From 606bb5cf79aa6d3f7f206b8bca7348f982fd3496 Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Mon, 8 Apr 2024 12:17:47 +0200 Subject: [PATCH] CYS - E2E tests: restore the default theme (#46268) * CYS - E2E tests: restore the default theme * Add changefile(s) from automation for the following project(s): woocommerce * add comment --------- Co-authored-by: github-actions --- .../changelog/46268-fix-restore-default-theme-cys | 4 ++++ .../tests/customize-store/assembler-hub.spec.js | 6 +++--- .../customize-store/assembler/color-picker.spec.js | 5 +++-- .../tests/customize-store/assembler/footer.spec.js | 14 +++++++++----- .../tests/customize-store/assembler/header.spec.js | 12 ++++++++---- .../assembler/logo-picker/logo-picker.spec.js | 5 +++-- .../e2e-pw/tests/customize-store/intro.spec.js | 8 +++----- .../tests/customize-store/transitional.spec.js | 6 +++--- plugins/woocommerce/tests/e2e-pw/utils/themes.js | 2 ++ 9 files changed, 38 insertions(+), 24 deletions(-) create mode 100644 plugins/woocommerce/changelog/46268-fix-restore-default-theme-cys diff --git a/plugins/woocommerce/changelog/46268-fix-restore-default-theme-cys b/plugins/woocommerce/changelog/46268-fix-restore-default-theme-cys new file mode 100644 index 00000000000..68aef60384e --- /dev/null +++ b/plugins/woocommerce/changelog/46268-fix-restore-default-theme-cys @@ -0,0 +1,4 @@ +Significance: patch +Type: dev +Comment: CYS - E2E tests: restore the default theme + diff --git a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler-hub.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler-hub.spec.js index 910f3dfaf06..5fd99d9f8a0 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler-hub.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler-hub.spec.js @@ -1,6 +1,6 @@ const { test: base, expect, request } = require( '@playwright/test' ); const { AssemblerPage } = require( './assembler/assembler.page' ); -const { activateTheme } = require( '../../utils/themes' ); +const { activateTheme, DEFAULT_THEME } = require( '../../utils/themes' ); const { setOption } = require( '../../utils/options' ); const ASSEMBLER_HUB_URL = @@ -47,8 +47,8 @@ test.describe( 'Store owner can view Assembler Hub for store customization', () } ); test.afterAll( async ( { baseURL } ) => { - // Reset theme back to twentynineteen - await activateTheme( 'twentynineteen' ); + // Reset theme back to default. + await activateTheme( DEFAULT_THEME ); // Reset tour to visible. await setOption( diff --git a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/color-picker.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/color-picker.spec.js index 52fb3c2cd4b..38f5e0dc0a0 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/color-picker.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/color-picker.spec.js @@ -2,7 +2,7 @@ const { test: base, expect, request } = require( '@playwright/test' ); const { AssemblerPage } = require( './assembler.page' ); const { CustomizeStorePage } = require( '../customize-store.page' ); -const { activateTheme } = require( '../../../utils/themes' ); +const { activateTheme, DEFAULT_THEME } = require( '../../../utils/themes' ); const { setOption } = require( '../../../utils/options' ); const test = base.extend( { @@ -50,7 +50,8 @@ test.skip( 'Assembler -> Color Pickers', () => { 'no' ); - await activateTheme( 'twentynineteen' ); + // Reset theme back to default. + await activateTheme( DEFAULT_THEME ); await customizeStorePageObject.resetCustomizeStoreChanges( baseURL ); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/footer.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/footer.spec.js index a944c959b09..727140a5453 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/footer.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/footer.spec.js @@ -1,6 +1,6 @@ const { test: base, expect, request } = require( '@playwright/test' ); const { AssemblerPage } = require( './assembler.page' ); -const { activateTheme } = require( '../../../utils/themes' ); +const { activateTheme, DEFAULT_THEME } = require( '../../../utils/themes' ); const { setOption } = require( '../../../utils/options' ); const test = base.extend( { @@ -42,8 +42,8 @@ test.describe( 'Assembler -> Footers', () => { 'woocommerce_admin_customize_store_completed', 'no' ); - - await activateTheme( 'twentynineteen' ); + // Reset theme back to default. + await activateTheme( DEFAULT_THEME ); } catch ( error ) { console.log( 'Store completed option not updated' ); } @@ -117,7 +117,9 @@ test.describe( 'Assembler -> Footers', () => { .frameLocator( 'iframe' ) .locator( '.wc-blocks-footer-pattern' ); - const expectedFooterClass = extractFooterClass( await footer.getAttribute( 'class' ) ); + const expectedFooterClass = extractFooterClass( + await footer.getAttribute( 'class' ) + ); await footer.click(); @@ -135,7 +137,9 @@ test.describe( 'Assembler -> Footers', () => { await page.goto( baseURL ); - const selectedFooterClasses = await page.locator( 'footer div.wc-blocks-footer-pattern' ).getAttribute( 'class' ); + const selectedFooterClasses = await page + .locator( 'footer div.wc-blocks-footer-pattern' ) + .getAttribute( 'class' ); expect( selectedFooterClasses ).toContain( expectedFooterClass ); } ); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/header.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/header.spec.js index 16f4759cf12..f60b1df5038 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/header.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/header.spec.js @@ -1,6 +1,6 @@ const { test: base, expect, request } = require( '@playwright/test' ); const { AssemblerPage } = require( './assembler.page' ); -const { activateTheme } = require( '../../../utils/themes' ); +const { activateTheme, DEFAULT_THEME } = require( '../../../utils/themes' ); const { setOption } = require( '../../../utils/options' ); const test = base.extend( { @@ -43,7 +43,7 @@ test.describe( 'Assembler -> headers', () => { 'no' ); - await activateTheme( 'twentynineteen' ); + await activateTheme( DEFAULT_THEME ); } catch ( error ) { console.log( 'Store completed option not updated' ); } @@ -117,7 +117,9 @@ test.describe( 'Assembler -> headers', () => { .frameLocator( 'iframe' ) .locator( '.wc-blocks-header-pattern' ); - const expectedHeaderClass = extractHeaderClass( await header.getAttribute( 'class' ) ); + const expectedHeaderClass = extractHeaderClass( + await header.getAttribute( 'class' ) + ); await header.click(); @@ -134,7 +136,9 @@ test.describe( 'Assembler -> headers', () => { await waitResponse; await page.goto( baseURL ); - const selectedHeaderClasses = await page.locator( 'header div.wc-blocks-header-pattern' ).getAttribute( 'class' ); + const selectedHeaderClasses = await page + .locator( 'header div.wc-blocks-header-pattern' ) + .getAttribute( 'class' ); expect( selectedHeaderClasses ).toContain( expectedHeaderClass ); } ); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/logo-picker/logo-picker.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/logo-picker/logo-picker.spec.js index c8aef70387c..74cf019d310 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/logo-picker/logo-picker.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/assembler/logo-picker/logo-picker.spec.js @@ -1,7 +1,7 @@ const { test: base, expect, request } = require( '@playwright/test' ); const { AssemblerPage } = require( '../assembler.page' ); const { LogoPickerPage } = require( './logo-picker.page' ); -const { activateTheme } = require( '../../../../utils/themes' ); +const { activateTheme, DEFAULT_THEME } = require( '../../../../utils/themes' ); const { CustomizeStorePage } = require( '../../customize-store.page' ); const { setOption } = require( '../../../../utils/options' ); @@ -59,7 +59,8 @@ test.describe( 'Assembler -> Logo Picker', () => { await customizeStorePageObject.resetCustomizeStoreChanges( baseURL ); - await activateTheme( 'twentynineteen' ); + // Reset theme back to default. + await activateTheme( DEFAULT_THEME ); } catch ( error ) { console.log( 'Store completed option not updated' ); } diff --git a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/intro.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/intro.spec.js index f05e6dfe667..8c6cf6add2e 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/intro.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/intro.spec.js @@ -1,7 +1,5 @@ const { test, expect, request } = require( '@playwright/test' ); -const { BASE_URL } = process.env; -const { features } = require( '../../utils' ); -const { activateTheme } = require( '../../utils/themes' ); +const { activateTheme, DEFAULT_THEME } = require( '../../utils/themes' ); const { setOption } = require( '../../utils/options' ); const CUSTOMIZE_STORE_URL = @@ -37,8 +35,8 @@ test.describe( 'Store owner can view the Intro page', () => { } ); test.afterAll( async ( { baseURL } ) => { - // Reset theme back to twentynineteen - await activateTheme( 'twentynineteen' ); + // Reset theme to the default. + await activateTheme( DEFAULT_THEME ); // Reset tour to visible. await setOption( diff --git a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/transitional.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/transitional.spec.js index 9fef530b3da..a43dd9fda2b 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/customize-store/transitional.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/customize-store/transitional.spec.js @@ -1,6 +1,6 @@ const { test: base, expect, request } = require( '@playwright/test' ); const { setOption } = require( '../../utils/options' ); -const { activateTheme } = require( '../../utils/themes' ); +const { activateTheme, DEFAULT_THEME } = require( '../../utils/themes' ); const { AssemblerPage } = require( './assembler/assembler.page' ); const CUSTOMIZE_STORE_URL = @@ -45,8 +45,8 @@ test.describe( 'Store owner can view the Transitional page', () => { } ); test.afterAll( async ( { baseURL } ) => { - // Reset theme back to twentynineteen - await activateTheme( 'twentynineteen' ); + // Reset theme back to default. + await activateTheme( DEFAULT_THEME ); // Reset tour to visible. await setOption( diff --git a/plugins/woocommerce/tests/e2e-pw/utils/themes.js b/plugins/woocommerce/tests/e2e-pw/utils/themes.js index 7a8b9a9a456..9f66ccb0edc 100644 --- a/plugins/woocommerce/tests/e2e-pw/utils/themes.js +++ b/plugins/woocommerce/tests/e2e-pw/utils/themes.js @@ -1,5 +1,7 @@ const { exec } = require( 'node:child_process' ); +export const DEFAULT_THEME = 'twentytwentythree'; + export const activateTheme = ( themeName ) => { return new Promise( ( resolve, reject ) => { const command = `wp-env run tests-cli wp theme activate ${ themeName }`;