Skip to content

Commit

Permalink
chore: add test for drawer testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nmerget committed Jul 24, 2024
1 parent c71dba3 commit 7daacd5
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 43 deletions.
21 changes: 9 additions & 12 deletions packages/components/src/components/drawer/drawer.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export default function DBDrawer(props: DBDrawerProps) {
onClick={(event) => {
state.handleClose(event);
}}
autofocus=""
onKeyDown={(event) => state.handleClose(event)}
data-backdrop={props.backdrop}>
<article
Expand All @@ -95,17 +94,15 @@ export default function DBDrawer(props: DBDrawerProps) {
<div class="db-drawer-header-text">
<Slot name="drawerHeader" />
</div>
<Show when={props.withCloseButton}>
<DBButton
className="button-close-drawer"
id={props.closeButtonId}
icon="cross"
variant="ghost"
noText
onClick={() => state.handleClose('close')}>
{props.closeButtonText ?? DEFAULT_CLOSE_BUTTON}
</DBButton>
</Show>
<DBButton
className="button-close-drawer"
id={props.closeButtonId}
icon="cross"
variant="ghost"
noText
onClick={() => state.handleClose('close')}>
{props.closeButtonText ?? DEFAULT_CLOSE_BUTTON}
</DBButton>
</header>
<div class="db-drawer-content">{props.children}</div>
</article>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/drawer/drawer.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const testAction = () => {
test(`should open and close drawer`, async ({ mount, page }) => {
let test: string = '';
const drawer: any = (
<DBDrawer onClose={() => (test = 'close')} withCloseButton={true}>
<DBDrawer onClose={() => (test = 'close')}>
<span data-testid="test">Test</span>
</DBDrawer>
);
Expand Down
5 changes: 0 additions & 5 deletions packages/components/src/components/drawer/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ export interface DBDrawerDefaultProps {
* The "end" depends on which direction you use.
*/
rounded?: boolean;

/**
* The withCloseButton attribute shows/hides the default close button.
*/
withCloseButton?: boolean;
}

export type DBDrawerProps = DBDrawerDefaultProps &
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/components/header/header.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export default function DBHeader(props: DBHeaderProps) {
<DBDrawer
className="db-header-drawer"
rounded
withCloseButton
spacing="small"
open={props.drawerOpen}
onClose={() => state.toggle()}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
>
<db-drawer
[backdrop]="exampleProps?.backdrop"
[withCloseButton]="exampleProps?.withCloseButton"
[rounded]="exampleProps?.rounded"
[width]="exampleProps?.width"
[spacing]="exampleProps?.spacing"
Expand Down
2 changes: 0 additions & 2 deletions showcases/react-showcase/src/components/drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const getDrawer = ({
id,
width,
rounded,
withCloseButton,
spacing,
openDrawer,
setOpenDrawer,
Expand All @@ -24,7 +23,6 @@ const getDrawer = ({
}: DBDrawerProps & AdditionalDrawerProperties) => (
<div>
<DBDrawer
withCloseButton={withCloseButton}
rounded={rounded}
width={width}
spacing={spacing}
Expand Down
5 changes: 4 additions & 1 deletion showcases/screen-reader/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ const translations: Record<string, string[]> = {
checked: ['aktiviert'],
' of ': [' von '],
clickable: ['anklickbar'],
'has auto complete': ['mit Auto Vervollständigung']
'has auto complete': ['mit Auto Vervollständigung'],
unknown: ['Unbekannt'],
dialog: ['Dialogfeld'],
document: ['Dokument']
};

const cleanSpeakInstructions = (phraseLog: string[]): string[] =>
Expand Down
16 changes: 16 additions & 0 deletions showcases/screen-reader/tests/drawer.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { getTest, testDefault } from '../default';

const test = getTest();

test.describe('DBDrawer', () => {
testDefault({
test,
title: 'should autofocus',
url: './#/01/drawer?page=density',
async testFn(voiceOver, nvda) {
const screenReader = voiceOver ?? nvda;
await screenReader?.act();
await screenReader?.next();
}
});
});
19 changes: 0 additions & 19 deletions showcases/shared/drawer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"name": "Functional",
"className": "db-density-functional",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
Expand All @@ -15,7 +14,6 @@
"name": "(Default) Regular",
"className": "db-density-regular",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
Expand All @@ -24,7 +22,6 @@
"name": "Expressive",
"className": "db-density-expressive",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
Expand All @@ -37,15 +34,13 @@
{
"name": "(Default) Medium",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
},
{
"name": "Full",
"props": {
"withCloseButton": true,
"width": "full",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -59,15 +54,13 @@
{
"name": "(Default) No rounding",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
},
{
"name": "Rounded",
"props": {
"withCloseButton": true,
"rounded": true,
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -81,15 +74,13 @@
{
"name": "(Default) Medium",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
},
{
"name": "Small",
"props": {
"withCloseButton": true,
"spacing": "small",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -98,7 +89,6 @@
{
"name": "Large",
"props": {
"withCloseButton": true,
"spacing": "large",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -107,7 +97,6 @@
{
"name": "No spacing",
"props": {
"withCloseButton": true,
"spacing": "none",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -121,15 +110,13 @@
{
"name": "(Default) With Backdrop",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
},
{
"name": "Backdrop-weak",
"props": {
"withCloseButton": true,
"backdrop": "weak",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -138,7 +125,6 @@
{
"name": "Invisible",
"props": {
"withCloseButton": true,
"backdrop": "invisible",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -147,7 +133,6 @@
{
"name": "No Backdrop",
"props": {
"withCloseButton": true,
"backdrop": "none",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -161,15 +146,13 @@
{
"name": "(Default) Right",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
},
{
"name": "Left",
"props": {
"withCloseButton": true,
"direction": "left",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -178,7 +161,6 @@
{
"name": "Up",
"props": {
"withCloseButton": true,
"direction": "up",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -187,7 +169,6 @@
{
"name": "Down",
"props": {
"withCloseButton": true,
"direction": "down",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand Down
1 change: 0 additions & 1 deletion showcases/vue-showcase/src/components/drawer/Drawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const toggleDrawer = (example?: string) => {
>
<DBDrawer
:backdrop="exampleProps?.backdrop"
:withCloseButton="exampleProps?.withCloseButton"
:rounded="exampleProps?.rounded"
:width="exampleProps?.width"
:spacing="exampleProps?.spacing"
Expand Down

0 comments on commit 7daacd5

Please sign in to comment.