Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import AxeBuilder from '@axe-core/playwright';
import { expect, test } from '@playwright/experimental-ct-react';

import { DBDrawer } from '../drawer';
import { DBNavigation } from '../navigation';
import { DBNavigationItem } from './index';
// @ts-ignore - vue can only find it with .ts as file ending
import { DEFAULT_VIEWPORT } from '../../shared/constants.ts';
Expand All @@ -19,6 +21,44 @@ const comp: any = (
</menu>
);

const nestedSubNavigationComp: any = (
<DBDrawer open={true} backdrop="none" position="absolute">
<DBNavigation>
<DBNavigationItem
subNavigation={
<>
<DBNavigationItem
subNavigation={
<>
<DBNavigationItem>
<a href="#" aria-current="page">
Sub-Sub-Navi-Item 1
</a>
</DBNavigationItem>
<DBNavigationItem>
<a href="#">Sub-Sub-Navi-Item 2</a>
</DBNavigationItem>
</>
}>
Sub-Navi-Item 1
</DBNavigationItem>
<DBNavigationItem>
<a href="#">Sub-Navi-Item 2</a>
</DBNavigationItem>
</>
}>
Navi-Item 1
</DBNavigationItem>
<DBNavigationItem icon="x_placeholder">
<a href="#">Navi-Item 2</a>
</DBNavigationItem>
<DBNavigationItem disabled>
<a href="#">Navi-Item 3</a>
</DBNavigationItem>
</DBNavigation>
</DBDrawer>
);

const testComponent = () => {
test('should contain text', async ({ mount }) => {
const component = await mount(comp);
Expand All @@ -29,6 +69,27 @@ const testComponent = () => {
const component = await mount(comp);
await expect(component).toHaveScreenshot();
});

test('should match screenshot with expanded mobile sub-navigation inside drawer', async ({
mount,
page
}) => {
await page.emulateMedia({ reducedMotion: 'reduce' });
await mount(nestedSubNavigationComp);

const navigationItemButton = page.getByRole('button', { name: 'Navi-Item 1' });
const subNavigationItemButton = page.getByRole('button', { name: 'Sub-Navi-Item 1' });

await navigationItemButton.click();
await expect(navigationItemButton).toHaveAttribute('aria-expanded', 'true');

await subNavigationItemButton.click();
await expect(subNavigationItemButton).toHaveAttribute('aria-expanded', 'true');

const drawer = page.locator('.db-drawer');
Comment thread
mfranzke marked this conversation as resolved.
await expect(drawer).toHaveAttribute('data-transition', 'open');
await expect(drawer).toHaveScreenshot();
Comment thread
mfranzke marked this conversation as resolved.
Comment on lines +89 to +91
});
};
const testA11y = () => {
test('should have same aria-snapshot', async ({ mount }, testInfo) => {
Expand Down
Loading