-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(playwright): add playwright testing #33
Conversation
export const addIssueForm = { | ||
addButton: (page: Page) => page.locator("_react=Button[buttonText = \"Add\"]"), | ||
submitButton: (page: Page) => | ||
page.locator("_react=Button[buttonText = \"Submit\"]"), | ||
titleInput: (page: Page) => page.getByLabel("Title"), | ||
descriptionInput: (page: Page) => page.getByLabel("Description"), | ||
prioritySelect: (page: Page) => | ||
page.getByRole("combobox", { name: "Priority" }), | ||
typeSelect: (page: Page) => page.getByRole("combobox", { name: "Type" }), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont love this way of doing the selectors. thinking maybe a class might work better. thoughts are welcome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good from what I can tell, great work! Excited to see it in action
src/services/ui/playwright.config.ts
Outdated
// { | ||
// name: "firefox", | ||
// use: { ...devices["Desktop Firefox"] }, | ||
// }, | ||
|
||
// { | ||
// name: "webkit", | ||
// use: { ...devices["Desktop Safari"] }, | ||
// }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on uncommenting these configs for other browsers? Unless we want all devs to use chronium based browsers only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah thats a good idea. was there mainly for an example, but cant hurt to have them run as well 👍
Code Climate has analyzed commit dcd6f77 and detected 1 issue on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
🎉 This PR is included in version 1.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Purpose
This change adds end to end testing via playwright to the ui service, top level
run e2e
script, and gh workflow step. This is one part of two changes.Linked Issues to Close
https://qmacbis.atlassian.net/browse/OY2-23755
https://qmacbis.atlassian.net/browse/OY2-24074
Approach
We installed playwright in the ui and api services, added playwright config files in the roots of those directories, and added example tests. In the ui service these tests use a headless browser to run through actions and expectations in the local instance of the front end. In the api service these tests make calls and expectations to actual endpoints.
An e2e script was added to the run command. A step was added to the deploy workflow to set up the aws creds, install playwright browsers and run the e2e tests and upload the artifacts when complete.
You run e2e tests against a local running instance of the application by using the
run ui --stage [stage]
command to deploy and init an instance of the application. A second terminal can be used to run therun e2e
command which will run the playwright tests against the currently running instance of the ui on localhost:5000.Assorted Notes/Considerations/Learning
A pattern of selectors is used which define selectors in a separate dir and imports them for reusability.
The e2e tests for the UI service are located in
src/services/ui/e2e
and defined in .spec files. examples can be found to guide how to structure tests.When defining the selectors for elements make sure to define your selectors in the
e2e/selectors
directory. Defining selectors using react component names and properties is preferred to maintain consistent scalable testing. Other patterns can be used such as xpath, element type/name, and id/data-id/test-id. But should only be used when necessary.