Skip to content

Commit f6e0bc9

Browse files
nowgnuesLeeyomybaby
authored andcommitted
feat: add FolderCreationModal class and some tests to test createion modal class
1 parent 91bc683 commit f6e0bc9

12 files changed

Lines changed: 244 additions & 28 deletions

e2e/agent.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { loginAsAdmin } from './test-util';
2-
import { checkActiveTab, findColumnIndex } from './test-util-antd';
1+
import { loginAsAdmin } from './utils/test-util';
2+
import { checkActiveTab, findColumnIndex } from './utils/test-util-antd';
33
import { test, expect } from '@playwright/test';
44

55
test.beforeEach(async ({ page }) => {

e2e/config.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { loginAsAdmin, modifyConfigToml, webuiEndpoint } from './test-util';
1+
import {
2+
loginAsAdmin,
3+
modifyConfigToml,
4+
webuiEndpoint,
5+
} from './utils/test-util';
26
import { test, expect } from '@playwright/test';
37

48
test.describe.parallel('config.toml', () => {

e2e/environment.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { loginAsAdmin, navigateTo } from './test-util';
2-
import { findColumnIndex } from './test-util-antd';
1+
import { loginAsAdmin, navigateTo } from './utils/test-util';
2+
import { findColumnIndex } from './utils/test-util-antd';
33
import { expect, test } from '@playwright/test';
44

55
test.describe('environment ', () => {

e2e/login.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { loginAsAdmin } from './test-util';
1+
import { loginAsAdmin } from './utils/test-util';
22
import { test, expect } from '@playwright/test';
33

44
test.beforeEach(async ({ page }) => {

e2e/maintenance.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { loginAsAdmin } from './test-util';
1+
import { loginAsAdmin } from './utils/test-util';
22
import {
33
getNotificationDescriptionBox,
44
getNotificationMessageBox,
5-
} from './test-util-antd';
5+
} from './utils/test-util-antd';
66
import { test, expect } from '@playwright/test';
77

88
test.beforeEach(async ({ page }) => {

e2e/screenshot.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { loginAsAdmin, webuiEndpoint } from './test-util';
1+
import { loginAsAdmin, webuiEndpoint } from './utils/test-util';
22
import { test } from '@playwright/test';
33
import * as path from 'path';
44

e2e/session-launcher.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
loginAsAdmin,
55
loginAsUser,
66
navigateTo,
7-
} from './test-util';
7+
} from './utils/test-util';
88
import { test, expect } from '@playwright/test';
99

1010
test.describe('NEO Sessions Launcher', () => {

e2e/user.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
loginAsCreatedAccount,
44
logout,
55
webuiEndpoint,
6-
} from './test-util';
6+
} from './utils/test-util';
77
import test, { expect } from '@playwright/test';
88

99
const EMAIL = '[email protected]';

e2e/utils/classes/FolderCreationModal.ts

Lines changed: 152 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@ import { expect, Locator, Page } from '@playwright/test';
22

33
export class FolderCreationModal {
44
private readonly modal: Locator;
5+
private readonly page: Page;
56
constructor(page: Page) {
6-
this.modal = page.locator('#create-folder-modal');
7+
this.modal = page.locator(
8+
'.ant-modal-content:has-text("Create a new storage folder")',
9+
);
10+
this.page = page;
11+
}
12+
13+
async modalToBeVisible(): Promise<void> {
14+
await expect(this.modal).toBeVisible();
715
}
816

917
async getFolderNameInput(): Promise<Locator> {
10-
const folderNameInput = this.modal
11-
.locator('ant-form-item-row:has-text("Folder name")')
12-
.locator('input');
18+
const folderNameInput = (
19+
await this.getFormItemByLabel('Folder Name')
20+
).locator('input');
21+
1322
await expect(folderNameInput).toBeVisible();
1423
return folderNameInput;
1524
}
@@ -21,20 +30,152 @@ export class FolderCreationModal {
2130
}
2231

2332
async getLocationSelector(): Promise<Locator> {
24-
const locationSelector = this.modal
25-
.locator('ant-form-item-row:has-text("Location")')
26-
.locator(
27-
'.ant-form-item-control-input-content > .ant-select > .ant-select-selector',
28-
);
33+
const locationSelector = (
34+
await this.getFormItemByLabel('Location')
35+
).locator(
36+
'.ant-form-item-control-input-content > .ant-select > .ant-select-selector',
37+
);
2938
await expect(locationSelector).toBeVisible();
3039
return locationSelector;
3140
}
3241

33-
async getRadioByLabel(label: string): Promise<Locator> {
42+
async getLocationSelectorInput(): Promise<Locator> {
43+
const locationSelectorInput = (await this.getLocationSelector()).locator(
44+
'input',
45+
);
46+
await expect(locationSelectorInput).toBeVisible();
47+
return locationSelectorInput;
48+
}
49+
50+
async fillLocationSelector(text: string): Promise<void> {
51+
const locationSelectorInput = await this.getLocationSelectorInput();
52+
await locationSelectorInput.fill(text);
53+
await expect(locationSelectorInput).toHaveValue(text);
54+
}
55+
56+
async getLocationOptionContainer(): Promise<Locator> {
57+
await (await this.getLocationSelector()).click();
58+
const locationOptionContainer = this.page.locator('.ant-select-dropdown');
59+
await expect(locationOptionContainer).toBeVisible();
60+
return locationOptionContainer;
61+
}
62+
63+
async getLocationOptionByText(text: string): Promise<Locator> {
64+
const locationOptionContainer = await this.getLocationOptionContainer();
65+
const locationOption = locationOptionContainer
66+
.getByRole('option', {
67+
name: text,
68+
})
69+
.first();
70+
await expect(locationOption).toBeVisible();
71+
return locationOption;
72+
}
73+
74+
async selectLocationOptionByText(text: string): Promise<void> {
75+
const locationOption = await this.getLocationOptionByText(text);
76+
await locationOption.click();
77+
await expect(locationOption).toHaveAttribute('aria-selected', 'true');
78+
}
79+
80+
async getFormItemByLabel(label: string): Promise<Locator> {
3481
const RadioContainer = this.modal.locator(
35-
`ant-form-item-row:has-text("${label}")`,
82+
`.ant-form-item-row:has-text("${label}")`,
3683
);
3784
await expect(RadioContainer).toBeVisible();
3885
return RadioContainer;
3986
}
87+
88+
async getUsageModeFormItem(): Promise<Locator> {
89+
return await this.getFormItemByLabel('Usage Mode');
90+
}
91+
92+
async getTypeFormItem(): Promise<Locator> {
93+
return await this.getFormItemByLabel('Type');
94+
}
95+
96+
async getPermissionFormItem(): Promise<Locator> {
97+
return await this.getFormItemByLabel('Permission');
98+
}
99+
100+
async getProjectFormItem(): Promise<Locator> {
101+
return await this.getFormItemByLabel('Project');
102+
}
103+
104+
async getCloneableFormItem(): Promise<Locator> {
105+
return await this.getFormItemByLabel('Cloneable');
106+
}
107+
108+
async getCloneableSwitchButton(): Promise<Locator> {
109+
const cloneableToggleButton = (
110+
await this.getCloneableFormItem()
111+
).getByLabel('Cloneable');
112+
await expect(cloneableToggleButton).toBeVisible();
113+
return cloneableToggleButton;
114+
}
115+
116+
async getGeneralUsageModeRadio(): Promise<Locator> {
117+
const usageModeFormItem = await this.getUsageModeFormItem();
118+
return usageModeFormItem.getByLabel('General', {
119+
exact: true,
120+
});
121+
}
122+
123+
async getModelUsageModeRadio(): Promise<Locator> {
124+
const usageModeFormItem = await this.getUsageModeFormItem();
125+
return usageModeFormItem.getByLabel('Model', {
126+
exact: true,
127+
});
128+
}
129+
130+
async getUserTypeRadio(): Promise<Locator> {
131+
const typeFormItem = await this.getTypeFormItem();
132+
return typeFormItem.getByLabel('User', {
133+
exact: true,
134+
});
135+
}
136+
137+
async getProjectTypeRadio(): Promise<Locator> {
138+
const typeFormItem = await this.getTypeFormItem();
139+
return typeFormItem.getByLabel('Project', {
140+
exact: true,
141+
});
142+
}
143+
144+
async getReadWritePermissionRadio(): Promise<Locator> {
145+
const permissionFormItem = await this.getPermissionFormItem();
146+
return permissionFormItem.getByLabel('Read & Write', {
147+
exact: true,
148+
});
149+
}
150+
151+
async getReadOnlyPermissionRadio(): Promise<Locator> {
152+
const permissionFormItem = await this.getPermissionFormItem();
153+
return permissionFormItem.getByLabel('Read Only', {
154+
exact: true,
155+
});
156+
}
157+
158+
async getCreateButton(): Promise<Locator> {
159+
const createButton = this.modal.getByTestId('create-folder-button');
160+
await expect(createButton).toBeVisible();
161+
return createButton;
162+
}
163+
164+
async getCancelButton(): Promise<Locator> {
165+
const cancelButton = this.modal.getByRole('button', {
166+
name: 'Cancel',
167+
exact: true,
168+
});
169+
await expect(cancelButton).toBeVisible();
170+
return cancelButton;
171+
}
172+
173+
async getResetButton(): Promise<Locator> {
174+
const resetButton = this.modal.getByRole('button', {
175+
name: 'Reset',
176+
exact: true,
177+
});
178+
await expect(resetButton).toBeVisible();
179+
return resetButton;
180+
}
40181
}

e2e/utils/test-util.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ async function removeSearchButton(page: Page, folderName: string) {
135135
export async function verifyVFolder(
136136
page: Page,
137137
folderName: string,
138-
statusTab: 'Created' | 'Trash' = 'Created',
138+
statusTab: 'Active' | 'Trash' = 'Active',
139139
) {
140140
await page.getByRole('link', { name: 'Data' }).click();
141141
await page.getByRole('tab', { name: statusTab }).click();
@@ -279,7 +279,7 @@ export async function restoreVFolderAndVerify(page: Page, folderName: string) {
279279
.getByRole('button')
280280
.first()
281281
.click();
282-
await verifyVFolder(page, folderName, 'Created');
282+
await verifyVFolder(page, folderName, 'Active');
283283
}
284284

285285
export async function createSession(page: Page, sessionName: string) {
@@ -298,13 +298,13 @@ export async function createSession(page: Page, sessionName: string) {
298298
await page.getByRole('button', { name: 'Start' }).click();
299299

300300
// Wait for App dialog and close it
301-
await page.locator('[id="\\30 -apps"]').click({ timeout: 30000 });
301+
await expect(page.getByRole('heading', { name: 'App close' })).toBeVisible;
302302
await page.getByRole('button', { name: 'close' }).click();
303303

304304
// Verify that a cell exists to display the session name
305305
const session = page
306306
.locator('vaadin-grid-cell-content')
307-
.filter({ hasText: `${sessionName} edit done` });
307+
.filter({ hasText: `${sessionName}` });
308308
// it takes time to show the created session
309309
await expect(session).toBeVisible({ timeout: 10000 });
310310
}
@@ -314,7 +314,7 @@ export async function deleteSession(page: Page, sessionName: string) {
314314
const sessionList = page.locator('#running-jobs').locator('#list-grid');
315315
const searchSessionInfo = sessionList
316316
.locator('vaadin-grid-cell-content')
317-
.nth(2)
317+
.nth(1)
318318
.locator('vaadin-text-field')
319319
.nth(1)
320320
.locator('input');

0 commit comments

Comments
 (0)