Skip to content
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

playwright: initial setup of playwright for UI #16419

Merged
merged 15 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 152 additions & 2 deletions .github/workflows/playwright-mysql-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,155 @@ jobs:
runs-on: ubuntu-latest
environment: test
steps:
- name: Test
run: echo "Test"
- name: Set Playwright Project Environment variable
id: playwright-project-id
run: |
echo "CYPRESS_PROJECT_ID=${{ secrets.CYPRESS_PR_PROJECT_ID }}" >> $GITHUB_OUTPUT
echo "CYPRESS_RECORD_KEY=${{ secrets.CYPRESS_PR_RECORD_KEY }}" >> $GITHUB_OUTPUT
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this?

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
swap-storage: true
docker-images: false
- name: Wait for the labeler
uses: lewagon/[email protected]
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
check-name: Team Label
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 90

- name: Verify PR labels
uses: jesusvasquez333/[email protected]
if: ${{ github.event_name == 'pull_request_target' }}
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
valid-labels: "safe to test"
pull-request-number: "${{ github.event.pull_request.number }}"
disable-reviews: true # To not auto approve changes

- name: Checkout
uses: actions/checkout@v4

- name: Cache Maven Dependencies
id: cache-output
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Get yarn cache directory path
if: steps.cache-output.outputs.exit-code == 0
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
if: steps.yarn-cache-dir-path.outputs.exit-code == 0
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Set up JDK 17
if: steps.cache-output.outputs.exit-code == 0
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "temurin"

- name: Generating Data Models
run: |
pip install --upgrade pip
sudo make install_antlr_cli
make install_dev generate

- name: Start Server and Ingest Sample Data
env:
INGESTION_DEPENDENCY: "all"
run: ./docker/run_local_docker.sh -d mysql
timeout-minutes: 60

- name: Install dependencies
working-directory: openmetadata-ui/src/main/resources/ui/
run: yarn --frozen-lockfile
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
working-directory: openmetadata-ui/src/main/resources/ui/
run: npx playwright test
env:
CYPRESS_BASE_URL: "http://localhost:8585"
CYPRESS_RECORD_KEY: ${{ steps.cypress-project-id.outputs.CYPRESS_RECORD_KEY }}
CYPRESS_grepTags: ${{ steps.getCypresse2eLabels.outputs.e2eLabels }}
CYPRESS_grepFilterSpecs: "true"
CYPRESS_SNOWFLAKE_USERNAME: ${{ secrets.TEST_SNOWFLAKE_USERNAME }}
CYPRESS_SNOWFLAKE_PASSWORD: ${{ secrets.TEST_SNOWFLAKE_PASSWORD }}
CYPRESS_SNOWFLAKE_ACCOUNT: ${{ secrets.TEST_SNOWFLAKE_ACCOUNT }}
Comment on lines +125 to +131
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this variable if we are not using it for playwright

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have kept env variable in the workflow intentionally as we will need in serviceIngetion test once we migrate it to playwright

