Skip to content

Commit

Permalink
test(deployment): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
baktun14 committed Oct 4, 2024
1 parent 6d56e89 commit 27fc8b7
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 28 deletions.
4 changes: 2 additions & 2 deletions apps/deploy-web/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { defineConfig, devices } from "@playwright/test";
import dotenv from 'dotenv';
import dotenv from "dotenv";
import path from "path";

dotenv.config({ path: path.resolve(__dirname, 'env/.env.test') });
dotenv.config({ path: path.resolve(__dirname, "env/.env.test") });

/**
* See https://playwright.dev/docs/test-configuration.
Expand Down
10 changes: 2 additions & 8 deletions apps/deploy-web/tests/deploy-custom-template.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ import { expect, test } from "@playwright/test";
import { SSH_VM_IMAGES } from "@src/utils/sdl/data";
import { DeployCustomTemplatePage } from "./pages/DeployCustomTemplatePage";

test("ssh keys generation", async ({ page, context }) => {
test("create custom template deployment", async ({ page, context }) => {
const customTemplatePage = new DeployCustomTemplatePage(context, page, "new-deployment", "build-template-card");
await customTemplatePage.gotoInteractive();
await customTemplatePage.fillImageName(SSH_VM_IMAGES["Ubuntu 24.04"]);
await customTemplatePage.toggleSsh();

const { input, download } = await customTemplatePage.generateSSHKeys();

expect(download.suggestedFilename()).toBe("keypair.zip");
await expect(input).toHaveValue(/ssh-/);

await customTemplatePage.createDeployment();
await page.getByTestId("create-deployment-btn").click();

await expect(customTemplatePage.page.getByTestId("connect-wallet-btn").first()).toBeVisible();
});
11 changes: 5 additions & 6 deletions apps/deploy-web/tests/deploy-hello-world.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import { DeployHelloWorldPage } from "./pages/DeployHelloWorldPage";
test("deploy hello world", async ({ extPage: page, context }) => {
await setupLeap(context, page);

const customTemplatePage = new DeployHelloWorldPage(context, page, "new-deployment", "hello-world-card");
const helloWorldPage = new DeployHelloWorldPage(context, page, "new-deployment", "hello-world-card");

await customTemplatePage.createDeployment();
await customTemplatePage.createLease();
await customTemplatePage.validateLeaseAndClose();

await page.pause();
await helloWorldPage.gotoInteractive(true);
await helloWorldPage.createDeploymentAndSign();
await helloWorldPage.createLeaseAndSign();
await helloWorldPage.validateLeaseAndClose();
});
2 changes: 1 addition & 1 deletion apps/deploy-web/tests/deploy-linux.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test("ssh keys generation", async ({ page, context }) => {
expect(download.suggestedFilename()).toBe("keypair.zip");
await expect(input).toHaveValue(/ssh-/);

await plainLinuxPage.createDeployment();
await page.getByTestId("create-deployment-btn").click();

await expect(plainLinuxPage.page.getByTestId("connect-wallet-btn").first()).toBeVisible();
});
7 changes: 4 additions & 3 deletions apps/deploy-web/tests/fixture/fixture.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { test as base, BrowserContext, chromium, selectors, Page } from "@playwright/test";
import path from "path";
import { BrowserContext, chromium, Page, test as base } from "@playwright/test";
import { nanoid } from "nanoid";
import path from "path";

export const test = base.extend<{
context: BrowserContext;
extensionId: string;
extPage: Page;
}>({
// eslint-disable-next-line no-empty-pattern
context: async ({}, use) => {
console.log("context");
const pathToExtension = path.join(__dirname, "Leap");
Expand Down Expand Up @@ -40,7 +41,7 @@ export const test = base.extend<{
context.route;
},
extPage: [
async ({ context }, use, workerInfo) => {
async ({ context }, use) => {
const pageList = context.pages();
if (pageList && pageList.length > 1) {
const extensionPage = pageList.filter(page => page.url().includes("extension")) || [];
Expand Down
2 changes: 1 addition & 1 deletion apps/deploy-web/tests/pages/DeployBasePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class DeployBasePage {

async gotoInteractive(skipInit?: boolean) {
if (this.cardTestId) {
if (skipInit) {
if (!skipInit) {
await this.page.goto(testEnvConfig.BASE_URL);
await this.page.getByTestId("welcome-modal-accept-button").click();
}
Expand Down
4 changes: 0 additions & 4 deletions apps/deploy-web/tests/pages/DeployCustomTemplatePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ export class DeployCustomTemplatePage extends DeployBasePage {
async fillImageName(name: string) {
await this.page.getByTestId("image-name-input").fill(name);
}

async toggleSsh() {
await this.page.getByTestId("ssh-toggle").check();
}
}
5 changes: 2 additions & 3 deletions apps/deploy-web/tests/pages/DeployHelloWorldPage.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { DeployBasePage } from "./DeployBasePage";

export class DeployHelloWorldPage extends DeployBasePage {
async createDeployment() {
await this.gotoInteractive(true);
async createDeploymentAndSign() {
await this.createDeployment();
await this.signTransaction();
}

async createLease() {
async createLeaseAndSign() {
await this.createLease();
await this.signTransaction();
}
Expand Down

0 comments on commit 27fc8b7

Please sign in to comment.