Skip to content

Prevent duplicated script to hide admin bar in onboarding wizard#6877

Merged
westonruter merged 5 commits intoampproject:developfrom
rtCamp:bug/6643-prevent-duplicate-scripts
Feb 8, 2022
Merged

Prevent duplicated script to hide admin bar in onboarding wizard#6877
westonruter merged 5 commits intoampproject:developfrom
rtCamp:bug/6643-prevent-duplicate-scripts

Conversation

@NikhilJoshua
Copy link
Copy Markdown
Contributor

Summary

Fixes #6643

Changes in PR prevent scripts to be printed multiple times on the page to hide the admin bar in the onboarding wizard.

image

Checklist

  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 2, 2022

CLA assistant check
All committers have signed the CLA.

@NikhilJoshua NikhilJoshua force-pushed the bug/6643-prevent-duplicate-scripts branch from c620b1a to c86439b Compare February 4, 2022 10:58
Copy link
Copy Markdown
Collaborator

@delawski delawski left a comment

Choose a reason for hiding this comment

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

Thanks for your work, @NikhilJoshua!

The code looks good to me. I left one minor comment about unit tests.

Comment on lines +197 to +198
add_action( 'wp_head', 'amp_remove_admin_bar_in_phone_preview' );
add_action( 'amp_post_template_head', 'amp_remove_admin_bar_in_phone_preview' );
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we maybe add a unit test to confirm that those two hooks are added?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@delawski There's no test case for amp_init() function so I didn't add it. Let me know your thoughts on it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'll defer to @westonruter who's now free to do the final review.

Co-authored-by: Piotr Delawski <delawski@users.noreply.github.com>
@delawski delawski requested a review from westonruter February 8, 2022 16:21
@delawski delawski added this to the v2.2.2 milestone Feb 8, 2022
@delawski delawski added the Bug Something isn't working label Feb 8, 2022
Copy link
Copy Markdown
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

The E2E test is a nice touch 👍

Comment on lines +25 to +28
// Checks for admin bar in iframe phone preview.
const iframeElement = await page.$( 'iframe[name="amp-wizard-completion-preview"]' );
const previewFrame = await iframeElement.contentFrame();
await expect( previewFrame ).not.toMatchElement( '#wpadminbar' );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you :)

@westonruter westonruter merged commit 95c009a into ampproject:develop Feb 8, 2022
westonruter added a commit that referenced this pull request Feb 8, 2022
Co-authored-by: Piotr Delawski <delawski@users.noreply.github.com>
Co-authored-by: Nikhil Joshua <nikhiljoshua.a@gmail.com>
@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Changelogged Whether the issue/PR has been added to release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicated script printed to hide admin bar in onboarding wizard

4 participants