Skip to content

Commit 0920769

Browse files
committed
Changes to the e2e tests after Svelte 4 migration
1 parent c53d910 commit 0920769

File tree

8 files changed

+84
-66
lines changed

8 files changed

+84
-66
lines changed

tests/not_found.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test';
22

33
test('Handles not found pages', async ({ page }) => {
44
await page.goto('/foo');
5-
await expect(page.getByText('Route not found')).toHaveCount(1);
5+
await expect(page.getByText('Route not found')).toBeVisible();
66
await page.goto('/_app/foo');
7-
await expect(page.getByText('Route not found')).toHaveCount(1);
7+
await expect(page.getByText('Not found')).toBeVisible();
88
});

tests/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export async function selectSlimSelect(page, selector, optionValue, multiple = f
8484
} else {
8585
await expect(selector).toHaveText(optionValue);
8686
}
87+
await expect(page.getByRole('option', { name: optionValue, exact: true })).toHaveAttribute('aria-selected', 'true');
8788
}
8889

8990
/**
@@ -109,4 +110,5 @@ export async function logout(page, email) {
109110
await page.getByRole('button', { name: email }).click();
110111
await page.getByRole('link', { name: 'Logout' }).click();
111112
await waitPageLoading(page);
113+
await expect(page.getByRole('link', {name: 'Login'}).first()).toBeVisible();
112114
}

tests/v1/jschema.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ test('JSON Schema validation', async ({ page, browserName, workflow }) => {
6767

6868
await test.step('Select required option', async () => {
6969
await page.getByRole('combobox', { name: 'Required enum' }).selectOption('option1');
70-
await page.getByRole('combobox', { name: 'Required enum' }).selectOption('null');
70+
await page.getByRole('combobox', { name: 'Required enum' }).selectOption('');
7171
expect(form.getByText('Field is required')).toHaveCount(1);
7272
await page.getByRole('combobox', { name: 'Required enum' }).selectOption('option1');
7373
expect(form.getByText('Field is required')).toHaveCount(0);
7474
});
7575

7676
await test.step('Select optional option', async () => {
7777
await page.getByRole('combobox', { name: 'Optional enum' }).selectOption('option1');
78-
await page.getByRole('combobox', { name: 'Optional enum' }).selectOption('null');
78+
await page.getByRole('combobox', { name: 'Optional enum' }).selectOption('');
7979
expect(form.getByText('Field is required')).toHaveCount(0);
8080
});
8181

tests/v2/admin_groups.spec.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,25 @@ test('Admin groups management', async ({ page }) => {
1212
group1 = await createTestGroup(page);
1313
});
1414

15-
/** @type {string[]} */
16-
let availableUsers;
17-
await test.step('Add all available users to the group', async () => {
15+
await test.step('Add the test user the group', async () => {
1816
const dragArea = page.getByText('drag the users here');
19-
availableUsers = await page.locator('[draggable="true"]').allInnerTexts();
17+
const availableUsers = await page.locator('[draggable="true"]').allInnerTexts();
2018
expect(availableUsers.length).toBeGreaterThan(1);
21-
for (const user of availableUsers) {
22-
const userBadge = page.getByRole('button', { name: user, exact: true });
23-
await userBadge.dragTo(dragArea);
24-
await expect(page.locator('.spinner-border-sm')).not.toBeVisible();
25-
}
26-
await expect(page.getByText('No more users available')).toBeVisible();
19+
await page.getByPlaceholder('Filter users').fill(user1);
20+
await expect(page.locator('[draggable="true"]')).toHaveCount(1);
21+
const userBadge = page.getByRole('button', { name: user1, exact: true });
22+
await userBadge.dragTo(dragArea);
23+
await expect(page.locator('.spinner-border-sm')).not.toBeVisible();
24+
await expect(page.getByRole('region')).toContainText(user1);
2725
});
2826

2927
await test.step('Check group info page', async () => {
3028
await page.goto('/v2/admin/groups');
3129
await waitPageLoading(page);
3230
await page.getByRole('row', { name: group1 }).getByRole('link', { name: 'Info' }).click();
33-
await page.getByText('Members of the group').waitFor();
34-
for (const user of availableUsers) {
35-
const userBadge = page.getByRole('link', { name: user, exact: true });
36-
await expect(userBadge).toBeVisible();
37-
}
31+
await expect(page.getByText('Members of the group')).toBeVisible();
32+
const userBadge = page.getByRole('link', { name: user1, exact: true });
33+
await expect(userBadge).toBeVisible();
3834
});
3935

4036
let group2, group3;
@@ -50,6 +46,7 @@ test('Admin groups management', async ({ page }) => {
5046
await page.goto('/v2/admin/users');
5147
await waitPageLoading(page);
5248
await page.getByRole('row', { name: user1 }).getByRole('link', { name: 'Edit' }).click();
49+
await page.waitForURL(/\/v2\/admin\/users\/\d+\/edit/);
5350
await waitPageLoading(page);
5451
const currentGroups = await groupBadges.allInnerTexts();
5552
initialGroupBadgesCount = await groupBadges.count();

tests/v2/jschema.spec.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,89 +43,89 @@ test('JSON Schema validation', async ({ page, workflow }) => {
4343
const input = form.getByLabel('Required string', { exact: true });
4444
await input.fill('foo');
4545
await input.fill('');
46-
expect(form.getByText('Field is required')).toHaveCount(1);
46+
await expect(form.getByText('Field is required')).toHaveCount(1);
4747
await input.fill('bar');
48-
expect(form.getByText('Field is required')).toHaveCount(0);
48+
await expect(form.getByText('Field is required')).toHaveCount(0);
4949
// Check that export button is disabled when there are some pending changes
50-
expect(await page.getByRole('button', { name: /.*Export$/ }).isDisabled()).toEqual(true);
50+
await expect(page.getByRole('button', { name: /.*Export$/ })).toBeDisabled();
5151
});
5252

5353
await test.step('Fill optional string', async () => {
5454
const input = form.getByLabel('Optional string', { exact: true });
5555
await input.fill('foo');
5656
await input.fill('');
57-
expect(form.getByText('Field is required')).toHaveCount(0);
57+
await expect(form.getByText('Field is required')).toHaveCount(0);
5858
});
5959

6060
await test.step('Select required option', async () => {
6161
await page.getByRole('combobox', { name: 'Required enum' }).selectOption('option1');
62-
await page.getByRole('combobox', { name: 'Required enum' }).selectOption('null');
63-
expect(form.getByText('Field is required')).toHaveCount(1);
62+
await page.getByRole('combobox', { name: 'Required enum' }).selectOption('');
63+
await expect(form.getByText('Field is required')).toHaveCount(1);
6464
await page.getByRole('combobox', { name: 'Required enum' }).selectOption('option1');
65-
expect(form.getByText('Field is required')).toHaveCount(0);
65+
await expect(form.getByText('Field is required')).toHaveCount(0);
6666
});
6767

6868
await test.step('Select optional option', async () => {
6969
await page.getByRole('combobox', { name: 'Optional enum' }).selectOption('option1');
70-
await page.getByRole('combobox', { name: 'Optional enum' }).selectOption('null');
71-
expect(form.getByText('Field is required')).toHaveCount(0);
70+
await page.getByRole('combobox', { name: 'Optional enum' }).selectOption('');
71+
await expect(form.getByText('Field is required')).toHaveCount(0);
7272
});
7373

7474
await test.step('Fill required integer with min and max', async () => {
7575
const input = form.getByLabel('minMaxRequiredInt', { exact: true });
7676
// Note: the only allowed characted in chrome is an "e" (for the scientific notation)
7777
await input.pressSequentially('e');
78-
expect(form.getByText('Should be a number')).toHaveCount(1);
78+
await expect(form.getByText('Should be a number')).toHaveCount(1);
7979
await input.fill('1');
80-
expect(form.getByText('Should be greater or equal than 5')).toHaveCount(1);
80+
await expect(form.getByText('Should be greater or equal than 5')).toHaveCount(1);
8181
await input.fill('15');
82-
expect(form.getByText('Should be lower or equal than 10')).toHaveCount(1);
82+
await expect(form.getByText('Should be lower or equal than 10')).toHaveCount(1);
8383
await input.fill('');
84-
expect(form.getByText('Field is required')).toHaveCount(1);
84+
await expect(form.getByText('Field is required')).toHaveCount(1);
8585
await input.fill('8');
86-
expect(form.getByText('Field is required')).toHaveCount(0);
86+
await expect(form.getByText('Field is required')).toHaveCount(0);
8787
});
8888

8989
await test.step('Fill optional integer with min and max', async () => {
9090
const input = form.getByLabel('minMaxOptionalInt', { exact: true });
9191
// Note: the only allowed characted in chrome is an "e" (for the scientific notation)
9292
await input.pressSequentially('e');
93-
expect(form.getByText('Should be a number')).toHaveCount(1);
93+
await expect(form.getByText('Should be a number')).toHaveCount(1);
9494
await input.fill('-7');
95-
expect(form.getByText('Should be greater or equal than 0')).toHaveCount(1);
95+
await expect(form.getByText('Should be greater or equal than 0')).toHaveCount(1);
9696
await input.fill('33');
97-
expect(form.getByText('Should be lower or equal than 8')).toHaveCount(1);
97+
await expect(form.getByText('Should be lower or equal than 8')).toHaveCount(1);
9898
await input.fill('');
99-
expect(form.getByText('Field is required')).toHaveCount(0);
99+
await expect(form.getByText('Field is required')).toHaveCount(0);
100100
});
101101

102102
await test.step('Fill optional integer with exclusive min and max', async () => {
103103
const input = form.getByLabel('exclusiveMinMaxOptionalInt', { exact: true });
104104
// Note: the only allowed characted in chrome is an "e" (for the scientific notation)
105105
await input.pressSequentially('e');
106-
expect(form.getByText('Should be a number')).toHaveCount(1);
106+
await expect(form.getByText('Should be a number')).toHaveCount(1);
107107
await input.fill('2');
108-
expect(form.getByText('Should be greater or equal than 4')).toHaveCount(1);
108+
await expect(form.getByText('Should be greater or equal than 4')).toHaveCount(1);
109109
await input.fill('99');
110-
expect(form.getByText('Should be lower or equal than 41')).toHaveCount(1);
110+
await expect(form.getByText('Should be lower or equal than 41')).toHaveCount(1);
111111
await input.fill('');
112-
expect(form.getByText('Field is required')).toHaveCount(0);
112+
await expect(form.getByText('Field is required')).toHaveCount(0);
113113
});
114114

115115
await test.step('Required boolean', async () => {
116116
const booleanSwitch = form.getByRole('switch');
117-
expect(await booleanSwitch.isChecked()).toEqual(false);
117+
await expect(booleanSwitch).not.toBeChecked();
118118
await booleanSwitch.check();
119-
expect(await booleanSwitch.isChecked()).toEqual(true);
119+
await expect(booleanSwitch).toBeChecked();
120120
await booleanSwitch.uncheck();
121-
expect(await booleanSwitch.isChecked()).toEqual(false);
121+
await expect(booleanSwitch).not.toBeChecked();
122122
});
123123

124124
await test.step('Required array with minItems and maxItems', async () => {
125125
const addBtn = form.getByRole('button', { name: 'Add argument to list' }).first();
126126
await addBtn.click();
127127
await addBtn.click();
128-
expect(await addBtn.isDisabled()).toEqual(true);
128+
await expect( addBtn).toBeDisabled();
129129
const block = form.locator('.property-block', {
130130
has: page.getByText('requiredArrayWithMinMaxItems')
131131
});
@@ -145,7 +145,7 @@ test('JSON Schema validation', async ({ page, workflow }) => {
145145
await checkFirstArray(block, ['a', 'b', 'd', 'c']);
146146
// Remove items
147147
await form.getByRole('button', { name: 'Remove' }).nth(3).click();
148-
expect(await addBtn.isDisabled()).toEqual(false);
148+
await expect( addBtn).not.toBeDisabled();
149149
await form.getByRole('button', { name: 'Remove' }).nth(2).click();
150150
await checkFirstArray(block, ['a', 'b']);
151151
});
@@ -156,7 +156,7 @@ test('JSON Schema validation', async ({ page, workflow }) => {
156156
*/
157157
async function checkFirstArray(block, expectedValues) {
158158
for (let i = 0; i < expectedValues.length; i++) {
159-
expect(await block.getByRole('textbox').nth(i).inputValue()).toEqual(expectedValues[i]);
159+
await expect(block.getByRole('textbox').nth(i)).toHaveValue(expectedValues[i]);
160160
}
161161
}
162162

@@ -166,18 +166,18 @@ test('JSON Schema validation', async ({ page, workflow }) => {
166166
await addBtn.click();
167167
await addBtn.click();
168168
await addBtn.click();
169-
expect(await addBtn.isDisabled()).toEqual(true);
169+
await expect(addBtn).toBeDisabled();
170170
const block = form.locator('.property-block', {
171171
has: page.getByText('optionalArrayWithMinMaxItems')
172172
});
173173
await block.getByRole('textbox').nth(0).fill('a');
174174
await block.getByRole('textbox').nth(1).fill('b');
175175
await block.getByRole('textbox').nth(2).fill('c');
176176
await form.getByRole('button', { name: 'Remove' }).nth(2).click();
177-
expect(await addBtn.isDisabled()).toEqual(false);
177+
await expect(addBtn).not.toBeDisabled();
178178
await form.getByRole('button', { name: 'Remove' }).nth(1).click();
179179
await form.getByRole('button', { name: 'Remove' }).nth(0).click();
180-
expect(block.getByRole('textbox')).toHaveCount(0);
180+
await expect(block.getByRole('textbox')).toHaveCount(0);
181181
});
182182

183183
await test.step('Object with nested properties', async () => {
@@ -187,13 +187,13 @@ test('JSON Schema validation', async ({ page, workflow }) => {
187187
});
188188

189189
await test.step('Attempt to save with missing required fields', async () => {
190-
expect(form.getByText('Field is required')).toHaveCount(0);
190+
await expect(form.getByText('Field is required')).toHaveCount(0);
191191
const stringInput = form.getByLabel('Required string', { exact: true });
192192
await stringInput.fill('');
193193
const intInput = form.getByLabel('minMaxRequiredInt', { exact: true });
194194
await intInput.fill('');
195195
await page.getByRole('button', { name: 'Save changes' }).click();
196-
expect(form.getByText('Field is required')).toHaveCount(2);
196+
await expect(form.getByText('Field is required')).toHaveCount(2);
197197
});
198198

199199
await test.step('Save values', async () => {

tests/v2/slurm_account.spec.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { waitPageLoading } from '../utils.js';
1+
import { waitModalClosed, waitPageLoading } from '../utils.js';
22
import { createDataset } from './dataset_utils.js';
33
import { expect, test } from './workflow_fixture.js';
44
import { waitTaskSubmitted, waitTasksSuccess } from './workflow_task_utils.js';
@@ -19,16 +19,25 @@ test('Add SLURM accounts for the admin and execute workflow using a specific acc
1919
await waitPageLoading(page);
2020
});
2121

22-
const randomSlurmAccount = Math.random().toString(36).substring(7);
22+
let randomSlurmAccount;
2323

24-
await test.step('Add SLURM account to the admin', async () => {
25-
await page.getByRole('button', { name: 'Add SLURM account' }).click();
26-
await page
27-
.getByLabel(/^SLURM account #/)
28-
.last()
29-
.fill(randomSlurmAccount);
30-
await page.getByRole('button', { name: 'Save' }).nth(1).click();
31-
await expect(page.getByText('Settings successfully updated')).toBeVisible();
24+
await test.step('Add SLURM account to the admin or detect existing SLURM account', async () => {
25+
await expect(page.getByRole('button', { name: 'Add SLURM account' })).toBeVisible();
26+
const inputs = await page.getByLabel(/^SLURM account/).all();
27+
if (inputs.length > 0) {
28+
// If a SLURM account already exists, pick the exising one to avoid concurrent
29+
// modifications of the SLURM accounts list
30+
randomSlurmAccount = await inputs[0].inputValue();
31+
} else {
32+
randomSlurmAccount = Math.random().toString(36).substring(7);
33+
await page.getByRole('button', { name: 'Add SLURM account' }).click();
34+
await page
35+
.getByLabel(/^SLURM account #/)
36+
.last()
37+
.fill(randomSlurmAccount);
38+
await page.getByRole('button', { name: 'Save' }).nth(1).click();
39+
await expect(page.getByText('Settings successfully updated')).toBeVisible();
40+
}
3241
});
3342

3443
await test.step('Add task to workflow', async () => {
@@ -51,7 +60,9 @@ test('Add SLURM accounts for the admin and execute workflow using a specific acc
5160
await modal.getByRole('button', { name: 'Advanced Options' }).click();
5261
await modal.getByRole('combobox', { name: 'SLURM account' }).selectOption(randomSlurmAccount);
5362
await modal.getByRole('button', { name: 'Run' }).click();
63+
await expect(modal.getByRole('combobox', { name: 'SLURM account' })).toBeDisabled();
5464
await modal.getByRole('button', { name: 'Confirm' }).click();
65+
await waitModalClosed(page);
5566
});
5667

5768
await test.step('Wait task submitted', async () => {

tests/v2/task_utils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ export async function createFakeTask(page, task) {
8383
* @param {'v1'|'v2'} version
8484
*/
8585
export async function deleteTask(page, taskName, version = 'v2') {
86-
await page.goto(`/${version}/tasks`);
87-
await waitPageLoading(page);
86+
if (!page.url().endsWith(`/${version}/tasks`)) {
87+
await page.goto(`/${version}/tasks`);
88+
await waitPageLoading(page);
89+
}
8890
const row = await getTaskRow(page, taskName);
8991
await row.getByRole('button', { name: 'Delete' }).click();
9092
const modal = page.locator('.modal.show');

tests/v2/users_crud.spec.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ test('Create and update a user', async ({ page }) => {
6363
await test.step('Display the user info page', async () => {
6464
const userRow = await getUserRow(page, randomUserName);
6565
await userRow.getByRole('link', { name: 'Info' }).click();
66+
await page.waitForURL(/\/v2\/admin\/users\/\d+/);
6667
await waitPageLoading(page);
6768
const cells = await page.locator('table td').all();
6869
expect(await cells[0].innerText()).toEqual(userId);
@@ -80,12 +81,14 @@ test('Create and update a user', async ({ page }) => {
8081
await test.step('Go back to previous page', async () => {
8182
await page.getByRole('link', { name: 'Manage users' }).click();
8283
await waitPageLoading(page);
84+
await expect(page.getByText('Users list')).toBeVisible();
8385
});
8486

8587
await test.step('Open edit user page', async () => {
8688
const userRow = await getUserRow(page, randomUserName);
8789
await userRow.getByRole('link', { name: 'Edit' }).click();
8890
await waitPageLoading(page);
91+
await page.waitForURL(/\/v2\/admin\/users\/\d+/);
8992
});
9093

9194
await test.step('Test cache dir validation error', async () => {
@@ -151,6 +154,7 @@ test('Create and update a user', async ({ page }) => {
151154
await test.step('Display the user info page', async () => {
152155
const userRow = await getUserRow(page, randomUserName + '-renamed');
153156
await userRow.getByRole('link', { name: 'Info' }).click();
157+
await page.waitForURL(/\/v2\/admin\/users\/\d+/);
154158
await waitPageLoading(page);
155159
const cells = await page.locator('table td').all();
156160
expect(await cells[0].innerText()).toEqual(userId);
@@ -168,7 +172,7 @@ test('Create and update a user', async ({ page }) => {
168172
await test.step('Go back clicking on breadcrumb', async () => {
169173
await page.getByText('Manage users').click();
170174
await waitPageLoading(page);
171-
await page.getByText('Users list').waitFor();
175+
await expect(page.getByText('Users list')).toBeVisible();
172176
});
173177

174178
await test.step('Grant superuser privilege', async () => {
@@ -190,6 +194,7 @@ test('Create and update a user', async ({ page }) => {
190194
await test.step('Check user in users list', async () => {
191195
await page.goto('/v2/admin/users');
192196
await waitPageLoading(page);
197+
await expect(page.getByText('Users list')).toBeVisible();
193198
const userRowCells = await getUserRowCells(page, randomUserName + '-renamed');
194199
verifyChecked(userRowCells, 3, true);
195200
verifyChecked(userRowCells, 4, true);
@@ -200,7 +205,7 @@ test('Create and update a user', async ({ page }) => {
200205
const userRow = await getUserRow(page, randomUserName + '-renamed');
201206
await userRow.getByRole('link', { name: 'Edit' }).click();
202207
await waitPageLoading(page);
203-
await page.getByText('Editing user #').waitFor();
208+
await page.waitForURL(/\/v2\/admin\/users\/\d+/);
204209
await page.locator('#superuser').uncheck();
205210
await page.getByRole('button', { name: 'Save' }).first().click();
206211

@@ -218,6 +223,7 @@ test('Create and update a user', async ({ page }) => {
218223
await test.step('Check user in users list', async () => {
219224
await page.goto('/v2/admin/users');
220225
await waitPageLoading(page);
226+
await expect(page.getByText('Users list')).toBeVisible();
221227
const userRowCells = await getUserRowCells(page, randomUserName + '-renamed');
222228
verifyChecked(userRowCells, 3, true);
223229
verifyChecked(userRowCells, 4, false);

0 commit comments

Comments
 (0)