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

feat: E2E test using cypress #2082

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d34f1e8
install cypress and make signin test
gee05053 Nov 28, 2023
91234cf
change package-lock.json
gee05053 Nov 28, 2023
a968fa8
add changeProfile test
gee05053 Nov 29, 2023
af235bd
modify code more simply
gee05053 Nov 30, 2023
19fdf8f
delete unused import
gee05053 Nov 30, 2023
e8c82cd
Merge branch 'main' into feat/e2eTesting-cypress
gee05053 Dec 4, 2023
883e761
change test account
gee05053 Dec 4, 2023
3ed72e1
Merge branch 'main' into feat/e2eTesting-cypress
gee05053 Dec 6, 2023
a88a633
implemnet createVfolder test
gee05053 Dec 6, 2023
f77af2f
implement delete vfolder test
gee05053 Dec 6, 2023
4e5aa4a
apply prettier and change DataPage to DataStoragePage
gee05053 Dec 7, 2023
9244b1f
fix: apply prettier
gee05053 Dec 7, 2023
8417746
implement launch session e2e test
gee05053 Dec 7, 2023
be7b2b9
fix:change vfolderName to mountVfolderName
gee05053 Dec 7, 2023
bbe8641
implement delete session test
gee05053 Dec 7, 2023
945811e
fix:add cy.wait() to see test process
gee05053 Dec 7, 2023
4842f34
Merge branch 'main' into feat/e2eTesting-cypress
gee05053 Dec 14, 2023
0c61074
feat:implement add user and delete user
gee05053 Dec 14, 2023
52075fc
fix:remove unused params
gee05053 Dec 14, 2023
7787479
feat:add playwright and implement test
gee05053 Dec 18, 2023
cb750c7
feat:implment delete session test
gee05053 Dec 18, 2023
e063020
fix:modify vfolder name to use params
gee05053 Dec 18, 2023
cd906f3
fix:add login with endpoint
gee05053 Dec 18, 2023
d50da4c
feat:implement delete vfolder test
gee05053 Dec 18, 2023
761ad32
feat:implement create and delete user
gee05053 Dec 19, 2023
bf52ed7
fix:modify code to use id
gee05053 Dec 19, 2023
6a60045
fix:add ;
gee05053 Dec 19, 2023
f44554c
fix:apply prettier
gee05053 Dec 19, 2023
79af354
fix:change sessionStoragePage to sessionPage
gee05053 Dec 20, 2023
6d7e7c8
fix:wrong import
gee05053 Dec 20, 2023
ed49d55
fix:remove cypress
gee05053 Dec 21, 2023
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
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ src/lib/backend.ai-client-node.ts
src/lib/backend.ai-client-node-to-es6.js
src/lib/backend.ai-client-node-test-native-es6.js
src/lib/Chart.min.js
src/lib/json_to_csv.js
src/lib/json_to_csv.js
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ src/plugins/*

#
!.vscode/i18n-ally-*
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
src/lib/
!/src
!/react
!/playwright
**/__generated__/*.graphql.ts
*.graphql
96 changes: 93 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"docs": "npx jsdoc -c ./jsdoc.json",
"update": "npx tsc",
"postinstall": "npx concurrently -c \"auto\" --names \"react-dependencies\" \"cd react && npm install\"",
"patch:lit-translate": "unzip -o ./scripts/lit-translate.zip -d ./node_modules/lit-translate && cp -f ./scripts/lit-translate-index.js ./node_modules/lit-translate/index.js",
"prepare": "husky install"
"patch:lit-translate": "unzip -o ./scripts/lit-translate.zip -d ./node_modules/lit-translate && cp -f ./scripts/lit-translate-index.js ./node_modules/lit-translate/index.js"
},
"dependencies": {
"@material/mwc-button": "^0.27.0",
Expand Down Expand Up @@ -97,6 +96,7 @@
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/preset-typescript": "^7.23.2",
"@babel/types": "^7.23.2",
"@playwright/test": "^1.40.1",
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-replace": "^5.0.2",
Expand All @@ -106,6 +106,7 @@
"@types/drawflow": "^0.0.6",
"@types/estree": "1.0.2",
"@types/hammerjs": "^2.0.42",
"@types/node": "^20.10.4",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"@web/dev-server": "^0.3.1",
Expand Down
77 changes: 77 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { defineConfig, devices } from '@playwright/test';

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

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './playwright/',
/* 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: 'html',
/* 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://127.0.0.1:3000',

/* 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'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: '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,
// },
});
10 changes: 10 additions & 0 deletions playwright/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"importOrderSeparation": true,
"printWidth": 80,
"bracketSpacing": true,
"trailingComma": "all",
"singleAttributePerLine": false
}
21 changes: 21 additions & 0 deletions playwright/e2eTest.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { test } from '@playwright/test';
import { login } from './pages/LoginPage.spec';
import { createVfolder, deleteVfolder } from './pages/DataStoragePage.spec';
import { createSession, deleteSession } from './pages/SessionPage.spec';
import { createUser, deleteUser } from './pages/CredentialPage.spec';

test('E2E test', async ({ page }) => {
await page.goto('http://localhost:9081/');
await login(page, 'test@lablup.com', 'test123!', 'http://127.0.0.1:8090');
await createVfolder(page, 'test2');
await createSession(
page,
'Ubuntu 20.04 aarch64',
'testvfolder',
'testSession',
);
await deleteSession(page, 'test@lablup.com', 'testSession');
await deleteVfolder(page, 'test2');
await createUser(page, 'test9@lablup.com', 'test9', 'test123!');
await deleteUser(page, 'test9\\@lablup\\.com');
});
71 changes: 71 additions & 0 deletions playwright/pages/CredentialPage.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { expect } from '@playwright/test';

export async function createUser(
page: Page,
email: string,
userName: string,
password: string,
) {
await page.locator('#credential').click();
await page.waitForURL('**/credential');
await page.getByRole('tab', { name: 'Users' }).click();
await page.getByRole('tab', { name: 'Active', exact: true }).click();
await page.locator('#add-user').click();
await page.locator('#new-user-dialog #id_user_email').click();
await page.locator('#new-user-dialog #id_user_email label').fill(email);
await page.locator('#new-user-dialog #id_user_name').click();
await page.locator('#new-user-dialog #id_user_name label').fill(userName);
await page.locator('#new-user-dialog #id_user_password').click();
await page.locator('#new-user-dialog #id_user_password label').fill(password);
await page.locator('#new-user-dialog #id_user_confirm').click();
await page.locator('#new-user-dialog #id_user_confirm label').fill(password);
await page.locator('#new-user-dialog #create-user-button').click();
await expect(
page
.locator('#active-user-list vaadin-grid-cell-content')
.filter({ hasText: email }),
).toBeVisible();
await page.getByRole('tab', { name: 'Credentials' }).click();
await page.getByRole('tab', { name: 'Active', exact: true }).click();
await expect(
page
.locator('#active-credential-list vaadin-grid-cell-content')
.filter({ hasText: email }),
).toBeVisible();
}

export async function deleteUser(page: Page, email: string) {
const emailText = email.replace(/\\/g, '');
await page.locator('#credential').click();
await page.waitForURL('**/credential');
await page.getByRole('tab', { name: 'Users' }).click();
await page.getByRole('tab', { name: 'Active', exact: true }).click();
await page
.locator(`#controls[user-id=${email}]`)
.locator('mwc-icon-button[icon="delete_forever"]')
.click();
await page.locator('#active-user-list #deleteOk').click();
await expect(
page
.locator('#active-user-list vaadin-grid-cell-content')
.filter({ hasText: emailText }),
).toBeHidden();
await page.getByRole('tab', { name: 'Inactive' }).click();
await expect(
page
.locator('#inactive-user-list vaadin-grid-cell-content')
.filter({ hasText: emailText }),
).toBeVisible();
await page.getByRole('tab', { name: 'Credentials' }).click();
await expect(
page
.locator('#active-credential-list vaadin-grid-cell-content')
.filter({ hasText: emailText }),
).toBeHidden();
await page.getByRole('tab', { name: 'Inactive' }).click();
await expect(
page
.locator('#inactive-credential-list vaadin-grid-cell-content')
.filter({ hasText: emailText }),
).toBeVisible();
}
Loading