Skip to content

✨ [Amp story shopping] Open or close defaults for product details section#37790

Merged
processprocess merged 7 commits intoampproject:mainfrom
processprocess:details-state
Mar 2, 2022
Merged

✨ [Amp story shopping] Open or close defaults for product details section#37790
processprocess merged 7 commits intoampproject:mainfrom
processprocess:details-state

Conversation

@processprocess
Copy link
Copy Markdown
Contributor

@processprocess processprocess commented Feb 28, 2022

  • Ensures product details section is closed when opening a template.
  • Ensures it is open when there is only one product on the page.
  • Updates comment.
  • Adds visual test for PDP display when there is one product on the page.

Demo Page 1 has multiple tags. Page 3 has one tag.

Images:

Details section closed by default when there is more than one product on page.
If opened, will re-open in the closed state.
Screen Shot 2022-03-01 at 12 59 37 PM

Details section open by default when the only product on the page (page 3 of demo)
Screen Shot 2022-03-01 at 12 59 48 PM

Fixes #37763

@amp-owners-bot
Copy link
Copy Markdown

amp-owners-bot bot commented Feb 28, 2022

Hey @gmajoulet! These files were changed:

extensions/amp-story-shopping/0.1/amp-story-shopping-attachment.js
extensions/amp-story-shopping/0.1/test/test-amp-story-shopping-config.js

await verifySelectorsVisible(page, name, [
'.i-amphtml-story-draggable-drawer-open',
]);
await page.waitForSelector('.i-amphtml-amp-story-shopping-pdp');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does .i-amphtml-amp-story-shopping-pdp always exist somewhere within the shopping attachment? If so, then should we use verifySelectorsVisible() as a more useful test?

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.

It doesn't build until the attachment is opened. I think waitForSelector is okay because of that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Got it, although you can update waitForSelector to verify that the PDP is displayed by default instead of solely verifying that the PDP exists somewhere in the DOM:

page.waitForSelector('.i-amphtml-amp-story-shopping-pdp', {visible: true})

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.

🔥 https://puppeteer.github.io/puppeteer/docs/puppeteer.page.waitforselector/
TIL about options on waitforselector :) Thank you!
I updated the other tests with this option.

await verifySelectorsVisible(page, name, [
'.i-amphtml-story-draggable-drawer-open',
]);
await page.waitForSelector('.i-amphtml-amp-story-shopping-pdp');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Got it, although you can update waitForSelector to verify that the PDP is displayed by default instead of solely verifying that the PDP exists somewhere in the DOM:

page.waitForSelector('.i-amphtml-amp-story-shopping-pdp', {visible: true})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[amp story shopping] PDP Details section open / closing state setting

3 participants