-
Notifications
You must be signed in to change notification settings - Fork 206
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
Add E2E tests for silent authentication #5150
base: main
Are you sure you want to change the base?
Conversation
Preview URL 🚀 : https://blurts-server-pr-5150-mgjlpikfea-uk.a.run.app |
src/middleware.ts
Outdated
@@ -12,6 +12,13 @@ export function middleware(request: NextRequest) { | |||
|
|||
const requestHeaders = new Headers(request.headers); | |||
requestHeaders.set("x-nonce", nonce); | |||
|
|||
if (typeof process.env.E2E_TEST_ENV !== "undefined") { |
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'm worried that if this env var is set somehow in stage or prod, we would have this feature flag forced?
Would it be better to have more guards like && not in prod && not in stage
?
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 was thinking about this as well and had the condition first only to check for process.env.E2E_TEST_ENV === "local"
. Now you are mentioning it: Yes, let’s play it safe — changed in 4ae7859.
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.
The feature flag override looks good to me, and overall the code looks good too (just a question and an ignorable suggestion). However... The tests appear to fail now in CI?
@@ -71,4 +71,34 @@ export class AuthPage { | |||
expect(verificationCode).toBeDefined(); | |||
await this.enterVerificationCode(verificationCode as string); | |||
} | |||
|
|||
async signInToFxA(email: string, password: string) { |
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.
It's not clear to me (because I'm not terribly familiar with our existing e2e tests) why this extra method is needed - don't we already have methods to sign in?
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 method is for logging explicitly in to the Monitor Accounts application and not Monitor.
src/middleware.ts
Outdated
|
||
if (process.env.E2E_TEST_ENV === "local") { | ||
const forcedFeatureFlags = | ||
request.nextUrl.searchParams.get("feature_flags"); | ||
requestHeaders.set("x-forced-feature-flags", forcedFeatureFlags ?? ""); | ||
} | ||
|
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.
Instead of adding runtime middleware code, we could also skip that and just directly call .setExtraHTTPHeaders
, I think?
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.
Oh yeah — a lot better: 7f3feea.
src/e2e/pages/authPage.ts
Outdated
await this.page.goto( | ||
`${process.env.E2E_TEST_BASE_URL as string}/?feature_flags=PromptNoneAuthFlow&utm_source=moz-account&utm_campaign=settings-promo&utm_content=monitor-free`, |
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.
So as per my other comment, this would be:
await this.page.goto( | |
`${process.env.E2E_TEST_BASE_URL as string}/?feature_flags=PromptNoneAuthFlow&utm_source=moz-account&utm_campaign=settings-promo&utm_content=monitor-free`, | |
await this.page.setExtraHTTPHeaders({ "x-forced-feature-flags": "PromptNoneAuthFlow" }); | |
await this.page.goto( | |
`${process.env.E2E_TEST_BASE_URL as string}/?utm_source=moz-account&utm_campaign=settings-promo&utm_content=monitor-free`, |
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.
Thanks! Update in 7f3feea.
Preview URL 🚀 : https://blurts-server-pr-5150-mgjlpikfea-uk.a.run.app |
Preview URL 🚀 : https://blurts-server-pr-5150-mgjlpikfea-uk.a.run.app |
Preview URL 🚀 : https://blurts-server-pr-5150-mgjlpikfea-uk.a.run.app |
Preview URL 🚀 : https://blurts-server-pr-5150-mgjlpikfea-uk.a.run.app |
There seems to be an issue with the test accounts set up for the E2E tests. When attempting to sign-in to FxA directly rather than via OAuth it results in an application error. The issue is filed under FXA-10631. |
Preview URL 🚀 : https://blurts-server-pr-5150-mgjlpikfea-uk.a.run.app |
Preview URL 🚀 : https://blurts-server-pr-5150-mgjlpikfea-uk.a.run.app |
1 similar comment
Preview URL 🚀 : https://blurts-server-pr-5150-mgjlpikfea-uk.a.run.app |
Preview URL 🚀 : https://blurts-server-pr-5150-mgjlpikfea-uk.a.run.app |
Preview URL 🚀 : https://blurts-server-pr-5150-mgjlpikfea-uk.a.run.app |
References:
PR #5104
Description
This PR adds E2E tests for the silent authentication flow.