From 6861c6a2a827414a3cc5bf75459c4eed51c514cf Mon Sep 17 00:00:00 2001 From: Yasaman-Behnam-Malekzadeh Date: Wed, 16 Oct 2024 11:06:45 +0200 Subject: [PATCH 1/9] Add e2e tests for login, survey and dashboard --- e2e-tests/dashboard.spec.ts | 32 ++++++++++++++++++++++++++ e2e-tests/login.spec.ts | 8 +++++++ e2e-tests/survey.spec.ts | 45 +++++++++++++++++++++++++++++++++++++ e2e-tests/utils.ts | 10 +++++++++ 4 files changed, 95 insertions(+) create mode 100644 e2e-tests/dashboard.spec.ts create mode 100644 e2e-tests/login.spec.ts create mode 100644 e2e-tests/survey.spec.ts create mode 100644 e2e-tests/utils.ts diff --git a/e2e-tests/dashboard.spec.ts b/e2e-tests/dashboard.spec.ts new file mode 100644 index 000000000..52186a6f7 --- /dev/null +++ b/e2e-tests/dashboard.spec.ts @@ -0,0 +1,32 @@ +import { test, expect } from "@playwright/test"; +import { login } from "./utils"; + +test.describe("Dashboard", () => { + test("Check dashboard and Navbar", async ({ page }) => { + await login(page); + + const overviewLink = await page.locator('a:has-text("Overview")').isVisible(); + + if (!overviewLink) { + return; + } + //Visible the navbar + await expect(page.locator('a:has-text("Pipelines")')).toBeVisible(); + await expect(page.locator('a:has-text("Models")')).toBeVisible(); + await expect(page.locator('a:has-text("Artifacts")')).toBeVisible(); + await expect(page.locator('a:has-text("Stacks")')).toBeVisible(); + + //Change the URL by clicking each nav item + await page.click('a:has-text("Pipelines")'); + await expect(page).toHaveURL(/\/pipelines\?tab=pipelines/); + + await page.click('a:has-text("Models")'); + await expect(page).toHaveURL(/\/models/); + + await page.click('a:has-text("Artifacts")'); + await expect(page).toHaveURL(/\/artifacts/); + + await page.click('a:has-text("Stacks")'); + await expect(page).toHaveURL(/\/stacks/); + }); +}); diff --git a/e2e-tests/login.spec.ts b/e2e-tests/login.spec.ts new file mode 100644 index 000000000..e9bb6f275 --- /dev/null +++ b/e2e-tests/login.spec.ts @@ -0,0 +1,8 @@ +import { test } from "@playwright/test"; +import { login } from "./utils"; + +test.describe("Login", () => { + test("Login with default username", async ({ page }) => { + await login(page); + }); +}); diff --git a/e2e-tests/survey.spec.ts b/e2e-tests/survey.spec.ts new file mode 100644 index 000000000..c79918151 --- /dev/null +++ b/e2e-tests/survey.spec.ts @@ -0,0 +1,45 @@ +import { test } from "@playwright/test"; +import { login } from "./utils"; + +test.describe("Survey", () => { + test("Fill survey for first time", async ({ page }) => { + await login(page); + + const isVisible = await page.locator("text=Add your account details").isVisible(); + + if (!isVisible) { + return; + } + + //survey form - Step 1 + await page.fill('input[name="fullName"]', "test"); + await page.fill('input[name="email"]', "test@test.com"); + await page + .getByLabel("I want to receive news and recommendations about how to use ZenML") + .check(); + await page.click('button span:has-text("Continue")'); + await page.waitForSelector("text=What will be your primary use for ZenML?"); + + //survey form - Step 2 + await page.click('div label:has-text("Personal")'); + await page.click('button span:has-text("Continue")'); + await page.waitForSelector("text=What best describes your current situation with ZenML?"); + + //survey form - Step 3 + await page.check('label:has-text("I\'m new to MLOps and exploring")'); + await page.click('button span:has-text("Continue")'); + await page.waitForSelector("text=What is your current infrastructure?"); + + //survey form - Step 4 + await page.check('label:has-text("GCP") button'); + await page.check('label:has-text("Azure")'); + await page.check('label:has-text("Openshift")'); + await page.check('label:has-text("AWS")'); + await page.check('label:has-text("Native Kubernetes")'); + await page.click('button span:has-text("Continue")'); + await page.waitForSelector("text=Join The ZenML Slack Community"); + + //survey form - Step 5 + await page.click('button span:has-text("Skip")'); + }); +}); diff --git a/e2e-tests/utils.ts b/e2e-tests/utils.ts new file mode 100644 index 000000000..d56a07400 --- /dev/null +++ b/e2e-tests/utils.ts @@ -0,0 +1,10 @@ +import { Page, expect } from "@playwright/test"; + +// reusable login function +export async function login(page: Page) { + await page.goto("http://127.0.0.1:8237/"); + await expect(page.locator('h1:has-text("Log in to your account")')).toBeVisible(); + await page.fill('input[name="username"]', "default"); + await page.fill('input[name="password"]', ""); + await page.click('button span:has-text("Login")'); +} From bbfc98d9f3c2d39fc54ca468f8ad9b5c86f0b07b Mon Sep 17 00:00:00 2001 From: Yasaman-Behnam-Malekzadeh Date: Fri, 18 Oct 2024 19:01:30 +0200 Subject: [PATCH 2/9] rename files alphabeticly --- e2e-tests/{survey.spec.ts => 00-survey.spec.ts} | 0 e2e-tests/{login.spec.ts => 01-login.spec.ts} | 0 e2e-tests/{dashboard.spec.ts => 02-dashboard.spec.ts} | 0 e2e-tests/{example.spec.ts => 03-example.spec.ts} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename e2e-tests/{survey.spec.ts => 00-survey.spec.ts} (100%) rename e2e-tests/{login.spec.ts => 01-login.spec.ts} (100%) rename e2e-tests/{dashboard.spec.ts => 02-dashboard.spec.ts} (100%) rename e2e-tests/{example.spec.ts => 03-example.spec.ts} (100%) diff --git a/e2e-tests/survey.spec.ts b/e2e-tests/00-survey.spec.ts similarity index 100% rename from e2e-tests/survey.spec.ts rename to e2e-tests/00-survey.spec.ts diff --git a/e2e-tests/login.spec.ts b/e2e-tests/01-login.spec.ts similarity index 100% rename from e2e-tests/login.spec.ts rename to e2e-tests/01-login.spec.ts diff --git a/e2e-tests/dashboard.spec.ts b/e2e-tests/02-dashboard.spec.ts similarity index 100% rename from e2e-tests/dashboard.spec.ts rename to e2e-tests/02-dashboard.spec.ts diff --git a/e2e-tests/example.spec.ts b/e2e-tests/03-example.spec.ts similarity index 100% rename from e2e-tests/example.spec.ts rename to e2e-tests/03-example.spec.ts From 3c7eb78f897f1c008467d3883bbbb549d2733d5c Mon Sep 17 00:00:00 2001 From: Yasaman-Behnam-Malekzadeh Date: Mon, 21 Oct 2024 12:23:27 +0200 Subject: [PATCH 3/9] add pipeline for playwright tests --- .github/workflows/playwright-pipeline.yml | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/playwright-pipeline.yml diff --git a/.github/workflows/playwright-pipeline.yml b/.github/workflows/playwright-pipeline.yml new file mode 100644 index 000000000..8530ffb03 --- /dev/null +++ b/.github/workflows/playwright-pipeline.yml @@ -0,0 +1,39 @@ +name : ZenML Playwright test pipelines + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + run_zenml_tests: + runs-on: ubunto-latest + + steps: + - name: checkout repository + uses: actions/checkout@v3 + + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: "3.12" + + - name: Install ZenML + run: | + pip install --upgrade pip + pip install zenml + + - name: ZenMl up + run: | + zenml init + zenml up + + - name: Run Playwright Tests + run: npx playwright test --workers=1 + + - name: Verify ZenML Installation + run: zenml version + From 4ae903e474504256464be8b76fca892ac122dd02 Mon Sep 17 00:00:00 2001 From: Yasaman-Behnam-Malekzadeh Date: Mon, 21 Oct 2024 12:27:40 +0200 Subject: [PATCH 4/9] edit ubuntu --- .github/workflows/playwright-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright-pipeline.yml b/.github/workflows/playwright-pipeline.yml index 8530ffb03..96b85d2d4 100644 --- a/.github/workflows/playwright-pipeline.yml +++ b/.github/workflows/playwright-pipeline.yml @@ -10,7 +10,7 @@ on: jobs: run_zenml_tests: - runs-on: ubunto-latest + runs-on: ubuntu-latest steps: - name: checkout repository From 1dce813bf43d432415343569d3e4d0360c84fc2d Mon Sep 17 00:00:00 2001 From: Cahllagerfeld <43843195+Cahllagerfeld@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:14:28 +0000 Subject: [PATCH 5/9] feat: add pipeline fixture --- .github/workflows/playwright-pipeline.yml | 2 ++ e2e-tests/fixtures/simple-pipeline.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 e2e-tests/fixtures/simple-pipeline.py diff --git a/.github/workflows/playwright-pipeline.yml b/.github/workflows/playwright-pipeline.yml index 96b85d2d4..a26f24d6d 100644 --- a/.github/workflows/playwright-pipeline.yml +++ b/.github/workflows/playwright-pipeline.yml @@ -4,9 +4,11 @@ on: push: branches: - main + - staging pull_request: branches: - main + - staging jobs: run_zenml_tests: diff --git a/e2e-tests/fixtures/simple-pipeline.py b/e2e-tests/fixtures/simple-pipeline.py new file mode 100644 index 000000000..e89f109ee --- /dev/null +++ b/e2e-tests/fixtures/simple-pipeline.py @@ -0,0 +1,22 @@ +from typing import Annotated, Tuple +from zenml import pipeline, step + + +@step +def step_1() -> Tuple[int, Annotated[int, "custom_artifact_name"]]: + return 0, 1 + + +@step +def step_2(input_0: int) -> None: + pass + + +@pipeline(enable_cache=False) +def ui_test_pipeline(): + output_0, _ = step_1() + step_2(output_0) + + +if __name__ == "__main__": + ui_test_pipeline() From 4b44e73129d0e1421e54049d05f52ec034fee554 Mon Sep 17 00:00:00 2001 From: Yasaman-Behnam-Malekzadeh Date: Wed, 23 Oct 2024 17:48:19 +0200 Subject: [PATCH 6/9] merge two playwright files and change some steps in playwright file --- .github/workflows/playwright-pipeline.yml | 41 -------------------- .github/workflows/playwright.yml | 46 ++++++++++++++++++++--- 2 files changed, 40 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/playwright-pipeline.yml diff --git a/.github/workflows/playwright-pipeline.yml b/.github/workflows/playwright-pipeline.yml deleted file mode 100644 index a26f24d6d..000000000 --- a/.github/workflows/playwright-pipeline.yml +++ /dev/null @@ -1,41 +0,0 @@ -name : ZenML Playwright test pipelines - -on: - push: - branches: - - main - - staging - pull_request: - branches: - - main - - staging - -jobs: - run_zenml_tests: - runs-on: ubuntu-latest - - steps: - - name: checkout repository - uses: actions/checkout@v3 - - - name: Set up Python 3.12 - uses: actions/setup-python@v4 - with: - python-version: "3.12" - - - name: Install ZenML - run: | - pip install --upgrade pip - pip install zenml - - - name: ZenMl up - run: | - zenml init - zenml up - - - name: Run Playwright Tests - run: npx playwright test --workers=1 - - - name: Verify ZenML Installation - run: zenml version - diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index ba18c2b59..1b148d3b8 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,13 +1,22 @@ -name: Playwright Tests -on: +name : ZenML Playwright test pipelines + +on: push: - branches: [main, master] + branches: + - main + - staging pull_request: - branches: [main, master] + branches: + - main + - staging + jobs: - test: - timeout-minutes: 60 + run_zenml_tests: runs-on: ubuntu-latest + + env: + ZENML_ANALYTICS_OPT_IN: "false" + steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -25,3 +34,28 @@ jobs: name: playwright-report path: playwright-report/ retention-days: 30 + + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: "3.12" + + - name: Install ZenML + run: | + pip install --upgrade pip + pip install zenml[server] + + - name: Run ZenML Simple Pipeline + run: python e2e-tests/fixtures/simple-pipeline.py + + - name: ZenMl up + run: | + zenml init + zenml up + + - name: Run Playwright Tests + working-directory: e2e-tests + run: npx playwright test --workers=1 + + - name: Verify ZenML Installation + run: zenml version \ No newline at end of file From 97710642b37225f169cb5a9d616cdcd88c96dc80 Mon Sep 17 00:00:00 2001 From: Cahllagerfeld <43843195+Cahllagerfeld@users.noreply.github.com> Date: Thu, 24 Oct 2024 08:42:33 +0000 Subject: [PATCH 7/9] Trigger Build From 5852aaa13d69b93c50287d0ad5ae04024c0c0f5a Mon Sep 17 00:00:00 2001 From: Cahllagerfeld <43843195+Cahllagerfeld@users.noreply.github.com> Date: Thu, 24 Oct 2024 08:45:43 +0000 Subject: [PATCH 8/9] chore: adjust trigger --- .github/workflows/playwright.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 1b148d3b8..8641528f4 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,15 +1,9 @@ name : ZenML Playwright test pipelines -on: - push: - branches: - - main - - staging +on: pull_request: - branches: - - main - - staging - + types: [opened, synchronize, ready_for_review] + jobs: run_zenml_tests: runs-on: ubuntu-latest @@ -58,4 +52,4 @@ jobs: run: npx playwright test --workers=1 - name: Verify ZenML Installation - run: zenml version \ No newline at end of file + run: zenml version From fa216ee989da97a12d5170973a8e3eaf4994a7c6 Mon Sep 17 00:00:00 2001 From: Cahllagerfeld <43843195+Cahllagerfeld@users.noreply.github.com> Date: Thu, 24 Oct 2024 08:49:49 +0000 Subject: [PATCH 9/9] chore: reorder steps --- .github/workflows/playwright.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 8641528f4..5b1650aa1 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -3,7 +3,7 @@ name : ZenML Playwright test pipelines on: pull_request: types: [opened, synchronize, ready_for_review] - + jobs: run_zenml_tests: runs-on: ubuntu-latest @@ -13,21 +13,16 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: lts/* + - name: Install dependencies run: npm install -g pnpm && pnpm install + - name: Install Playwright Browsers run: pnpm exec playwright install --with-deps - - name: Run Playwright tests - run: pnpm exec playwright test - - uses: actions/upload-artifact@v4 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 - name: Set up Python 3.12 uses: actions/setup-python@v4 @@ -39,6 +34,9 @@ jobs: pip install --upgrade pip pip install zenml[server] + - name: Verify ZenML Installation + run: zenml version + - name: Run ZenML Simple Pipeline run: python e2e-tests/fixtures/simple-pipeline.py @@ -50,6 +48,12 @@ jobs: - name: Run Playwright Tests working-directory: e2e-tests run: npx playwright test --workers=1 + + - uses: actions/upload-artifact@v4 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 - - name: Verify ZenML Installation - run: zenml version +