-
Notifications
You must be signed in to change notification settings - Fork 5.1k
feat(test): Migrate Common.robot to Playwright #22630
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
base: main
Are you sure you want to change the base?
Changes from all commits
9c1f9b2
546bdb4
1e8b05e
1317cb6
490f414
d113454
1d0a09d
ce73295
01d7ac0
1ed0161
c3e9544
708893d
bc913a0
546d254
b91cea5
60cc463
964bdf7
c2abc3f
b2bdaa6
fb41beb
d4a900b
b2eff68
73d9b6c
99c3e88
d7bd80f
80b6df4
d1c58fb
46f96b6
c96fc01
a672e95
16061d9
c63869a
39676b7
d958b89
d579c63
b91f1a0
e6d6b88
20d2975
4a20920
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,91 @@ | ||||||||
| name: Playwright Tests | ||||||||
|
|
||||||||
| env: | ||||||||
| POSTGRESQL_HOST: localhost | ||||||||
| POSTGRESQL_PORT: 5432 | ||||||||
| POSTGRESQL_USR: postgres | ||||||||
| POSTGRESQL_PWD: root123 | ||||||||
| POSTGRESQL_DATABASE: registry | ||||||||
| DOCKER_COMPOSE_VERSION: 2.27.1 | ||||||||
| HARBOR_ADMIN: admin | ||||||||
| HARBOR_ADMIN_PASSWD: Harbor12345 | ||||||||
| CORE_SECRET: tempString | ||||||||
| KEY_PATH: "/data/secret/keys/secretkey" | ||||||||
| REDIS_HOST: localhost | ||||||||
| REG_VERSION: v2.7.1-patch-2819-2553 | ||||||||
| UI_BUILDER_VERSION: 1.6.0 | ||||||||
|
|
||||||||
| on: | ||||||||
| pull_request: | ||||||||
| branches: [ main ] | ||||||||
| paths-ignore: | ||||||||
| - 'docs/**' | ||||||||
| - '**.md' | ||||||||
| - 'tests/**' | ||||||||
| - '!tests/**.sh' | ||||||||
| - '!tests/apitests/**' | ||||||||
| - '!tests/ci/**' | ||||||||
| - '!tests/resources/**' | ||||||||
| - '!tests/robot-cases/**' | ||||||||
| - '!tests/robot-cases/Group1-Nightly/**' | ||||||||
|
|
||||||||
| permissions: | ||||||||
| contents: read | ||||||||
| pull-requests: read | ||||||||
| actions: read | ||||||||
|
|
||||||||
| jobs: | ||||||||
| E2E_PLAYWRIGHT: | ||||||||
| runs-on: ubuntu-latest | ||||||||
| timeout-minutes: 120 | ||||||||
| steps: | ||||||||
| - name: Set up Go 1.23 | ||||||||
| uses: actions/setup-go@v5 | ||||||||
| with: | ||||||||
| go-version: 1.23.2 | ||||||||
| - uses: actions/setup-node@v5 | ||||||||
| with: | ||||||||
| node-version: '18' | ||||||||
| - uses: actions/checkout@v5 | ||||||||
| with: | ||||||||
| path: src/github.com/goharbor/harbor | ||||||||
| - name: setup env | ||||||||
| run: | | ||||||||
| cd src/github.com/goharbor/harbor | ||||||||
| pwd | ||||||||
| go env | ||||||||
| echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV | ||||||||
| echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV | ||||||||
| echo "$(go env GOPATH)/bin" >> $GITHUB_PATH | ||||||||
| echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV | ||||||||
| IP=`hostname -I | awk '{print $1}'` | ||||||||
| echo "IP=$IP" >> $GITHUB_ENV | ||||||||
| echo "BASE_URL=https://$IP" >> $GITHUB_ENV | ||||||||
|
||||||||
| echo "BASE_URL=https://$IP" >> $GITHUB_ENV | |
| echo "BASE_URL=https://$IP" >> $GITHUB_ENV | |
| echo "HARBOR_BASE_URL=https://$IP" >> $GITHUB_ENV |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,3 @@ | ||||||||||||
| HARBOR_USERNAME="<your_admin_username>" # e.g., admin | ||||||||||||
| HARBOR_PASSWORD="<your_admin_password>" # e.g., Harbor12345 | ||||||||||||
| HARBOR_BASE_URL="<your_harbor_instance_url>" # e.g., https://harbor.mycompany.com | ||||||||||||
|
||||||||||||
| HARBOR_BASE_URL="<your_harbor_instance_url>" # e.g., https://harbor.mycompany.com | |
| HARBOR_BASE_URL="<your_harbor_instance_url>" # e.g., https://harbor.mycompany.com | |
| LOCAL_REGISTRY="docker.io" # e.g., docker.io for the default Docker Hub registry | |
| LOCAL_REGISTRY_NAMESPACE="library" # e.g., library for official Docker Hub images |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
|
|
||
| # Playwright | ||
| node_modules/ | ||
| /test-results/ | ||
| /playwright-report/ | ||
| /blob-report/ | ||
| /playwright/.cache/ | ||
|
|
||
| # Files | ||
| .env |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,57 @@ | ||||||||||||||||||||||||||||||||
| import { test as base, Page } from '@playwright/test'; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| type HarborUser = { | ||||||||||||||||||||||||||||||||
| username: string; | ||||||||||||||||||||||||||||||||
| password: string; | ||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| type HarborFixtures = { | ||||||||||||||||||||||||||||||||
| harborPage: Page; | ||||||||||||||||||||||||||||||||
| harborUser: HarborUser; | ||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export async function login(page: Page, baseURL: string | undefined, creds: HarborUser) { | ||||||||||||||||||||||||||||||||
| await page.goto(baseURL); | ||||||||||||||||||||||||||||||||
| await page.getByRole('textbox', { name: 'Username' }).fill(creds.username); | ||||||||||||||||||||||||||||||||
| await page.getByRole('textbox', { name: 'Password' }).fill(creds.password); | ||||||||||||||||||||||||||||||||
| await page.getByRole('button', { name: 'LOG IN' }).click(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export async function logout(page: Page, username: string) { | ||||||||||||||||||||||||||||||||
| await page.getByRole('button', { name: username, exact: true }).waitFor({ state: 'visible', timeout: 5000 }); | ||||||||||||||||||||||||||||||||
| await page.getByRole('button', { name: username, exact: true }).click(); | ||||||||||||||||||||||||||||||||
| await page.getByRole('menuitem', { name: 'Log Out' }).click(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export async function logoutIfPossible(page: Page, username: string) { | ||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||
| await page.getByRole('button', { name: username, exact: true }).waitFor({ state: 'visible', timeout: 2000 }); | ||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||
| await logout(page, username); | ||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| const harborTest = base.extend<HarborFixtures>({ | ||||||||||||||||||||||||||||||||
| harborUser: async ({}, use) => { | ||||||||||||||||||||||||||||||||
| await use({ | ||||||||||||||||||||||||||||||||
| username: process.env.HARBOR_USERNAME || 'admin', | ||||||||||||||||||||||||||||||||
| password: process.env.HARBOR_PASSWORD || 'Harbor12345', | ||||||||||||||||||||||||||||||||
|
Comment on lines
+40
to
+44
|
||||||||||||||||||||||||||||||||
| const harborTest = base.extend<HarborFixtures>({ | |
| harborUser: async ({}, use) => { | |
| await use({ | |
| username: process.env.HARBOR_USERNAME || 'admin', | |
| password: process.env.HARBOR_PASSWORD || 'Harbor12345', | |
| const harborPassword = | |
| process.env.HARBOR_TEST_USER_PASSWORD || | |
| process.env.HARBOR_PASSWORD || | |
| ''; | |
| const harborTest = base.extend<HarborFixtures>({ | |
| harborUser: async ({}, use) => { | |
| await use({ | |
| username: process.env.HARBOR_USERNAME || 'admin', | |
| password: harborPassword, |
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.
This workflow uses
actions/checkout@v5, while all other GitHub Actions workflows in this repository consistently useactions/checkout@v6(e.g.,.github/workflows/CI.yml,.github/workflows/build-package.yml,.github/workflows/codeql-analysis.yml). The checkout action version should be updated to@v6to be consistent with the rest of the codebase.