Skip to content

Commit

Permalink
refactor test implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
just-boris committed Oct 11, 2024
1 parent 87552c0 commit 936684e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
29 changes: 12 additions & 17 deletions pages/app-layout/utils/content-blocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import range from 'lodash/range';
import BreadcrumbGroup from '~components/breadcrumb-group';
import Button from '~components/button';
import Container from '~components/container';
import Flashbar from '~components/flashbar';
import Flashbar, { FlashbarProps } from '~components/flashbar';
import Header from '~components/header';
import HelpPanel from '~components/help-panel';
import SideNavigation from '~components/side-navigation';
Expand Down Expand Up @@ -66,23 +66,18 @@ export function Navigation() {

export function Notifications() {
const [visible, setVisible] = useState(true);
if (!visible) {
return null;
const notifications: Array<FlashbarProps.MessageDefinition> = [];
if (visible) {
notifications.push({
type: 'success',
header: 'Success message',
statusIconAriaLabel: 'success',
dismissLabel: 'Dismiss notification',
dismissible: true,
onDismiss: () => setVisible(false),
});
}
return (
<Flashbar
items={[
{
type: 'success',
header: 'Success message',
statusIconAriaLabel: 'success',
dismissLabel: 'Dismiss notification',
dismissible: true,
onDismiss: () => setVisible(false),
},
]}
/>
);
return <Flashbar items={notifications} />;
}

export function Footer({ legacyConsoleNav }: { legacyConsoleNav: boolean }) {
Expand Down
2 changes: 1 addition & 1 deletion pages/app-layout/with-notifications.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function () {
// the case when `notifications` slot is not falsy, but eventually it renders no HTML
notifications={<Notifications />}
content={
<div className={styles.highlightBorder}>
<div data-testid="content-root" className={styles.highlightBorder}>
<h1>Distribution details</h1>
<p>Some information</p>
</div>
Expand Down
15 changes: 11 additions & 4 deletions src/app-layout/__integ__/awsui-applayout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,18 @@ describe.each(['classic', 'refresh', 'refresh-toolbar'] as Theme[])('%s', theme
test(
'does not render notifications slot when it is empty',
setupTest({ pageName: 'with-notifications' }, async page => {
const { height: originalHeight } = await page.getBoundingBox(wrapper.findNotifications().toSelector());
expect(originalHeight).toBeGreaterThan(0);
await page.click(wrapper.findNotifications().findFlashbar().findItems().get(1).findDismissButton().toSelector());
const { height: newHeight } = await page.getBoundingBox(wrapper.findNotifications().toSelector());
expect(newHeight).toEqual(0);
await expect(page.isExisting(wrapper.findNotifications().findFlashbar().toSelector())).resolves.toBe(true);
await expect(
page.getElementsCount(wrapper.findNotifications().findFlashbar().findItems().toSelector())
).resolves.toBe(0);
const { top: contentTop } = await page.getBoundingBox('[data-testid="content-root"]');
const expectedOffset = {
classic: 61,
refresh: 57,
'refresh-toolbar': 99,
}[theme];
expect(contentTop).toEqual(expectedOffset);

Check warning on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / Components integ tests

RETRY 1: classic › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 61 Received: 59 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check warning on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / Components integ tests

RETRY 2: classic › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 61 Received: 59 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check warning on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / Components integ tests

RETRY 3: classic › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 61 Received: 59 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check failure on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / Components integ tests

classic › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 61 Received: 59 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check warning on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / Components integ tests

RETRY 1: refresh › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 57 Received: 55 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check warning on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / Components integ tests

RETRY 2: refresh › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 57 Received: 55 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check failure on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / Components integ tests

refresh › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 57 Received: 55 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check failure on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / Components integ tests

refresh-toolbar › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 99 Received: 97 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check warning on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components integration tests

RETRY 1: classic › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 61 Received: 59 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check warning on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components integration tests

RETRY 2: classic › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 61 Received: 59 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check warning on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components integration tests

RETRY 3: classic › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 61 Received: 59 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check failure on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components integration tests

classic › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 61 Received: 59 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check warning on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components integration tests

RETRY 1: refresh › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 57 Received: 55 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check warning on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components integration tests

RETRY 2: refresh › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 57 Received: 55 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check warning on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components integration tests

RETRY 3: refresh › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 57 Received: 55 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check failure on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components integration tests

refresh › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 57 Received: 55 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check warning on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components integration tests

RETRY 1: refresh-toolbar › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 99 Received: 97 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check warning on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components integration tests

RETRY 2: refresh-toolbar › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 99 Received: 97 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)

Check failure on line 181 in src/app-layout/__integ__/awsui-applayout.test.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components integration tests

refresh-toolbar › does not render notifications slot when it is empty

expect(received).toEqual(expected) // deep equality Expected: 99 Received: 97 at src/app-layout/__integ__/awsui-applayout.test.ts:181:26 at src/app-layout/__integ__/awsui-applayout.test.ts:35:7 at Object.<anonymous> (node_modules/@cloudscape-design/browser-test-tools/use-browser.js:36:13)
})
);
});

0 comments on commit 936684e

Please sign in to comment.