Update tests to not use a hard coded localhost:3000#1949
Update tests to not use a hard coded localhost:3000#1949jeesunikim wants to merge 1 commit intomainfrom
localhost:3000#1949Conversation
There was a problem hiding this comment.
Pull request overview
Updates Playwright E2E tests to avoid hard-coded http://localhost:3000 URLs so tests can run against a configurable port (and leverage Playwright’s baseURL support).
Changes:
- Replaced many
page.goto("http://localhost:3000/...")calls with relative navigations likepage.goto("/..."). - Introduced
BASE_URL(derived fromprocess.env.PORT) in a few tests/mocks that still construct absolute URLs. - Updated mocked storage state origin/shareable URLs to use the configurable base URL.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/viewXdrToJsonPage.test.ts | Switches navigation to relative URL. |
| tests/e2e/viewJsonToXdrPage.test.ts | Switches navigation to relative URL. |
| tests/e2e/urlParams.test.ts | Uses BASE_URL for deep-link navigations with query params. |
| tests/e2e/txDashTokenSummary.test.ts | Switches navigation to relative URL. |
| tests/e2e/txDashStateChange.test.ts | Switches navigation to relative URL. |
| tests/e2e/txDashSignatures.test.ts | Switches navigation to relative URL. |
| tests/e2e/txDashResourceProfiler.test.ts | Switches navigation to relative URL. |
| tests/e2e/txDashInfo.test.ts | Switches navigation to relative URL. |
| tests/e2e/txDashFeeBreakdown.test.ts | Switches navigation to relative URL. |
| tests/e2e/txDashEvents.test.ts | Switches navigation to relative URL. |
| tests/e2e/txDashContracts.test.ts | Switches navigation to relative URL. |
| tests/e2e/txDashClassicOperations.test.ts | Switches navigation to relative URL. |
| tests/e2e/submitTransactionPage.test.ts | Switches navigation to relative URL. |
| tests/e2e/smartContractsVersionHistory.test.ts | Switches navigation to relative URL. |
| tests/e2e/smartContractsStorage.test.ts | Switches navigation to relative URL in helper. |
| tests/e2e/smartContractsContractInfo.test.ts | Switches navigation to relative URL. |
| tests/e2e/simulateTransactionPage.test.ts | Switches navigation to relative URL. |
| tests/e2e/signerSelector.test.ts | Uses BASE_URL when creating a new context/page for navigation. |
| tests/e2e/signTransactionPage.test.ts | Switches navigation to relative URL. |
| tests/e2e/savedTransactions.test.ts | Switches navigation to relative URL (includes manual context usage). |
| tests/e2e/savedSmartContractIds.test.ts | Switches navigation to relative URL (includes manual context usage). |
| tests/e2e/savedRequests.test.ts | Switches navigation to relative URL (includes manual context usage). |
| tests/e2e/savedKeypairs.test.ts | Switches navigation to relative URL (includes manual context usage). |
| tests/e2e/parseMuxedAccountPage.test.ts | Switches navigation to relative URL. |
| tests/e2e/networkSelector.test.ts | Uses relative navigation for base page and BASE_URL for deep-link case. |
| tests/e2e/networkLimitsPage.test.ts | Uses BASE_URL for one deep-link and relative URL elsewhere. |
| tests/e2e/mock/localStorage.ts | Makes storageState origin/shareable URLs depend on process.env.PORT. |
| tests/e2e/introductionPage.test.ts | Switches navigation to relative URL (includes manual context usage). |
| tests/e2e/fundAccountPage.test.ts | Switches navigation to relative URLs. |
| tests/e2e/feeBumpPage.test.ts | Switches navigation to relative URL. |
| tests/e2e/endpointsPage.test.ts | Uses relative navigation for most pages and BASE_URL for some deep-links. |
| tests/e2e/diffXdrsPage.test.ts | Switches navigation to relative URL. |
| tests/e2e/createMuxedAccountPage.test.ts | Switches navigation to relative URL. |
| tests/e2e/createAccountPage.test.ts | Switches navigation to relative URL. |
| tests/e2e/buildTransaction.test.ts | Switches navigation to relative URL. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const browserContext = await browser.newContext({ | ||
| storageState: MOCK_LOCAL_STORAGE, | ||
| }); | ||
| pageContext = await browserContext.newPage(); | ||
| await pageContext.goto("http://localhost:3000/endpoints/saved"); | ||
| await pageContext.goto("/endpoints/saved"); | ||
|
|
There was a problem hiding this comment.
pageContext is created via browser.newContext() without a baseURL. Relative pageContext.goto("/endpoints/saved") will fail because there’s no base URL to resolve against. Provide baseURL in newContext or navigate to an absolute URL.
| const browserContext = await browser.newContext({ | ||
| storageState: MOCK_LOCAL_STORAGE, | ||
| }); | ||
| pageContext = await browserContext.newPage(); | ||
|
|
||
| await pageContext.goto("http://localhost:3000/smart-contracts/saved"); | ||
| await pageContext.goto("/smart-contracts/saved"); | ||
| }); |
There was a problem hiding this comment.
This page is created from a manually constructed context (browser.newContext). Without passing baseURL into that context, pageContext.goto("/smart-contracts/saved") won’t resolve and will fail. Set baseURL when creating the context or use an absolute URL here.
| const browserContext = await browser.newContext({ | ||
| storageState: MOCK_LOCAL_STORAGE, | ||
| }); | ||
| pageContext = await browserContext.newPage(); | ||
|
|
||
| await pageContext.goto("http://localhost:3000/account/saved"); | ||
| await pageContext.goto("/account/saved"); | ||
|
|
There was a problem hiding this comment.
pageContext is created via browser.newContext({ storageState }) without baseURL. Relative navigation (pageContext.goto("/account/saved")) relies on baseURL and will fail in this setup. Pass baseURL into newContext (preferred) or use an absolute URL.
| const BASE_URL = `http://localhost:${process.env.PORT || 3000}`; | ||
|
|
There was a problem hiding this comment.
This reintroduces a second “source of truth” for the test server URL (BASE_URL built from process.env.PORT). Since playwright.config.ts already sets use.baseURL, these navigations can use relative URLs (including query strings) to automatically respect whatever baseURL/webServer URL Playwright is using. Keeping a local BASE_URL risks drift if the config baseURL ever changes (host, protocol, etc.).
| const context = await browser.newContext(); | ||
| const page = await context.newPage(); | ||
| await page.goto("http://localhost:3000/"); | ||
| await page.goto("/"); | ||
|
|
There was a problem hiding this comment.
page.goto("/") only works when the page/context has a baseURL configured. Here the page is created via browser.newContext() (not the Playwright page fixture), so no baseURL is applied and this navigation will fail. Pass baseURL when creating the context (recommended) or navigate using an absolute URL derived from the same baseURL used in playwright.config.ts.
| const browserContext = await browser.newContext({ | ||
| storageState: MOCK_LOCAL_STORAGE, | ||
| }); | ||
| pageContext = await browserContext.newPage(); | ||
| await pageContext.goto("http://localhost:3000/transaction/saved"); | ||
| await pageContext.goto("/transaction/saved"); | ||
| }); |
There was a problem hiding this comment.
This pageContext comes from a manually created browser.newContext(). Relative navigation (pageContext.goto("/transaction/saved")) requires a context baseURL, which isn’t set here, so the test will fail. Set baseURL in browser.newContext({ ..., baseURL }) or use an absolute URL for this navigation.
|
Preview is available here: |
leighmcculloch
left a comment
There was a problem hiding this comment.
There's one comment from Copilot that's worth looking at; otherwise it looks good to me.
localhost:3000so that I can run multiple repos in parallel, make updates, and able to pass tests.