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

[e2e tests] Add new tests for up-sells and cross-sells #44154

Merged
merged 23 commits into from Feb 7, 2024

Conversation

adimoldovan
Copy link
Contributor

@adimoldovan adimoldovan commented Jan 29, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

Closes https://github.com/woocommerce/woocommerce-quality/issues/604.
Closes https://github.com/woocommerce/woocommerce-quality/issues/605.

Added a new spec file with tests for linked products. It covers adding and removing up-sells and adding and removing cross-sells.

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

Run the new spec file locally:

pnpm env:restart && pnpm test:e2e-pw ./tests/e2e-pw/tests/merchant/product-linked-producs.spec.js

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

@github-actions github-actions bot added focus: e2e tests Issues related to e2e tests plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Jan 29, 2024
@adimoldovan adimoldovan self-assigned this Jan 29, 2024
Copy link
Contributor

github-actions bot commented Jan 29, 2024

Test Results Summary

Commit SHA: fa6c18d

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 37s
E2E Tests303001003139m 19s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@adimoldovan adimoldovan marked this pull request as ready for review January 30, 2024 15:14
@adimoldovan adimoldovan requested review from a team January 30, 2024 15:14
Copy link
Contributor

github-actions bot commented Jan 30, 2024

Hi @lanej0, @woocommerce/solaris

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Contributor

@lanej0 lanej0 left a comment

Choose a reason for hiding this comment

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

The viewport isn't an issue, more of a question. I'm curious about creating a function to replace page.goto though -- we're definitely trying to stay away from replacing built-in Playwright functions with custom ones.

stateDir: 'tests/e2e-pw/test-results/storage/',
trace: 'retain-on-failure',
video: 'on-first-retry',
viewport: { width: 1280, height: 720 },
viewport: { width: 1280, height: 1600 },
Copy link
Contributor

Choose a reason for hiding this comment

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

While I don't think there's an issue with this, what was the driver for increasing the viewport size so much? Seems like an unlikely resolution that a user might use, which could lead to some false-negative test results... but maybe I'm overthinking it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reverted the height in fa6c18d.
It helped me when I ran tests locally to view all elements at once without needing to scroll. I should have reverted it before.
I'm curious though to know your thoughts on the possible false-negative that could result from that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really think it's an issue, but e2e tests are meant to mimic real-world testing. Most people probably aren't browsing a site using a browser that's 1600 pixels tall. In an extreme edge case, if there was some CSS limiting scrolling/the content shown, and the button you're supposed to click is cropped off screen... there could be an issue. Not likely, scenario for sure.

await page.goto(
`wp-admin/post.php?post=${ productId }&action=edit`
);
} );
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you choose to abstract this into a separate function instead of just inlining page.goto in the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are two steps in that function, the goto and the click on the Linked Products, which are repeated in each test, so I extracted them into a function, the same way that I extracted the update product logic into updateProduct function.

@adimoldovan
Copy link
Contributor Author

Thanks @lanej0 for reviewing.

I'm curious about creating a function to replace page.goto though -- we're definitely trying to stay away from replacing built-in Playwright functions with custom ones.

I think you misinterpreted this one. I did not replace Playwright's page.goto and I'm not trying to replace the build-in functions in any way. I was merely extracting some common code into a function. Those two steps are repeating in each of the 4 tests, it seems reasonable to me to extract it in a function.

@lanej0 lanej0 merged commit 035eb2d into trunk Feb 7, 2024
34 checks passed
@lanej0 lanej0 deleted the e2e/add/related-products branch February 7, 2024 22:28
@github-actions github-actions bot added this to the 8.7.0 milestone Feb 7, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Feb 7, 2024
@nigeljamesstevenson nigeljamesstevenson added status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: e2e tests Issues related to e2e tests plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants