Skip to content

Commit

Permalink
test(deployment): refactor test classes
Browse files Browse the repository at this point in the history
  • Loading branch information
baktun14 committed Oct 1, 2024
1 parent 3944519 commit 92c5067
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 25 deletions.
4 changes: 2 additions & 2 deletions apps/deploy-web/tests/build-template.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { expect, test } from "@playwright/test";

import { BuildTemplatePage } from "./pages/BuildTemplatePage";

test("ssh function absence", async ({ page }) => {
const plainLinuxPage = new BuildTemplatePage(page, "sdl-builder");
test("ssh function absence", async ({ page, context }) => {
const plainLinuxPage = new BuildTemplatePage(context, page, "sdl-builder");
await plainLinuxPage.gotoInteractive();

await expect(page.getByTestId("generate-ssh-keys-btn")).not.toBeVisible();
Expand Down
4 changes: 2 additions & 2 deletions apps/deploy-web/tests/deploy-custom-template.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ 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 }) => {
const customTemplatePage = new DeployCustomTemplatePage(page, "new-deployment", "build-template-card");
test("ssh keys generation", 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();
Expand Down
16 changes: 2 additions & 14 deletions apps/deploy-web/tests/deploy-hello-world.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,14 @@ import { test } from "./fixture/fixture";
import { setupLeap } from "./fixture/wallet-setup";
import { DeployHelloWorldPage } from "./pages/DeployHelloWorldPage";

// test.describe.configure({ mode: "serial" });

test("deploy hello world", async ({ extPage: page, context }) => {
await setupLeap(context, page);

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

// Create deployment
await customTemplatePage.gotoInteractive();
await customTemplatePage.createDeployment();
await customTemplatePage.signTransaction();

// Create lease
await customTemplatePage.createLease();
await customTemplatePage.signTransaction();

// Validate lease and close
await customTemplatePage.validateLease();
await customTemplatePage.closeDeploymentDetail();
await customTemplatePage.signTransaction();
await customTemplatePage.createLease();
await customTemplatePage.validateLeaseAndClose();

await page.pause();
});
4 changes: 2 additions & 2 deletions apps/deploy-web/tests/deploy-linux.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { expect, test } from "@playwright/test";

import { PlainLinuxPage } from "./pages/PlainLinuxPage";

test("ssh keys generation", async ({ page }) => {
const plainLinuxPage = new PlainLinuxPage(page, "deploy-linux", "plain-linux-card");
test("ssh keys generation", async ({ page, context }) => {
const plainLinuxPage = new PlainLinuxPage(context, page, "deploy-linux", "plain-linux-card");
await plainLinuxPage.gotoInteractive();
await plainLinuxPage.selectDistro("Ubuntu 24.04");

Expand Down
8 changes: 5 additions & 3 deletions apps/deploy-web/tests/pages/DeployBasePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ export class DeployBasePage {
await this.page.goto(`http://localhost:3000/${this.path}`);
}

async gotoInteractive() {
async gotoInteractive(skipInit?: boolean) {
if (this.cardTestId) {
// await this.page.goto("http://localhost:3000");
// await this.page.getByTestId("welcome-modal-accept-button").click();
if (skipInit) {
await this.page.goto("http://localhost:3000");
await this.page.getByTestId("welcome-modal-accept-button").click();
}
await this.page.getByTestId("sidebar-deploy-button").first().click();
await this.page.getByTestId(this.cardTestId).click();
}
Expand Down
17 changes: 15 additions & 2 deletions apps/deploy-web/tests/pages/DeployHelloWorldPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import { DeployBasePage } from "./DeployBasePage";

export class DeployHelloWorldPage extends DeployBasePage {
async fillImageName(name: string) {
await this.page.getByTestId("image-name-input").fill(name);
async createDeployment() {
await this.gotoInteractive(true);
await this.createDeployment();
await this.signTransaction();
}

async createLease() {
await this.createLease();
await this.signTransaction();
}

async validateLeaseAndClose() {
await this.validateLease();
await this.closeDeploymentDetail();
await this.signTransaction();
}
}

0 comments on commit 92c5067

Please sign in to comment.