Skip to content

Commit

Permalink
Fix failing e2e tests due to changes in post preview button class names
Browse files Browse the repository at this point in the history
  • Loading branch information
thelovekesh committed Jan 8, 2024
1 parent 7423f59 commit fd4933a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/e2e/specs/block-editor/amp-preview-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ import {
deactivatePlugin,
} from '../../utils/amp-settings-utils';

const postPreviewBtnSelector = '.components-button.editor-post-preview';
const postPreviewBtnSelector =
'.components-button.edit-post-header__post-preview-button';
const ampPreviewBtnSelector = `${postPreviewBtnSelector} + .amp-wrapper-post-preview > .amp-editor-post-preview`;

// Remove legacy selectors once changes of <https://github.com/WordPress/gutenberg/pull/56921> lands in WP core.
const legacyPreviewBtnSelector = '.components-button.editor-post-preview';
const legacyAmpPreviewBtnSelector = `${legacyPreviewBtnSelector} + .amp-wrapper-post-preview > .amp-editor-post-preview`;

describe('AMP Preview button', () => {
it('is rendered on a new post', async () => {
await createNewPost();
Expand All @@ -27,9 +32,9 @@ describe('AMP Preview button', () => {
await deactivatePlugin('gutenberg');

await createNewPost();
await page.waitForSelector(postPreviewBtnSelector);
await page.waitForSelector(legacyPreviewBtnSelector);

await expect(page).toMatchElement(ampPreviewBtnSelector);
await expect(page).toMatchElement(legacyAmpPreviewBtnSelector);

await activatePlugin('gutenberg');
});
Expand Down

0 comments on commit fd4933a

Please sign in to comment.