-
-
Notifications
You must be signed in to change notification settings - Fork 5
Test/e2e login auth #19
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
Test/e2e login auth #19
Conversation
|
@n3c777 is attempting to deploy a commit to the Compass Team on Vercel. A member of the Team first needs to authorize it. |
MartinBraquet
left a comment
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.
Let's fix the failing preSetup and postSetup tests, otherwise it's a great structure!
Co-authored-by: Martin Braquet <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| await authenticatedPage.goto('/settings'); | ||
|
|
||
| await expect( | ||
| authenticatedPage.getByRole('heading', { name: 'Theme' }) |
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.
Test still errors out here. Not sure why right now.
1) [main] › tests/e2e/web/specs/postSignIn.spec.ts:4:5 › should be logged in and see settings page
Error: expect(locator).toBeVisible() failed
Locator: getByRole('heading', { name: 'Theme' })
Expected: visible
Received: <element(s) not found>
Timeout: 5000ms
Call log:
- Expect "toBeVisible" with timeout 5000ms
- waiting for getByRole('heading', { name: 'Theme' })
7 | await expect(
8 | authenticatedPage.getByRole('heading', { name: 'Theme' })
> 9 | ).toBeVisible();
| ^
10 | });
at /home/runner/work/Compass/Compass/tests/e2e/web/specs/postSignIn.spec.ts:9:5
Error Context: test-results/web-specs-postSignIn-shoul-5e404-ed-in-and-see-settings-page-main/error-context.md
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This PR introduces three components that enable two separate frontend E2E testing functionalities.
preSetup
This component is for testing areas of Compass that don’t require a logged-in user, such as signin and signup. These tests run independently.
To have Playwright recognize these files as part of preSetup, their filenames must include preSetup. This is the only component with this naming requirement; the others work normally.
A basic login test (signIn.setup.spec.ts and signInPage) has been added to demonstrate preSetup. It uses the POM design pattern.
setup
This component sets up the postSetup tests. It logs in by directly contacting Firebase and retrieves the auth state, which is then saved for future use. By avoiding UI-based login, this reduces flakiness and removes the need to re-login for every test.
postSetup
This is where the majority of E2E tests will live. It leverages the saved auth state from setup.ts as described above.
A small demonstration test (postSetup.spec.ts) shows postSetup functionality, but it can easily be replaced with other tests. The main advantage of this three-component setup is the ease of adding postSetup tests without worrying about login or authentication setup.
Hopefully this makes sense. The only thing missing is further documentation, which could be added maybe as a README for a more in-depth explanation.