Skip to content

Commit

Permalink
Use context for offline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Feb 13, 2024
1 parent 06f480b commit 27d5a99
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions test/e2e/specs/editor/various/autosave.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ test.describe( 'Autosave', () => {

test( "shouldn't clear local autosave if remote autosave fails", async ( {
editor,
context,
page,
pageUtils,
} ) => {
Expand All @@ -194,12 +195,7 @@ test.describe( 'Autosave', () => {
).toBeGreaterThanOrEqual( 1 );

// Intercept autosave request and abort it.
await page.route(
( url ) => url.href.includes( 'autosave' ),
async ( route ) => {
await route.abort( 'internetdisconnected' );
}
);
await context.setOffline( true );
await page.evaluate( () =>
window.wp.data.dispatch( 'core/editor' ).autosave()
);
Expand Down Expand Up @@ -243,6 +239,7 @@ test.describe( 'Autosave', () => {

test( "shouldn't clear local autosave if save fails", async ( {
editor,
context,
page,
pageUtils,
} ) => {
Expand All @@ -268,15 +265,7 @@ test.describe( 'Autosave', () => {
await page.evaluate( () => window.sessionStorage.length )
).toBeGreaterThanOrEqual( 1 );

await page.route(
( url ) =>
url.href.includes(
`rest_route=${ encodeURIComponent( '/wp/v2/posts/' ) }`
),
async ( route ) => {
await route.abort( 'internetdisconnected' );
}
);
await context.setOffline( true );
await pageUtils.pressKeys( 'primary+s' );

await expect(
Expand Down

0 comments on commit 27d5a99

Please sign in to comment.