From a9a1d114fe37aa142c9493177efebb20d3b8cf6b Mon Sep 17 00:00:00 2001 From: Rares Herta Date: Fri, 31 Mar 2023 10:23:37 +0300 Subject: [PATCH] feat: change html structure and add e2e tests --- .../dialog/__tests__/bq-dialog.e2e.ts | 49 +++++++++++++++++-- .../bee-q/src/components/dialog/bq-dialog.tsx | 21 ++++---- .../bee-q/src/components/dialog/readme.md | 10 ++-- 3 files changed, 61 insertions(+), 19 deletions(-) diff --git a/packages/bee-q/src/components/dialog/__tests__/bq-dialog.e2e.ts b/packages/bee-q/src/components/dialog/__tests__/bq-dialog.e2e.ts index 31e91bf38..cc76d03d9 100644 --- a/packages/bee-q/src/components/dialog/__tests__/bq-dialog.e2e.ts +++ b/packages/bee-q/src/components/dialog/__tests__/bq-dialog.e2e.ts @@ -19,12 +19,53 @@ describe('bq-dialog', () => { expect(element.shadowRoot).not.toBeNull(); }); - it('should display text', async () => { + it('should display title', async () => { const page = await newE2EPage(); - await page.setContent(''); + await page.setContent('

Dialog Title

'); + + const element = await page.find('bq-dialog'); + + expect(element).toEqualText('Dialog Title'); + }); + + it('should display content', async () => { + const page = await newE2EPage(); + await page.setContent( + '

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

', + ); - const element = await page.find('bq-dialog >>> p'); + const element = await page.find('bq-dialog'); - expect(element).toEqualText('My name is Stencil'); + expect(element).toEqualText('Lorem Ipsum is simply dummy text of the printing and typesetting industry.'); }); + + // it('closes dialog when clicking on the close button', async () => { + // const page = await newE2EPage(); + // await page.setContent(''); + + // const dialogClosedEvent = await page.spyOnEvent('bqClick'); + + // const element = await page.find('bq-dialog >>> [part="button-close"]'); + + // await element.click(); + + // expect(dialogClosedEvent).toHaveReceivedEventTimes(1); + // }); + + // it('should render footer with at least one button', async () => { + // const page = await newE2EPage(); + // await page.setContent(` + //
+ // + // Primary button + // + // Primary button + //
+ //
+ // `); + + // const element = await page.find('bq-dialog'); + + // expect(element).toContain('bq-button'); + // }); }); diff --git a/packages/bee-q/src/components/dialog/bq-dialog.tsx b/packages/bee-q/src/components/dialog/bq-dialog.tsx index 02b5e9475..8020ce3a3 100644 --- a/packages/bee-q/src/components/dialog/bq-dialog.tsx +++ b/packages/bee-q/src/components/dialog/bq-dialog.tsx @@ -6,7 +6,7 @@ import { DIALOG_SIZE, DIALOG_FOOTER_VARIANT, TDialogSize, TDialogFooterVariant } /** * @part base - The component wrapper container inside the shadow DOM * @part container - The `
` container that holds the dialog content - * @part icon-close - The icon that close the dialog on click + * @part button-close - The button that close the dialog on click */ @Component({ @@ -125,16 +125,17 @@ export class BqDialog {
- - + - + part="button-close" + > + + +