Skip to content

Commit

Permalink
fix(core/drawer): start show true (#652)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Leroux <daniel.leroux@siemens.com>
  • Loading branch information
goncalosard and danielleroux committed Jul 27, 2023
1 parent 5ac2ecb commit 56c730b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/core/src/components/drawer/drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ export class Drawer {
});
}

componentDidLoad() {
this.onShowChanged(this.show);
}

render() {
return (
<Host
Expand Down
62 changes: 62 additions & 0 deletions packages/core/src/components/drawer/test/drawer.ct.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* SPDX-FileCopyrightText: 2023 Siemens AG
*
* SPDX-License-Identifier: MIT
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/*
* SPDX-FileCopyrightText: 2023 Siemens AG
*
* SPDX-License-Identifier: MIT
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { expect } from '@playwright/test';
import { test } from '@utils/test';

test('renders', async ({ mount, page }) => {
await mount(`<ix-drawer>Content</ix-drawer>`);
const drawer = page.locator('ix-drawer');
await expect(drawer).toHaveClass(/hydrated/);
await expect(drawer).not.toBeVisible();
});

test('show by property (initial)', async ({ mount, page }) => {
await mount(`<ix-drawer show>Content</ix-drawer>`);
const drawer = page.locator('ix-drawer');
await expect(drawer).toHaveClass(/hydrated/);
await expect(drawer).toBeVisible();
});

test('show by property', async ({ mount, page }) => {
await mount(`<ix-drawer show>Content</ix-drawer>`);
const drawer = page.locator('ix-drawer');

await drawer.evaluate(
(drawerElement: HTMLIxDrawerElement) => (drawerElement.show = true)
);

await expect(drawer).toHaveClass(/hydrated/);
await expect(drawer).toBeVisible();
});

test('toggle by property', async ({ mount, page }) => {
await mount(`<ix-drawer show>Content</ix-drawer>`);
const drawer = page.locator('ix-drawer');

await drawer.evaluate(
(drawerElement: HTMLIxDrawerElement) => (drawerElement.show = true)
);

await expect(drawer).toHaveClass(/hydrated/);
await expect(drawer).toBeVisible();

await drawer.evaluate(
(drawerElement: HTMLIxDrawerElement) => (drawerElement.show = false)
);

await expect(drawer).not.toBeVisible();
});

0 comments on commit 56c730b

Please sign in to comment.