Update LYS frontend e2e tests to test with both classic and block themes (#50657)

* Update lys e2e tests to test with both classic and block themes

* Add changelog

* Minor tweak
This commit is contained in:
Chi-Hsuan Huang 2024-08-15 20:57:12 +08:00 committed by GitHub
parent 8c9c784f45
commit c07b7b8e9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 97 additions and 56 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Update lys e2e tests to test with both classic and block themes

View File

@ -1,5 +1,76 @@
const { test, expect, request } = require( '@playwright/test' );
const { setOption } = require( '../../utils/options' );
const { activateTheme, DEFAULT_THEME } = require( '../../utils/themes' );
async function runComingSoonTests( themeContext = '' ) {
const testSuffix = themeContext ? ` (${ themeContext })` : '';
test( `Entire site coming soon mode${ testSuffix }`, async ( {
page,
baseURL,
} ) => {
try {
await setOption(
request,
baseURL,
'woocommerce_coming_soon',
'yes'
);
await setOption(
request,
baseURL,
'woocommerce_store_pages_only',
'no'
);
} catch ( error ) {
console.log( error );
}
await page.goto( baseURL );
await page
.locator( '.woocommerce-coming-soon-banner' )
.waitFor( { state: 'visible' } );
await expect(
page.getByText(
"Pardon our dust! We're working on something amazing — check back soon!"
)
).toBeVisible();
} );
test( `Store only coming soon mode${ testSuffix }`, async ( {
page,
baseURL,
} ) => {
try {
await setOption(
request,
baseURL,
'woocommerce_coming_soon',
'yes'
);
await setOption(
request,
baseURL,
'woocommerce_store_pages_only',
'yes'
);
} catch ( error ) {
console.log( error );
}
await page.goto( baseURL + '/shop/' );
await expect(
page.getByText( 'Great things are on the horizon' )
).toBeVisible();
await expect(
page.getByText(
'Something big is brewing! Our store is in the works and will be launching soon!'
)
).toBeVisible();
} );
}
test.describe(
'Launch Your Store front end - logged out',
@ -18,68 +89,34 @@ test.describe(
}
} );
test( 'Entire site coming soon mode', async ( { page, baseURL } ) => {
try {
await setOption(
request,
baseURL,
'woocommerce_coming_soon',
'yes'
);
test.describe( 'Block Theme (Twenty Twenty Four)', () => {
test.beforeAll( async () => {
await activateTheme( 'twentytwentyfour' );
} );
await setOption(
request,
baseURL,
'woocommerce_store_pages_only',
'no'
);
} catch ( error ) {
console.log( error );
}
test.afterAll( async () => {
// Reset theme to the default.
await activateTheme( DEFAULT_THEME );
} );
await page.goto( baseURL );
await page
.locator( '.woocommerce-coming-soon-banner' )
.waitFor( { state: 'visible' } );
await expect(
page.getByText(
"Pardon our dust! We're working on something amazing — check back soon!"
)
).toBeVisible();
runComingSoonTests( test.step, test.use );
} );
test( 'Store only coming soon mode', async ( { page, baseURL } ) => {
try {
await setOption(
request,
baseURL,
'woocommerce_coming_soon',
'yes'
);
test.describe( 'Classic Theme (Storefront)', () => {
test.beforeAll( async () => {
await activateTheme( 'storefront' );
} );
await setOption(
request,
baseURL,
'woocommerce_store_pages_only',
'yes'
);
} catch ( error ) {
console.log( error );
}
test.afterAll( async () => {
// Reset theme to the default.
await activateTheme( DEFAULT_THEME );
} );
await page.goto( baseURL + '/shop/' );
await expect(
page.getByText( 'Great things are on the horizon' )
).toBeVisible();
await expect(
page.getByText(
'Something big is brewing! Our store is in the works and will be launching soon!'
)
).toBeVisible();
runComingSoonTests(
test.step,
test.use,
'Classic Theme (Storefront)'
);
} );
}
);