Skip to content

Commit

Permalink
feat:implement create and delete user
Browse files Browse the repository at this point in the history
  • Loading branch information
gee05053 committed Dec 19, 2023
1 parent d50da4c commit 761ad32
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
9 changes: 6 additions & 3 deletions e2e/e2eTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import { test, expect } from '@playwright/test';
import { login } from '../tests-examples/login.spec'
import { createVfolder, deleteVfolder } from '../tests-examples/DataStoragePage.spec';
import { createSession, deleteSession } from '../tests-examples/SessionStoragePage.spec';
import { createUser, deleteUser } from '../tests-examples/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, 'testvfolder')
await createVfolder(page, 'testvfolder');
await createSession(page, 'Ubuntu 20.04 aarch64', 'testvfolder', 'testSession');
await deleteSession(page, 'test@lablup.com', 'testSession')
await deleteVfolder(page, 'testvfolder')
await deleteSession(page, 'test@lablup.com', 'testSession');
await deleteVfolder(page, 'testvfolder');
await createUser(page, 'test8@lablup.com', 'test8', 'test123!');
await deleteUser(page, 'test8\\@lablup\\.com');
});
40 changes: 40 additions & 0 deletions tests-examples/CredentialPage.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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.locator('#mdc-tab-1').click();
await page.locator('#mdc-tab-4').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.locator('#mdc-tab-2').click();
await page.locator('#mdc-tab-6').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.locator('#mdc-tab-1').click();
await page.locator('#mdc-tab-4').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.locator('#mdc-tab-5').click();
await expect(page.locator('#inactive-user-list vaadin-grid-cell-content').filter({ hasText: emailText })).toBeVisible();
await page.locator('#mdc-tab-2').click();
await expect(page.locator('#active-credential-list vaadin-grid-cell-content').filter({ hasText: emailText })).toBeHidden();
await page.locator('#mdc-tab-7').click();
await expect(page.locator('#inactive-credential-list vaadin-grid-cell-content').filter({ hasText: emailText })).toBeVisible();
}

0 comments on commit 761ad32

Please sign in to comment.