Skip to content

Commit

Permalink
test(deployment): extract env vars in config file
Browse files Browse the repository at this point in the history
  • Loading branch information
baktun14 committed Oct 1, 2024
1 parent 92c5067 commit 6d56e89
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
11 changes: 11 additions & 0 deletions apps/deploy-web/tests/fixture/test-env.config.ts
Original file line number Diff line number Diff line change
@@ -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
});
4 changes: 3 additions & 1 deletion apps/deploy-web/tests/fixture/wallet-setup.ts
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -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");
}
Expand Down
7 changes: 4 additions & 3 deletions apps/deploy-web/tests/pages/DeployBasePage.tsx
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 6d56e89

Please sign in to comment.