Administration: Adjust the "No private directive present in cache control when user not logged in" test so the assertions won't fail if the headers don't contain a cache-control key at all.

Props joemcgill

Fixes #21938


git-svn-id: https://develop.svn.wordpress.org/trunk@56134 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn
2023-07-04 23:30:36 +00:00
parent 56af1e4b94
commit 77c59ac4f1

View File

@@ -20,20 +20,20 @@ describe( 'Cache Control header directives', () => {
await logout();
const response = await page.goto( createURL( '/hello-world/' ) );
const cacheControl = response.headers();
const responseHeaders = response.headers();
expect( cacheControl[ 'cache-control' ] ).not.toContain( 'no-store' );
expect( cacheControl[ 'cache-control' ] ).not.toContain( 'private' );
expect( responseHeaders ).toEqual( expect.not.objectContaining( { "cache-control": "no-store" } ) );
expect( responseHeaders ).toEqual( expect.not.objectContaining( { "cache-control": "private" } ) );
} );
it( 'Private directive header present in cache control when logged in.', async () => {
await visitAdminPage( '/wp-admin' );
const response = await page.goto( createURL( '/wp-admin' ) );
const cacheControl = response.headers();
const responseHeaders = response.headers();
expect( cacheControl[ 'cache-control' ] ).toContain( 'no-store' );
expect( cacheControl[ 'cache-control' ] ).toContain( 'private' );
expect( responseHeaders[ 'cache-control' ] ).toContain( 'no-store' );
expect( responseHeaders[ 'cache-control' ] ).toContain( 'private' );
} );
} );