Skip to content
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

test(deployment): e2e testing create deployment #392

Merged
merged 10 commits into from
Oct 4, 2024
11 changes: 11 additions & 0 deletions apps/deploy-web/tests/fixture/test-env.config.ts
baktun14 marked this conversation as resolved.
Show resolved Hide resolved
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({
baktun14 marked this conversation as resolved.
Show resolved Hide resolved
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) {
baktun14 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading