-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Test with motion enabled (#1823)
- Loading branch information
Showing
13 changed files
with
143 additions
and
16 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
const { configure } = require('@cloudscape-design/browser-test-tools/use-browser'); | ||
|
||
configure({ | ||
browserName: 'ChromeHeadless', | ||
browserCreatorOptions: { | ||
seleniumUrl: 'http://localhost:9515', | ||
}, | ||
webdriverOptions: { | ||
baseUrl: 'http://localhost:8080', | ||
}, | ||
}); | ||
|
||
jest.retryTimes(3, { logErrorsBeforeRetry: true }); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
const execa = require('execa'); | ||
const glob = require('glob'); | ||
const waitOn = require('wait-on'); | ||
const { task } = require('../utils/gulp-utils.js'); | ||
|
||
module.exports = task('test:motion', async () => { | ||
const devServer = execa('webpack', ['serve', '--config', 'pages/webpack.config.integ.js'], { | ||
env: { | ||
NODE_ENV: 'development', | ||
}, | ||
}); | ||
await waitOn({ resources: ['http://localhost:8080'] }); | ||
|
||
const files = glob.sync('src/**/__motion__/**/*.test.ts'); | ||
await execa('jest', ['-c', 'jest.motion.config.js', ...files], { stdio: 'inherit' }); | ||
|
||
devServer.cancel(); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
const path = require('path'); | ||
const os = require('os'); | ||
|
||
module.exports = { | ||
verbose: true, | ||
testEnvironment: 'node', | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: 'tsconfig.integ.json', | ||
}, | ||
}, | ||
reporters: ['default', 'github-actions'], | ||
testTimeout: 60_000, // 1min | ||
maxWorkers: os.cpus().length * (process.env.GITHUB_ACTION ? 3 : 1), | ||
globalSetup: '<rootDir>/build-tools/integ/global-setup.js', | ||
globalTeardown: '<rootDir>/build-tools/integ/global-teardown.js', | ||
setupFilesAfterEnv: [path.join(__dirname, 'build-tools', 'integ', 'setup.motion.js')], | ||
moduleFileExtensions: ['js', 'ts'], | ||
testRegex: '(/(__motion__)/.*(\\.|/)test)\\.[jt]sx?$', | ||
preset: 'ts-jest', | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import useBrowser from '@cloudscape-design/browser-test-tools/use-browser'; | ||
import { flashbar } from '../__integ__/pages/base'; | ||
import { FlashbarInteractivePage } from '../__integ__/pages/interactive-page'; | ||
|
||
const setupTest = (options: { visualRefresh?: boolean }, testFn: (page: FlashbarInteractivePage) => Promise<void>) => { | ||
return useBrowser(async browser => { | ||
const page = new FlashbarInteractivePage(browser); | ||
const baseUrl = '#/light/flashbar/interactive'; | ||
const url = | ||
options.visualRefresh === undefined | ||
? baseUrl | ||
: `${baseUrl}?${new URLSearchParams({ | ||
visualRefresh: `${options.visualRefresh}`, | ||
}).toString()}`; | ||
await browser.url(url); | ||
await page.waitForVisible(flashbar.toSelector()); | ||
await testFn(page); | ||
}); | ||
}; | ||
|
||
describe('Collapsible flashbar', () => { | ||
describe('can dismiss all items', () => { | ||
it.each([true, false])('visualRefresh=%s', visualRefresh => | ||
setupTest({ visualRefresh }, async page => { | ||
await page.removeAll(); | ||
await page.toggleStackingFeature(); | ||
await expect(page.countFlashes()).resolves.toBe(0); | ||
await page.addInfoFlash(); | ||
await expect(page.countFlashes()).resolves.toBe(1); | ||
await page.waitForVisible(page.getItem(1).findDismissButton().toSelector()); | ||
await page.dismissFirstItem(); | ||
await page.waitForAssertion(() => expect(page.countFlashes()).resolves.toBe(0)); | ||
})() | ||
); | ||
}); | ||
}); |
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