CYPRESS_SNOWFLAKE_DATABASE: ${{ secrets.TEST_SNOWFLAKE_DATABASE }}
CYPRESS_SNOWFLAKE_WAREHOUSE: ${{ secrets.TEST_SNOWFLAKE_WAREHOUSE }}
CYPRESS_PROJECT_ID: ${{ steps.cypress-project-id.outputs.CYPRESS_PROJECT_ID }}
CYPRESS_BQ_PRIVATE_KEY: ${{ secrets.TEST_BQ_PRIVATE_KEY }}
CYPRESS_BQ_PROJECT_ID: ${{ secrets.TEST_BQ_PROJECT_ID }}
CYPRESS_BQ_PRIVATE_KEY_ID: ${{ secrets.TEST_BQ_PRIVATE_KEY_ID }}
CYPRESS_BQ_PROJECT_ID_TAXONOMY: ${{ secrets.TEST_BQ_PROJECT_ID_TAXONOMY }}
CYPRESS_BQ_CLIENT_EMAIL: ${{ secrets.TEST_BQ_CLIENT_EMAIL }}
CYPRESS_BQ_CLIENT_ID: ${{ secrets.TEST_BQ_CLIENT_ID }}
CYPRESS_REDSHIFT_HOST: ${{ secrets.E2E_REDSHIFT_HOST_PORT }}
CYPRESS_REDSHIFT_USERNAME: ${{ secrets.E2E_REDSHIFT_USERNAME }}
CYPRESS_REDSHIFT_PASSWORD: ${{ secrets.E2E_REDSHIFT_PASSWORD }}
CYPRESS_REDSHIFT_DATABASE: ${{ secrets.TEST_REDSHIFT_DATABASE }}
CYPRESS_METABASE_USERNAME: ${{ secrets.TEST_METABASE_USERNAME }}
CYPRESS_METABASE_PASSWORD: ${{ secrets.TEST_METABASE_PASSWORD }}
CYPRESS_METABASE_DB_SERVICE_NAME: ${{ secrets.TEST_METABASE_DB_SERVICE_NAME }}
CYPRESS_METABASE_HOST_PORT: ${{ secrets.TEST_METABASE_HOST_PORT }}
CYPRESS_SUPERSET_USERNAME: ${{ secrets.TEST_SUPERSET_USERNAME }}
CYPRESS_SUPERSET_PASSWORD: ${{ secrets.TEST_SUPERSET_PASSWORD }}
CYPRESS_SUPERSET_HOST_PORT: ${{ secrets.TEST_SUPERSET_HOST_PORT }}
CYPRESS_KAFKA_BOOTSTRAP_SERVERS: ${{ secrets.TEST_KAFKA_BOOTSTRAP_SERVERS }}
CYPRESS_KAFKA_SCHEMA_REGISTRY_URL: ${{ secrets.TEST_KAFKA_SCHEMA_REGISTRY_URL }}
CYPRESS_GLUE_ACCESS_KEY: ${{ secrets.TEST_GLUE_ACCESS_KEY }}
CYPRESS_GLUE_SECRET_KEY: ${{ secrets.TEST_GLUE_SECRET_KEY }}
CYPRESS_GLUE_AWS_REGION: ${{ secrets.TEST_GLUE_AWS_REGION }}
CYPRESS_GLUE_ENDPOINT: ${{ secrets.TEST_GLUE_ENDPOINT }}
CYPRESS_GLUE_STORAGE_SERVICE: ${{ secrets.TEST_GLUE_STORAGE_SERVICE }}
CYPRESS_MYSQL_USERNAME: ${{ secrets.TEST_MYSQL_USERNAME }}
CYPRESS_MYSQL_PASSWORD: ${{ secrets.TEST_MYSQL_PASSWORD }}
CYPRESS_MYSQL_HOST_PORT: ${{ secrets.TEST_MYSQL_HOST_PORT }}
CYPRESS_MYSQL_DATABASE_SCHEMA: ${{ secrets.TEST_MYSQL_DATABASE_SCHEMA }}
CYPRESS_POSTGRES_USERNAME: ${{ secrets.TEST_POSTGRES_USERNAME }}
CYPRESS_POSTGRES_PASSWORD: ${{ secrets.TEST_POSTGRES_PASSWORD }}
CYPRESS_POSTGRES_HOST_PORT: ${{ secrets.TEST_POSTGRES_HOST_PORT }}
CYPRESS_POSTGRES_DATABASE: ${{ secrets.TEST_POSTGRES_DATABASE }}
CYPRESS_AIRFLOW_HOST_PORT: ${{ secrets.TEST_AIRFLOW_HOST_PORT }}
CYPRESS_ML_MODEL_TRACKING_URI: ${{ secrets.TEST_ML_MODEL_TRACKING_URI }}
CYPRESS_ML_MODEL_REGISTRY_URI: ${{ secrets.TEST_ML_MODEL_REGISTRY_URI }}
CYPRESS_S3_STORAGE_ACCESS_KEY_ID: ${{ secrets.TEST_S3_STORAGE_ACCESS_KEY_ID }}
CYPRESS_S3_STORAGE_SECRET_ACCESS_KEY: ${{ secrets.TEST_S3_STORAGE_SECRET_ACCESS_KEY }}
CYPRESS_S3_STORAGE_END_POINT_URL: ${{ secrets.TEST_S3_STORAGE_END_POINT_URL }}

# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: openmetadata-ui/src/main/resources/ui/playwright/output/playwright-report
retention-days: 30
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let'e reduce it to 5 days


