-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #29637 - Allow jest test to use foremanReact
Jest allows local modules to be specified by path, which allows us to use foremanReact as long as foreman is present in a sibling directory to Katello
- Loading branch information
John Mitsch
committed
Apr 30, 2020
1 parent
576259f
commit 93bb8eb
Showing
23 changed files
with
106 additions
and
105 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
// Check for foremanReact files provided by Foreman and make available as module in Jest. | ||
const checkForForemanReact = (foremanLocations, foremanReact) => { | ||
const currentDir = process.cwd(); | ||
|
||
let foremanReactFullPath; | ||
foremanLocations.forEach((relativeForemanPath) => { | ||
if (fs.existsSync(path.join(currentDir, relativeForemanPath))) { | ||
const fullPath = path.join(currentDir, relativeForemanPath, foremanReact); | ||
if (fs.existsSync(fullPath)) foremanReactFullPath = fullPath; | ||
} | ||
}); | ||
return foremanReactFullPath; | ||
}; | ||
|
||
const foremanReactRelative = 'webpack/assets/javascripts/react_app'; | ||
const possibleForemanLocations = ['./foreman', '../foreman', '../../foreman']; | ||
const notFound = 'Foreman directory can not be found! These tests require Foreman to be present ' + | ||
'in either a parent, sibling, or child directory relative to Katello and contain the expected ' + | ||
`files in foreman/${foremanReactRelative}.`; | ||
|
||
const foremanReactFull = checkForForemanReact(possibleForemanLocations, foremanReactRelative); | ||
if (!foremanReactFull) throw new Error(notFound); | ||
|
||
// Jest configuration | ||
module.exports = { | ||
collectCoverage: true, | ||
collectCoverageFrom: [ | ||
'webpack/**/*.js', | ||
'!webpack/**/bundle*', | ||
], | ||
coverageReporters: [ | ||
'lcov', | ||
], | ||
testURL: 'http://localhost/', | ||
setupFiles: [ | ||
'raf/polyfill', | ||
'./webpack/test_setup.js', | ||
], | ||
setupFilesAfterEnv: [ | ||
'./webpack/global_test_setup.js', | ||
], | ||
testPathIgnorePatterns: [ | ||
'/node_modules/', | ||
'<rootDir>/foreman/', | ||
'<rootDir>/.+fixtures.+', | ||
'<rootDir>/engines', | ||
], | ||
moduleDirectories: [ | ||
'node_modules/@theforeman/vendor-core/node_modules', | ||
'node_modules', | ||
'webpack/test-utils', | ||
], | ||
modulePathIgnorePatterns: [ | ||
'<rootDir>/foreman/', | ||
], | ||
moduleNameMapper: { | ||
'^.+\\.(css|scss)$': 'identity-obj-proxy', | ||
'^foremanReact(.*)$': `${foremanReactFull}$1`, | ||
}, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
.../foremanReact/components/BreadcrumbBar.js → ...anReact/components/BreadcrumbBar/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
|
||
const BreadcrumbsBar = () => jest.fn(); | ||
export default BreadcrumbsBar; |
2 changes: 0 additions & 2 deletions
2
webpack/__mocks__/foremanReact/components/PermissionDenied/index.js
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
webpack/__mocks__/foremanReact/components/common/ModalProgressBar.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware/IntervalSelectors.js
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware/index.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const addLocaleData = jest.fn(); | ||
export const FormattedRelative = jest.fn(); | ||
export const intlShape = jest.fn(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters