-
Notifications
You must be signed in to change notification settings - Fork 155
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
1 parent
be9ecb4
commit 8b7a60b
Showing
4 changed files
with
43 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { BasePageObject } from '@cloudscape-design/browser-test-tools/page-objects'; | ||
import useBrowser from '@cloudscape-design/browser-test-tools/use-browser'; | ||
|
||
import createWrapper from '../../../lib/components/test-utils/selectors'; | ||
|
||
class RuntimeContentPage extends BasePageObject { | ||
async rerenderAlerts() { | ||
await this.click(createWrapper().findCheckbox('[data-testid="unmount-all"]').findNativeInput().toSelector()); | ||
await this.keys(['Space']); | ||
} | ||
} | ||
|
||
function setupTest(testFn: (page: RuntimeContentPage) => Promise<void>) { | ||
return useBrowser(async browser => { | ||
const page = new RuntimeContentPage(browser); | ||
await browser.url('#/light/alert/runtime-content/?autofocus=true'); | ||
await page.waitForVisible('.screenshot-area'); | ||
await testFn(page); | ||
}); | ||
} | ||
|
||
test( | ||
'should focus the alert', | ||
setupTest(async page => { | ||
await page.rerenderAlerts(); | ||
|
||
await expect(page.getFocusedElementText()).resolves.toEqual(expect.stringContaining('---REPLACEMENT---')); | ||
// (make sure entire page isn't focused) | ||
await expect(page.getFocusedElementText()).resolves.toEqual(expect.not.stringContaining('Header')); | ||
}) | ||
); |
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