- name: Clean Up
run: |
cd ./docker/development
docker compose down --remove-orphans
sudo rm -rf ${PWD}/docker-volume
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ openmetadata-ui/src/main/resources/ui/cypress/screenshots
openmetadata-ui/src/main/resources/ui/cypress/videos
openmetadata-ui/src/main/resources/ui/cypress/fixtures

# Playwright artifacts
openmetadata-ui/src/main/resources/ui/playwright/output/
openmetadata-ui/src/main/resources/ui/playwright/e2e/.cache/
openmetadata-ui/src/main/resources/ui/playwright/.env

#UI - Dereferenced Schemas
openmetadata-ui/src/main/resources/ui/src/jsons/connectionSchemas
openmetadata-ui/src/main/resources/ui/src/jsons/ingestionSchemas
Expand Down
19 changes: 19 additions & 0 deletions openmetadata-ui/src/main/resources/ui/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,25 @@ overrides:
jest/valid-describe:
- off

# Explicit assertions not required in most Playwright tests
- files:
- playwright/**
rules:
jest/expect-expect:
- off
jest/valid-expect-in-promise:
- off
jest/valid-expect:
- off
jest/valid-describe:
- off
jest/consistent-test-it:
- off
jest/no-done-callback:
- off
jest/no-standalone-expect:
- off

# i18next rule is not required for js, jsx, json and test file
- files:
- src/**/*.{js,jsx,json}
Expand Down
11 changes: 8 additions & 3 deletions openmetadata-ui/src/main/resources/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
"cypress:filter": "CYPRESS_BASE_URL=http://localhost:8585 cypress run --config-file=cypress.config.ts --env grepTags='Lineage',grepFilterSpecs=true",
"cypress:run:record": "cypress run --config-file=cypress.config.ts --record --parallel",
"i18n": "sync-i18n --files '**/locale/languages/*.json' --primary en-us --space 2 --fn",
"check-i18n": "npm run i18n -- --check"
"check-i18n": "npm run i18n -- --check",
"playwright:run": "playwright test",
"playwright:open": "playwright test --ui",
"playwright:codegen": "playwright codegen"
},
"dependencies": {
"@analytics/session-utils": "^0.1.17",
Expand All @@ -48,7 +51,9 @@
"@auth0/auth0-react": "^1.9.0",
"@azure/msal-browser": "^3.10.0",
"@azure/msal-react": "^2.0.12",
"@dagrejs/dagre": "^1.1.2",
"@deuex-solutions/react-tour": "^1.2.6",
"@estruyf/github-actions-reporter": "^1.7.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think we need this package, It's for CI only

"@fontsource/poppins": "^5.0.0",
"@fontsource/source-code-pro": "^5.0.0",
"@github/g-emoji-element": "^1.1.5",
Expand All @@ -72,7 +77,6 @@
"@tiptap/suggestion": "^2.3.0",
"@toast-ui/react-editor": "^3.1.8",
"@types/turndown": "^5.0.4",
"@dagrejs/dagre": "^1.1.2",
"analytics": "^0.8.1",
"antd": "4.24.0",
"antlr4": "4.9.2",
Expand Down Expand Up @@ -151,6 +155,7 @@
"@babel/preset-env": "^7.11.0",
"@babel/preset-react": "^7.10.4",
"@cypress/grep": "^4.0.1",
"@playwright/test": "^1.44.1",
"@svgr/webpack": "^6.5.0",
"@testing-library/jest-dom": "^5.11.8",
"@testing-library/react": "^9.3.2",
Expand Down Expand Up @@ -240,4 +245,4 @@
"prosemirror-view": "1.28.2",
"axios": "1.6.4"
}
}
}
71 changes: 71 additions & 0 deletions openmetadata-ui/src/main/resources/ui/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2024 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineConfig, devices } from '@playwright/test';
import dotenv from 'dotenv';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
dotenv.config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './playwright/e2e',
outputDir: './playwright/output/test-results',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [
['list'],
['html', { outputFolder: './playwright/output/playwright-report' }],
[
'@estruyf/github-actions-reporter',
{
useDetails: true,
showError: true,
},
],
],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'http://localhost:8585',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
12 changes: 12 additions & 0 deletions openmetadata-ui/src/main/resources/ui/playwright/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright 2024 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If nothing here, let's remove it

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Loading
Loading