-
Notifications
You must be signed in to change notification settings - Fork 160
Add Safari E2E tests to CI #3361
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
Draft
lmuntaner
wants to merge
15
commits into
main
Choose a base branch
from
lm-add-safari-e2e-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
64823f5
Add Safari E2E tests to CI
lmuntaner b42c018
try to fix Safari CI
lmuntaner 7ad82dc
Remove ignore certificate errors safari CI
lmuntaner 5993c87
Use different rule for Safari
lmuntaner cf459ac
Use Host header
lmuntaner 4914389
Safari passing one test!!!
lmuntaner 8de0844
Support other applications
lmuntaner 0340c0f
Pass CI pipeline
lmuntaner 6a1d23f
Enforce using fixtures test and expect
lmuntaner 429388b
Use dev CSP for E2E and extend it
lmuntaner 0e6c2a1
Improve comments and remove unnecessary config
lmuntaner dae8da0
Use import type
lmuntaner f94d365
Reintroduce `ignoreHTTPSErrors` from playwright
lmuntaner 8310265
Ignore certificate errors
lmuntaner 601f5ca
Fix
lmuntaner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/frontend/tests/e2e-playwright/authorize/alternativeOrigins.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/frontend/tests/e2e-playwright/authorize/delegationTtl.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/frontend/tests/e2e-playwright/authorize/postMessages.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/frontend/tests/e2e-playwright/dashboard/addPasskeys.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/frontend/tests/e2e-playwright/dashboard/removePasskey.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/frontend/tests/e2e-playwright/dashboard/renamePasskeys.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import { test as base, expect } from "@playwright/test"; | ||
|
|
||
| /** | ||
| * Custom test fixture that automatically applies host resolution routing | ||
| * to redirect all non-localhost requests to localhost:5173 | ||
| * | ||
| * ⚠️ IMPORTANT: All E2E test files MUST import { test, expect } from this file | ||
| * instead of from '@playwright/test' to ensure proper host routing for Safari/WebKit. | ||
| * | ||
| * @example | ||
| * // ✅ Correct | ||
| * import { test, expect } from "./fixtures"; | ||
| * // or from subdirectories: | ||
| * import { test, expect } from "../fixtures"; | ||
| * | ||
| * // ❌ Wrong - will fail ESLint | ||
| * import { test, expect } from "@playwright/test"; | ||
| */ | ||
| export const test = base.extend({ | ||
| page: async ({ page }, use) => { | ||
| // Safari doesn't support --host-resolver-rules, so we need page routing for Safari | ||
| // Chromium browsers will use host-resolver-rules which preserves Host headers better | ||
| const browserName = page.context().browser()?.browserType().name(); | ||
|
|
||
| if (browserName === "webkit") { | ||
| // Apply routing for Safari since it doesn't support host-resolver-rules | ||
| await page.context().route("**/*", (route) => { | ||
| // Should map the config in `vite.config.ts` | ||
| const hostToCanisterName: Record<string, string> = { | ||
| ["id.ai"]: "internet_identity", | ||
| ["identity.ic0.app"]: "internet_identity", | ||
| ["identity.internetcomputer.org"]: "internet_identity", | ||
| ["nice-name.com"]: "test_app", | ||
| }; | ||
|
|
||
| const req = route.request(); | ||
| const urlStr = req.url(); | ||
|
|
||
| let url: URL; | ||
| try { | ||
| url = new URL(urlStr); | ||
| } catch { | ||
| return route.continue(); | ||
| } | ||
|
|
||
| if (url.hostname.includes("localhost")) { | ||
| return route.continue(); | ||
| } | ||
|
|
||
| const canister_name = hostToCanisterName[url.hostname]; | ||
| if (canister_name === undefined) { | ||
| return route.continue(); | ||
| } | ||
| // The vite server uses the Host header and the localhost subdomain to determine where the redirect the request. | ||
| const newUrl = `https://${canister_name}.localhost:5173${url.pathname}${url.search}`; | ||
| return route.continue({ | ||
| url: newUrl, | ||
| // The vite server uses the Host header to determine where the redirect the request. | ||
| headers: { ...req.headers(), Host: url.hostname }, | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| // Use the page with routing applied | ||
| await use(page); | ||
| }, | ||
| }); | ||
|
|
||
| // Re-export expect for convenience | ||
| export { expect }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[nitpick] The
Pagetype import from@playwright/testcould be consolidated with the other imports or moved to a types-only import to improve organization.