mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
As per the migration plan shared last year, this migrates all browser-based tests in WordPress core to use Playwright. This includes end-to-end, performance, and visual regression tests. Props swissspidy, mamaduka, kevin940726, bartkalisz, desrosj, adamsilverstein. Fixes #59517. git-svn-id: https://develop.svn.wordpress.org/trunk@56926 602fd350-edb4-49c9-b593-d223f7449a82
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
/**
|
|
* WordPress dependencies
|
|
*/
|
|
import { test, expect } from '@wordpress/e2e-test-utils-playwright';
|
|
|
|
test.describe( 'Cache Control header directives', () => {
|
|
test.beforeAll( async ( { requestUtils } ) => {
|
|
await requestUtils.deleteAllPosts();
|
|
});
|
|
|
|
test(
|
|
'No private directive present in cache control when user not logged in.',
|
|
async ( { browser, admin, editor}
|
|
) => {
|
|
await admin.createNewPost( { title: 'Hello World' } );
|
|
await editor.publishPost();
|
|
|
|
await admin.visitAdminPage( '/' );
|
|
|
|
// Create a new incognito browser context to simulate logged-out state.
|
|
const context = await browser.newContext();
|
|
const loggedOutPage = await context.newPage();
|
|
|
|
const response = await loggedOutPage.goto( '/hello-world/' );
|
|
const responseHeaders = response.headers();
|
|
|
|
// Dispose context once it's no longer needed.
|
|
await context.close();
|
|
|
|
expect( responseHeaders ).toEqual( expect.not.objectContaining( { "cache-control": "no-store" } ) );
|
|
expect( responseHeaders ).toEqual( expect.not.objectContaining( { "cache-control": "private" } ) );
|
|
} );
|
|
|
|
test(
|
|
'Private directive header present in cache control when logged in.',
|
|
async ( { page, admin }
|
|
) => {
|
|
await admin.visitAdminPage( '/' );
|
|
|
|
const response = await page.goto( '/wp-admin' );
|
|
const responseHeaders = response.headers();
|
|
|
|
expect( responseHeaders[ 'cache-control' ] ).toContain( 'no-store' );
|
|
expect( responseHeaders[ 'cache-control' ] ).toContain( 'private' );
|
|
} );
|
|
} );
|