-
Notifications
You must be signed in to change notification settings - Fork 13
Add e2e tests for login, survey and dashboard #681
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
Open
Yasaman-Behnam-Malekzadeh
wants to merge
9
commits into
zenml-io:staging
Choose a base branch
from
Yasaman-Behnam-Malekzadeh:add-e2e-test
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6861c6a
Add e2e tests for login, survey and dashboard
Yasaman-Behnam-Malekzadeh bbfc98d
rename files alphabeticly
Yasaman-Behnam-Malekzadeh 3c7eb78
add pipeline for playwright tests
Yasaman-Behnam-Malekzadeh 4ae903e
edit ubuntu
Yasaman-Behnam-Malekzadeh 1dce813
feat: add pipeline fixture
Cahllagerfeld 4b44e73
merge two playwright files and change some steps in playwright file
Yasaman-Behnam-Malekzadeh 9771064
Trigger Build
Cahllagerfeld 5852aaa
chore: adjust trigger
Cahllagerfeld fa216ee
chore: reorder steps
Cahllagerfeld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,59 @@ | ||
name: Playwright Tests | ||
name : ZenML Playwright test pipelines | ||
|
||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
types: [opened, synchronize, ready_for_review] | ||
|
||
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 | ||
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 | ||
|
||
- 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: Verify ZenML Installation | ||
run: zenml version | ||
|
||
- 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 | ||
|
||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"]', "[email protected]"); | ||
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")'); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/); | ||
}); | ||
}); |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")'); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider using an assertion instead of an early return for the "Overview" link.
While checking for the "Overview" link visibility is a good practice, using an early return might lead to silently skipping important test assertions if the link is not visible.
Consider replacing the visibility check and early return with an assertion:
This change will make the test fail explicitly if the "Overview" link is not visible, providing clearer feedback about the application's state.