From 71c3ec0dc5ca6223ed138ff1aabbbda78fd8f739 Mon Sep 17 00:00:00 2001 From: David-Emmanuel DIVERNOIS Date: Mon, 24 Jul 2023 18:41:59 +0200 Subject: [PATCH] HTML snapshot test for all samples for consistency in the markup --- .prettierignore | 1 + .../src/app/samples/alert/config.route.ts | 4 +- .../src/app/samples/alert/dynamic.route.ts | 22 +- .../demo/src/app/samples/alert/icon.route.ts | 2 +- .../samples/focustrack/focustrack.route.ts | 4 +- .../src/app/samples/modal/default.route.ts | 2 +- .../app/samples/pagination/config.route.ts | 8 +- .../src/app/samples/rating/config.route.ts | 2 +- .../src/app/samples/select/select.route.ts | 4 +- angular/demo/src/index.html | 2 +- angular/lib/src/lib/alert/alert.component.ts | 7 +- .../lib/pagination/pagination.component.ts | 11 +- e2e/htmlSnapshot.ts | 188 +++++++++++++++ e2e/samplesMarkup.e2e-spec.ts | 19 ++ .../alert-config.html | 131 +++++++++++ .../alert-dynamic.html | 31 +++ .../alert-generic.html | 90 +++++++ .../alert-icon.html | 140 +++++++++++ .../alert-playground.html | 23 ++ .../focustrack-focustrack.html | 80 +++++++ .../modal-default.html | 20 ++ .../modal-playground.html | 9 + .../modal-stack.html | 15 ++ .../pagination-config.html | 162 +++++++++++++ .../pagination-default.html | 79 +++++++ .../pagination-playground.html | 71 ++++++ .../rating-config.html | 222 ++++++++++++++++++ .../rating-customtemplate.html | 171 ++++++++++++++ .../rating-default.html | 153 ++++++++++++ .../rating-form.html | 171 ++++++++++++++ .../rating-playground.html | 131 +++++++++++ .../rating-readonly.html | 127 ++++++++++ .../transition-transition.html | 139 +++++++++++ playwright.config.ts | 1 + react/demo/app/samples/alert/Icon.route.tsx | 2 +- .../app/samples/pagination/Config.route.tsx | 2 +- react/lib/Alert.tsx | 2 +- react/lib/pagination/Pagination.tsx | 4 +- svelte/demo/samples/alert/Config.route.svelte | 2 +- .../demo/samples/alert/Dynamic.route.svelte | 9 +- svelte/demo/samples/alert/Icon.svelte | 16 +- .../focustrack/Focustrack.route.svelte | 4 +- .../demo/samples/modal/Default.route.svelte | 1 - .../samples/pagination/Config.route.svelte | 4 +- .../samples/pagination/Default.route.svelte | 2 +- .../samples/transition/InnerComponent.svelte | 27 +-- 46 files changed, 2249 insertions(+), 68 deletions(-) create mode 100644 e2e/htmlSnapshot.ts create mode 100644 e2e/samplesMarkup.e2e-spec.ts create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-config.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-dynamic.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-generic.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-icon.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-playground.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/focustrack-focustrack.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/modal-default.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/modal-playground.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/modal-stack.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/pagination-config.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/pagination-default.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/pagination-playground.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-config.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-customtemplate.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-default.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-form.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-playground.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-readonly.html create mode 100644 e2e/samplesMarkup.e2e-spec.ts-snapshots/transition-transition.html diff --git a/.prettierignore b/.prettierignore index 3b91d94904..003ff267e0 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,3 +5,4 @@ coverage/ playwright-report/ test-results/ .svelte-kit/ +*-snapshots/ diff --git a/angular/demo/src/app/samples/alert/config.route.ts b/angular/demo/src/app/samples/alert/config.route.ts index 9e83a8a8eb..6b8a0e619c 100644 --- a/angular/demo/src/app/samples/alert/config.route.ts +++ b/angular/demo/src/app/samples/alert/config.route.ts @@ -18,14 +18,14 @@ export enum AlertStatus { @Component({ standalone: true, imports: [AgnosUIAngularModule, NgFor, FormsModule], - template: ` + template: `

diff --git a/angular/demo/src/app/samples/alert/dynamic.route.ts b/angular/demo/src/app/samples/alert/dynamic.route.ts index 57492f0e45..cc25e06e51 100644 --- a/angular/demo/src/app/samples/alert/dynamic.route.ts +++ b/angular/demo/src/app/samples/alert/dynamic.route.ts @@ -24,18 +24,16 @@ class AlertContainerService { standalone: true, imports: [AlertComponent, NgFor], template: ` -
- - -
+ + `, }) class ChildComponent { diff --git a/angular/demo/src/app/samples/alert/icon.route.ts b/angular/demo/src/app/samples/alert/icon.route.ts index 4e664636e4..5246b5397c 100644 --- a/angular/demo/src/app/samples/alert/icon.route.ts +++ b/angular/demo/src/app/samples/alert/icon.route.ts @@ -39,7 +39,7 @@ export default class IconAlertComponent { providers: [SlotDirective], template: ` - +

@@ -20,7 +20,7 @@ import {Component} from '@angular/core';
- +
`, diff --git a/angular/demo/src/app/samples/modal/default.route.ts b/angular/demo/src/app/samples/modal/default.route.ts index b03d806ea1..41b531f410 100644 --- a/angular/demo/src/app/samples/modal/default.route.ts +++ b/angular/demo/src/app/samples/modal/default.route.ts @@ -9,7 +9,7 @@ import {FormsModule} from '@angular/forms'; standalone: true, imports: [AgnosUIAngularModule, CommonModule, FormsModule], template: ` - +
{{ message }}
Do you want to save your changes? diff --git a/angular/demo/src/app/samples/pagination/config.route.ts b/angular/demo/src/app/samples/pagination/config.route.ts index 46b91cdfa8..6f63357d6f 100644 --- a/angular/demo/src/app/samples/pagination/config.route.ts +++ b/angular/demo/src/app/samples/pagination/config.route.ts @@ -47,7 +47,7 @@ const FILTER_PAG_REGEX = /[^0-9]/g; *ngIf="!widget.api.isEllipsis(page)" [attr.aria-label]="state.pagesLabel[i]" class="page-link au-page" - href + href="#" (click)="widget.actions.select(page); $event.preventDefault()" [attr.tabindex]="state.disabled ? '-1' : null" [attr.aria-disabled]="state.disabled ? 'true' : null" @@ -77,7 +77,7 @@ const FILTER_PAG_REGEX = /[^0-9]/g;
- Collection Size: + Collection size:
+
+
+
+
+ + +
+ + + +
+
+
+ +
+ + \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-dynamic.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-dynamic.html new file mode 100644 index 0000000000..40d0acb947 --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-dynamic.html @@ -0,0 +1,31 @@ + +
+
+ + + +
+
+ "Alerts in the service: 0" +
+
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-generic.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-generic.html new file mode 100644 index 0000000000..9dc0c7fad1 --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-generic.html @@ -0,0 +1,90 @@ + +
+
+ + + + + + + + +
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-icon.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-icon.html new file mode 100644 index 0000000000..6695db534d --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-icon.html @@ -0,0 +1,140 @@ + +
+
+ + + + + +
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-playground.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-playground.html new file mode 100644 index 0000000000..7a7ed228a3 --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/alert-playground.html @@ -0,0 +1,23 @@ + +
+
+ +
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/focustrack-focustrack.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/focustrack-focustrack.html new file mode 100644 index 0000000000..bd3c6fbe17 --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/focustrack-focustrack.html @@ -0,0 +1,80 @@ + +
+
+
+
+
+ "Container" +
+ +
+ +
+ +
+
+ + +
+ + + +
+
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/modal-default.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/modal-default.html new file mode 100644 index 0000000000..71f4ac0eec --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/modal-default.html @@ -0,0 +1,20 @@ + +
+
+ +
+
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/modal-playground.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/modal-playground.html new file mode 100644 index 0000000000..bf2304d7e7 --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/modal-playground.html @@ -0,0 +1,9 @@ + +
+
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/modal-stack.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/modal-stack.html new file mode 100644 index 0000000000..df7bb85dbf --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/modal-stack.html @@ -0,0 +1,15 @@ + +
+
+ +
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/pagination-config.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/pagination-config.html new file mode 100644 index 0000000000..8abe85f27b --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/pagination-config.html @@ -0,0 +1,162 @@ + +
+
+ +
+ "Current page is 1" +
+
+ "Disabled:" +
+ + +
+
+ "Collection size:" +
+ + + + +
+
+ "className:" +
+ + + +
+
+ "slotPages:" +
+ + + +
+
+
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/pagination-default.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/pagination-default.html new file mode 100644 index 0000000000..3d57c543eb --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/pagination-default.html @@ -0,0 +1,79 @@ + +
+
+ +
+ "Current page is 1" +
+
+ "Current page:" + + "1" + +
+
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/pagination-playground.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/pagination-playground.html new file mode 100644 index 0000000000..e38161aeb6 --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/pagination-playground.html @@ -0,0 +1,71 @@ + +
+
+ +
+ "Current page is 1" +
+
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-config.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-config.html new file mode 100644 index 0000000000..17b7fc57a4 --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-config.html @@ -0,0 +1,222 @@ + +
+
+
+ + "(*)" + + + "★" + + + "(*)" + + + "★" + + + "(*)" + + + "★" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + +
+
+ "Disabled:" +
+ + +
+
+ "maxRating:" +
+ + + + +
+
+ "className:" +
+ + + +
+
+ "slotStar:" +
+ + + +
+
+
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-customtemplate.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-customtemplate.html new file mode 100644 index 0000000000..ddd3d18873 --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-customtemplate.html @@ -0,0 +1,171 @@ + +
+
+
+ + "(*)" + + + + "★" + + + + "(*)" + + + + "★" + + + + "(*)" + + + + "★" + + + + "(*)" + + + + "★" + + + + "(*)" + + + + "★" + + + + "(*)" + + + + "★" + + + + "(*)" + + + + "★" + + + + "( )" + + + + "★" + + + + "( )" + + + + "★" + + + + "( )" + + + + "★" + + +
+
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-default.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-default.html new file mode 100644 index 0000000000..2484c734ef --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-default.html @@ -0,0 +1,153 @@ + +
+
+
+ + "(*)" + + + "★" + + + "(*)" + + + "★" + + + "(*)" + + + "★" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + +
+
+ "Current rate:" + + "3" + +
+ "Hovered:" + + "0" + +
+ "Left:" + + "0" + +
+
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-form.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-form.html new file mode 100644 index 0000000000..5c63526887 --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-form.html @@ -0,0 +1,171 @@ + +
+
+ +
+
+ + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + +
+
+
+ "Please rate us" +
+
+
+				"Model:"
+				
+					
+						"0"
+					
+				
+			
+ + +
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-playground.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-playground.html new file mode 100644 index 0000000000..e26e5b8435 --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-playground.html @@ -0,0 +1,131 @@ + +
+
+
+ + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + + + "( )" + + + "☆" + +
+
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-readonly.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-readonly.html new file mode 100644 index 0000000000..c6ecf91077 --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/rating-readonly.html @@ -0,0 +1,127 @@ + +
+
+
+ + "(*)" + + + + + "♥" + + "♥" + + + + "(*)" + + + + + "♥" + + "♥" + + + + "(*)" + + + + + "♥" + + "♥" + + + + "(*)" + + + + + "♥" + + "♥" + + + + "( )" + + + + + "♥" + + "♥" + + +
+
+
+ \ No newline at end of file diff --git a/e2e/samplesMarkup.e2e-spec.ts-snapshots/transition-transition.html b/e2e/samplesMarkup.e2e-spec.ts-snapshots/transition-transition.html new file mode 100644 index 0000000000..9eaf7eb95d --- /dev/null +++ b/e2e/samplesMarkup.e2e-spec.ts-snapshots/transition-transition.html @@ -0,0 +1,139 @@ + +
+
+

+ "Transition example" +

+
+ +
+

+ "Transition:" + + + +

+ + + + + + + +
    +
  • + "visible = true" +
  • +
  • + "transitioning = false" +
  • +
  • + "shown = true" +
  • +
  • + "hidden = false" +
  • +
+
+
+
+ "You can collapse this card by clicking Toggle" +
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/playwright.config.ts b/playwright.config.ts index 54017dd889..ca8bb47846 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -65,6 +65,7 @@ if (includesDemo) { const config: PlaywrightTestConfig = { testDir: 'e2e', testMatch: '*e2e-spec.ts', + snapshotPathTemplate: '{testDir}/{testFilePath}-snapshots/{arg}{ext}', retries: 0, reporter: [['list'], ['html', {open: 'never'}]], forbidOnly: isCI, diff --git a/react/demo/app/samples/alert/Icon.route.tsx b/react/demo/app/samples/alert/Icon.route.tsx index 1771fb1a09..96fadc2b75 100644 --- a/react/demo/app/samples/alert/Icon.route.tsx +++ b/react/demo/app/samples/alert/Icon.route.tsx @@ -23,7 +23,7 @@ const AlertIcon = ({widget, state}: AlertContext) => { return ( <> -
+
{state.dismissible ? ( diff --git a/react/demo/app/samples/pagination/Config.route.tsx b/react/demo/app/samples/pagination/Config.route.tsx index 495c3bae0f..fcc8a9601c 100644 --- a/react/demo/app/samples/pagination/Config.route.tsx +++ b/react/demo/app/samples/pagination/Config.route.tsx @@ -80,7 +80,7 @@ const PaginationDemo = () => {

- collection size:  + Collection size: 
+

diff --git a/svelte/demo/samples/alert/Dynamic.route.svelte b/svelte/demo/samples/alert/Dynamic.route.svelte index 184c757331..0655c1f8d9 100644 --- a/svelte/demo/samples/alert/Dynamic.route.svelte +++ b/svelte/demo/samples/alert/Dynamic.route.svelte @@ -17,16 +17,17 @@ export const alerts$ = createAlerts(); - - - alerts$.add({type: 'warning', slotDefault: 'Warning', dismissible: true, animation: true})}>Add warning
diff --git a/svelte/demo/samples/alert/Icon.svelte b/svelte/demo/samples/alert/Icon.svelte index 0bc5c52541..71e4b70dff 100644 --- a/svelte/demo/samples/alert/Icon.svelte +++ b/svelte/demo/samples/alert/Icon.svelte @@ -24,13 +24,15 @@ {@html typeIcon[state.type]} - - - - - - - +
+ + + + + + + +
{#if state.dismissible}
- - + +
diff --git a/svelte/demo/samples/modal/Default.route.svelte b/svelte/demo/samples/modal/Default.route.svelte index f83827944a..cdf898034e 100644 --- a/svelte/demo/samples/modal/Default.route.svelte +++ b/svelte/demo/samples/modal/Default.route.svelte @@ -13,7 +13,6 @@ -

- Collection Size:: + Collection size:
-
-
    -
  • visible = {$visible$}
  • -
  • transitioning = {$transitioning$}
  • -
  • shown = {$shown$}
  • -
  • hidden = {$hidden$}
  • -
- {#if !$paramRemoveFromDom$ || !$hidden$} -
-
-
You can collapse this card by clicking Toggle
-
+
    +
  • visible = {$visible$}
  • +
  • transitioning = {$transitioning$}
  • +
  • shown = {$shown$}
  • +
  • hidden = {$hidden$}
  • +
+ + {#if !$paramRemoveFromDom$ || !$hidden$} +
+
+
You can collapse this card by clicking Toggle
- {/if} -
+
+ {/if}