@@ -4,39 +4,45 @@ import * as dotenv from 'dotenv';
44const chartsListWithErrors = [ ] ;
55var totalChartExamplesCount = 302 ;
66const themes = [ "Light" , "Dark" ] ;
7+ const modes = [ "LTR" , "RTL" ] ;
8+ test . beforeEach ( async ( { page } ) => {
9+ //Pass base URL as part of playwright command
10+ //ex: npx cross-env BASE_URL='https://fluentchartstest-stage.azurewebsites.net/' npx playwright test
11+ await page . goto ( process . env . BASE_URL ! ) ;
12+ } ) ;
713
8- for ( const theme of themes ) {
9- test . describe ( `Declarative chart examples in ${ theme } mode` , ( ) => {
10- test . beforeEach ( async ( { page } ) => {
11- //Pass base URL as part of playwright command
12- //ex: npx cross-env BASE_URL='https://fluentchartstest-stage.azurewebsites.net/' npx playwright test
13- await page . goto ( process . env . BASE_URL ) ;
14- } ) ;
15-
16- for ( let index = 0 ; index < totalChartExamplesCount ; index ++ ) {
17- test ( `Declarative chart example ${ index + 1 } ` , async ( { page } ) => {
18- const iframe = page . locator ( '#webpack-dev-server-client-overlay' ) ;
19- if ( await iframe . count ( ) > 0 ) {
20- await iframe . evaluate ( ( el ) => el . remove ( ) ) . catch ( ( ) => {
21- console . warn ( "Failed to remove overlay iframe." ) ;
22- } ) ;
14+ for ( const theme of themes ) {
15+ for ( const mode of modes ) {
16+ //test.describe(`Declarative chart examples in ${theme} mode and ${mode} layout`, () => {
17+ for ( let index = 0 ; index < totalChartExamplesCount ; index ++ ) {
18+ test ( `Declarative chart example ${ index + 1 } -${ theme } -${ mode } mode` , async ( { page } ) => {
19+ const iframe = page . locator ( '#webpack-dev-server-client-overlay' ) ;
20+ if ( await iframe . count ( ) > 0 ) {
21+ await iframe . evaluate ( ( el ) => el . remove ( ) ) . catch ( ( ) => {
22+ console . warn ( "Failed to remove overlay iframe." ) ;
23+ } ) ;
24+ }
25+ await page . getByRole ( 'combobox' ) . first ( ) . click ( ) ;
26+ const listbox = page . getByRole ( 'listbox' ) ;
27+ await listbox . getByRole ( 'option' ) . locator ( `text=${ theme } ` ) . click ( ) ;
28+ const rtlSwitch = page . getByRole ( 'switch' ) ;
29+ const isCurrentlyRTL = await rtlSwitch . isChecked ( ) ;
30+ if ( ( mode === 'RTL' && ! isCurrentlyRTL ) || ( mode === 'LTR' && isCurrentlyRTL ) ) {
31+ await rtlSwitch . click ( ) ;
32+ }
33+ const combobox = page . getByRole ( 'combobox' ) ;
34+ await combobox . nth ( 1 ) . click ( ) ;
35+ const listitems = listbox . last ( ) . getByRole ( 'option' ) ;
36+ if ( ! chartsListWithErrors . includes ( index ) ) {
37+ await listitems . nth ( index ) . scrollIntoViewIfNeeded ( ) ;
38+ await listitems . nth ( index ) . click ( ) ;
39+ const chart = page . getByTestId ( 'chart-container' ) ;
40+ await expect ( chart ) . toHaveScreenshot ( ) ;
41+ await combobox . last ( ) . click ( ) ;
42+ } else {
43+ test . fail ( ) ;
44+ }
45+ } ) ;
46+ } ;
2347 }
24- await page . getByRole ( 'combobox' ) . first ( ) . click ( ) ;
25- const listbox = page . getByRole ( 'listbox' ) ;
26- await listbox . getByRole ( 'option' ) . locator ( `text=${ theme } ` ) . click ( ) ;
27- const combobox = page . getByRole ( 'combobox' ) ;
28- await combobox . nth ( 1 ) . click ( ) ;
29- const listitems = listbox . last ( ) . getByRole ( 'option' ) ;
30- if ( ! chartsListWithErrors . includes ( index ) ) {
31- await listitems . nth ( index ) . scrollIntoViewIfNeeded ( ) ;
32- await listitems . nth ( index ) . click ( ) ;
33- const chart = page . getByTestId ( 'chart-container' ) ;
34- await expect ( chart ) . toHaveScreenshot ( ) ;
35- await combobox . last ( ) . click ( ) ;
36- } else {
37- test . fail ( ) ;
38- }
39- } ) ;
40- } ;
41- } ) ;
4248}
0 commit comments