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

Open external links in product description in a new page #11761

Merged
Changes from 1 commit
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
2 changes: 0 additions & 2 deletions spec/system/consumer/shopping/products_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,12 @@ def expect_product_description_html_to_be_displayed(product, html, not_include =
truncate: false, href: false)
# check inside list of products
within "#product-#{product.id} .product-description" do
expect(html).to include(html)
Copy link
Member

Choose a reason for hiding this comment

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

I now realise that html was supposed to refer to the page html but it got accidentally overridden by a parameter named the same. So I added more commits to show you how I would write it. It's maybe not as DRY but much simpler to read. And it makes it easier to fix up all the little mistakes of the previous code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice. Thanks @mkllnk. This was a good learning experience 🙏
and I understand what you mean, readability is more important than being pedantically DRY 😄

expect(html).not_to include(not_include) if not_include
expect(page).to have_content "..." if truncate # it truncates a long product description
end

# check in product description modal
click_link product.name
expect(page).to have_selector '.reveal-modal'
modal_should_be_open_for product
within(".reveal-modal") do
expect(find_link('external site')[:target]).to eq('_blank') if href
Expand Down
Loading