diff --git a/apps/deploy-web/tests/fixture/test-env.config.ts b/apps/deploy-web/tests/fixture/test-env.config.ts new file mode 100644 index 000000000..24e337eba --- /dev/null +++ b/apps/deploy-web/tests/fixture/test-env.config.ts @@ -0,0 +1,11 @@ +import { z } from "zod"; + +export const testEnvSchema = z.object({ + BASE_URL: z.string().default("http://localhost:3000"), + TEST_WALLET_MNEMONIC: z.string() +}); + +export const testEnvConfig = testEnvSchema.parse({ + BASE_URL: process.env.BASE_URL, + TEST_WALLET_MNEMONIC: process.env.TEST_WALLET_MNEMONIC +}); diff --git a/apps/deploy-web/tests/fixture/wallet-setup.ts b/apps/deploy-web/tests/fixture/wallet-setup.ts index 2b5d82561..687fc92ad 100644 --- a/apps/deploy-web/tests/fixture/wallet-setup.ts +++ b/apps/deploy-web/tests/fixture/wallet-setup.ts @@ -1,5 +1,7 @@ import { type BrowserContext, type Page, selectors } from "@playwright/test"; +import { testEnvConfig } from "./test-env.config"; + const WALLET_PASSWORD = "12345678"; export const setupLeap = async (context: BrowserContext, page: Page) => { @@ -8,7 +10,7 @@ export const setupLeap = async (context: BrowserContext, page: Page) => { await page.getByTestId("import-seed-phrase").click(); - const mnemonic = process.env.TEST_WALLET_MNEMONIC; + const mnemonic = testEnvConfig.TEST_WALLET_MNEMONIC; if (!mnemonic) { throw new Error("TEST_WALLET_MNEMONIC is not set"); } diff --git a/apps/deploy-web/tests/pages/DeployBasePage.tsx b/apps/deploy-web/tests/pages/DeployBasePage.tsx index 927eaee9f..50b230d0f 100644 --- a/apps/deploy-web/tests/pages/DeployBasePage.tsx +++ b/apps/deploy-web/tests/pages/DeployBasePage.tsx @@ -1,4 +1,5 @@ import { type BrowserContext as Context, expect, type Page } from "@playwright/test"; +import { testEnvConfig } from "tests/fixture/test-env.config"; export class DeployBasePage { constructor( @@ -9,13 +10,13 @@ export class DeployBasePage { ) {} async goto() { - await this.page.goto(`http://localhost:3000/${this.path}`); + await this.page.goto(`${testEnvConfig.BASE_URL}/${this.path}`); } async gotoInteractive(skipInit?: boolean) { if (this.cardTestId) { if (skipInit) { - await this.page.goto("http://localhost:3000"); + await this.page.goto(testEnvConfig.BASE_URL); await this.page.getByTestId("welcome-modal-accept-button").click(); } await this.page.getByTestId("sidebar-deploy-button").first().click(); @@ -45,7 +46,7 @@ export class DeployBasePage { } async validateLease() { - await this.page.waitForURL(/http:\/\/localhost:3000\/deployments\/\d+/); + await this.page.waitForURL(new RegExp(`${testEnvConfig.BASE_URL}/deployments/\\d+`)); await expect(this.page.getByText("SuccessfulCreate", { exact: true })).toBeVisible({ timeout: 10000 }); await this.page.getByTestId("deployment-tab-leases").click(); await this.page.getByTestId("lease-list-row-0").isVisible();