-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
147 additions
and
10 deletions.
There are no files selected for viewing
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,14 @@ | ||
{ | ||
"name": "@console/integration-tests", | ||
"version": "0.0.0-fixed", | ||
"description": "Console integration tests", | ||
"private": true, | ||
"devDependencies": { | ||
"protractor": "5.4.x", | ||
"protractor-fail-fast": "3.x", | ||
"protractor-jasmine2-screenshot-reporter": "0.5.x", | ||
"js-yaml": "^3.13.1", | ||
"lodash-es": "4.x", | ||
"immutable": "3.x" | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
frontend/packages/console-demo-plugin/integration-tests/tests/demo.scenario.ts
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,17 @@ | ||
import { browser, ExpectedConditions as until, $, $$ } from 'protractor'; | ||
import { appHost, testName } from '@console/integration-tests/protractor.conf'; | ||
import * as crudView from '@console/integration-tests/views/crud.view'; | ||
|
||
const BROWSER_TIMEOUT = 15000; | ||
|
||
describe('Demo integration test', () => { | ||
it(`Test namespace ${testName}`, async () => { | ||
// Use projects if OpenShift so non-admin users can run tests. | ||
const resource = browser.params.openshift === 'true' ? 'projects' : 'namespaces'; | ||
await browser.get(`${appHost}/k8s/cluster/${resource}`); | ||
await crudView.isLoaded(); | ||
const exists = await crudView.rowForName(testName).isPresent(); | ||
|
||
expect(browser.getCurrentUrl()).toContain(appHost); | ||
}); | ||
}); |
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,13 +1,23 @@ | ||
{ | ||
"name": "@console/demo-plugin", | ||
"name": "@console/console-demo-plugin", | ||
"version": "0.0.0-fixed", | ||
"description": "Demo plugin for Console web application", | ||
"private": true, | ||
"dependencies": { | ||
"@console/plugin-sdk": "0.0.0-fixed", | ||
"@console/shared": "0.0.0-fixed" | ||
}, | ||
"devDependencies": { | ||
"@console/integration-tests": "0.0.0-fixed" | ||
}, | ||
"consolePlugin": { | ||
"entry": "src/plugin.tsx" | ||
"entry": "src/plugin.tsx", | ||
"integrationTests": { | ||
"demo": [ | ||
"@console/integration-tests/tests/login.scenario.ts", | ||
"@console/integration-tests/tests/base.scenario.ts", | ||
"integration-tests/tests/demo.scenario.ts" | ||
] | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
frontend/packages/console-plugin-sdk/src/codegen/__tests__/plugin-integration-tests.spec.ts
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,51 @@ | ||
import { PluginPackage, Package, filterActivePluginPackages } from '../plugin-resolver'; | ||
import { pluginsIntegrationTests } from '../plugin-integration-tests'; | ||
import { templatePackage } from './plugin-resolver.spec'; | ||
|
||
describe('pluginsIntegrationTests', () => { | ||
it('returns a map of short-plugin-name to a list of its integration tests.', () => { | ||
const appPackage: Package = { | ||
...templatePackage, | ||
name: 'app', | ||
dependencies: { | ||
'@console/bar-plugin': '1.2.3', | ||
'@console/qux-plugin': '2.3.4', | ||
}, | ||
}; | ||
|
||
const pluginPackages: PluginPackage[] = [ | ||
{ | ||
...templatePackage, | ||
name: '@console/bar-plugin', | ||
version: '1.2.3', | ||
consolePlugin: { | ||
entry: 'plugin.ts', | ||
integrationTests: { | ||
bar: [ | ||
'@console/integration-tests/tests/base.scenario.ts', | ||
'integration-tests/tests/index.scenario.ts', | ||
], | ||
}, | ||
}, | ||
}, | ||
{ | ||
...templatePackage, | ||
name: '@console/qux-plugin', | ||
version: '2.3.4', | ||
consolePlugin: { entry: 'plugin.ts' }, | ||
}, | ||
]; | ||
|
||
const pluginFilter = () => filterActivePluginPackages(appPackage, pluginPackages); | ||
|
||
const monorepoRootDir = process.cwd(); | ||
const expectedTests = { | ||
bar: [ | ||
'tests/base.scenario.ts', | ||
`${monorepoRootDir}/packages/bar-plugin/integration-tests/tests/index.scenario.ts`, | ||
], | ||
}; | ||
|
||
expect(pluginsIntegrationTests(monorepoRootDir, pluginFilter)).toEqual(expectedTests); | ||
}); | ||
}); |
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,4 @@ | ||
export { resolvePluginPackages } from './plugin-resolver'; | ||
export { pluginsIntegrationTests } from './plugin-integration-tests'; | ||
export { loadActivePlugins, getActivePluginsModule } from './active-plugins'; | ||
export { printPluginStats } from './plugin-stats'; |
42 changes: 42 additions & 0 deletions
42
frontend/packages/console-plugin-sdk/src/codegen/plugin-integration-tests.ts
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,42 @@ | ||
import * as _ from 'lodash'; | ||
import { | ||
PluginPackage, | ||
filterActivePluginPackages, | ||
PluginPackageFilter, | ||
resolvePluginPackages, | ||
} from './plugin-resolver'; | ||
|
||
const CONSOLE_PLUGIN_PREFIX = '@console/'; | ||
const CONSOLE_INEGRATION_TESTS_PREFIX = '@console/integration-tests/'; | ||
|
||
/** | ||
* Return a map of short-plugin-name to a list of it's integration tests. | ||
*/ | ||
export const pluginsIntegrationTests = ( | ||
monorepoRootDir: string = process.cwd(), | ||
pluginFilter: PluginPackageFilter = filterActivePluginPackages, | ||
) => { | ||
const shortName = (plugin: PluginPackage) => | ||
plugin.name.startsWith(CONSOLE_PLUGIN_PREFIX) && plugin.name.slice(CONSOLE_PLUGIN_PREFIX.length); | ||
|
||
const integrationTests = (plugin: PluginPackage) => | ||
plugin.consolePlugin.integrationTests && | ||
_.transform( | ||
plugin.consolePlugin.integrationTests, | ||
(result, paths, testName) => | ||
(result[testName] = _.map(paths, (path) => | ||
path.startsWith(CONSOLE_INEGRATION_TESTS_PREFIX) | ||
? path.slice(CONSOLE_INEGRATION_TESTS_PREFIX.length) | ||
: `${monorepoRootDir}/packages/${shortName(plugin)}/${path}`, | ||
)), | ||
{}, | ||
); | ||
|
||
const plugins = resolvePluginPackages(monorepoRootDir, pluginFilter); | ||
const pluginTests = plugins.reduce( | ||
(map, plugin) => Object.assign(map, integrationTests(plugin)), | ||
{}, | ||
); | ||
|
||
return _.pickBy(pluginTests, (tests) => !!tests); | ||
}; |
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