Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky change detection tests causing intermittent failures #31861

Merged
merged 1 commit into from
May 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,17 @@ describe( 'Change detection', () => {
// Keyboard shortcut Ctrl+S save.
await pressKeyWithModifier( 'primary', 'S' );

// Start this check immediately after save since dirtying the post will
// remove the "Saved" with the Save button.
const savedPromise = page.waitForSelector(
'.editor-post-saved-state.is-saved'
);

// Dirty post while save is in-flight.
await page.type( '.editor-post-title__input', '!' );

// Allow save to complete. Disabling interception flushes pending.
await Promise.all( [
page.waitForSelector( '.editor-post-saved-state.is-saved' ),
releaseSaveIntercept(),
] );
await Promise.all( [ savedPromise, releaseSaveIntercept() ] );

await assertIsDirty( true );
} );
Expand All @@ -302,14 +305,17 @@ describe( 'Change detection', () => {
// Keyboard shortcut Ctrl+S save.
await pressKeyWithModifier( 'primary', 'S' );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you insert await page.evaluate( () => new Promise( window.requestIdleCallback ) ); after this line, the problem can be consistently reproduced, as you would expect. So if the test runs slow, the tests fails.


// Start this check immediately after save since dirtying the post will
// remove the "Saved" with the Save button.
const savedPromise = page.waitForSelector(
'.editor-post-saved-state.is-saved'
);

await clickBlockAppender();
await page.keyboard.type( 'Paragraph' );

// Allow save to complete. Disabling interception flushes pending.
await Promise.all( [
page.waitForSelector( '.editor-post-saved-state.is-saved' ),
releaseSaveIntercept(),
] );
await Promise.all( [ savedPromise, releaseSaveIntercept() ] );

await assertIsDirty( true );
} );
Expand Down