Skip to content

Commit 82f2cb5

Browse files
PanchoutNathanAntoLC
authored andcommitted
✅(frontend) enhance tests
- Removed 'feature/doc-dnd' branch from the Docker Hub workflow to streamline deployment processes. - Updated document creation tests to replace 'New page' button references with 'New doc' for consistency. - Enhanced test cases to improve clarity and ensure accurate verification of document functionalities. - Added new utility function for creating root subpages, improving test maintainability.
1 parent 44909fa commit 82f2cb5

File tree

11 files changed

+117
-307
lines changed

11 files changed

+117
-307
lines changed

env.d/development/common.e2e.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
BURST_THROTTLE_RATES="200/minute"
33
COLLABORATION_API_URL=http://y-provider:4444/collaboration/api/
44
SUSTAINED_THROTTLE_RATES="200/hour"
5-
Y_PROVIDER_API_BASE_URL=http://y-provider:4444/api/
5+
Y_PROVIDER_API_BASE_URL=http://y-provider:4444/api/

src/frontend/apps/e2e/__tests__/app-impress/common.ts

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const createDoc = async (
9090

9191
await page
9292
.getByRole('button', {
93-
name: isChild ? 'New page' : 'New doc',
93+
name: 'New doc',
9494
})
9595
.click();
9696

@@ -220,6 +220,7 @@ export const updateDocTitle = async (page: Page, title: string) => {
220220
await input.click();
221221
await input.fill(title);
222222
await input.click();
223+
await input.blur();
223224
await verifyDocName(page, title);
224225
};
225226

@@ -302,6 +303,24 @@ export const mockedListDocs = async (page: Page, data: object[] = []) => {
302303
};
303304

304305
export const mockedInvitations = async (page: Page, json?: object) => {
306+
let result = [
307+
{
308+
id: '120ec765-43af-4602-83eb-7f4e1224548a',
309+
abilities: {
310+
destroy: true,
311+
update: true,
312+
partial_update: true,
313+
retrieve: true,
314+
},
315+
created_at: '2024-10-03T12:19:26.107687Z',
316+
317+
document: '4888c328-8406-4412-9b0b-c0ba5b9e5fb6',
318+
role: 'editor',
319+
issuer: '7380f42f-02eb-4ad5-b8f0-037a0e66066d',
320+
is_expired: false,
321+
...json,
322+
},
323+
];
305324
await page.route('**/invitations/**/', async (route) => {
306325
const request = route.request();
307326
if (
@@ -314,36 +333,33 @@ export const mockedInvitations = async (page: Page, json?: object) => {
314333
count: 1,
315334
next: null,
316335
previous: null,
317-
results: [
318-
{
319-
id: '120ec765-43af-4602-83eb-7f4e1224548a',
320-
abilities: {
321-
destroy: true,
322-
update: true,
323-
partial_update: true,
324-
retrieve: true,
325-
},
326-
created_at: '2024-10-03T12:19:26.107687Z',
327-
328-
document: '4888c328-8406-4412-9b0b-c0ba5b9e5fb6',
329-
role: 'editor',
330-
issuer: '7380f42f-02eb-4ad5-b8f0-037a0e66066d',
331-
is_expired: false,
332-
...json,
333-
},
334-
],
336+
results: result,
335337
},
336338
});
337339
} else {
338340
await route.continue();
339341
}
340342
});
343+
344+
await page.route(
345+
'**/invitations/120ec765-43af-4602-83eb-7f4e1224548a/**/',
346+
async (route) => {
347+
const request = route.request();
348+
if (request.method().includes('DELETE')) {
349+
result = [];
350+
351+
await route.fulfill({
352+
json: {},
353+
});
354+
}
355+
},
356+
);
341357
};
342358

343359
export const mockedAccesses = async (page: Page, json?: object) => {
344360
await page.route('**/accesses/**/', async (route) => {
345361
const request = route.request();
346-
console.log('oui');
362+
347363
if (
348364
request.method().includes('GET') &&
349365
request.url().includes('accesses')

src/frontend/apps/e2e/__tests__/app-impress/doc-export.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ test.describe('Doc Export', () => {
7272
await page
7373
.getByRole('button', {
7474
name: 'download',
75+
exact: true,
7576
})
7677
.click();
7778

@@ -82,6 +83,7 @@ test.describe('Doc Export', () => {
8283
void page
8384
.getByRole('button', {
8485
name: 'Download',
86+
exact: true,
8587
})
8688
.click();
8789

@@ -120,6 +122,7 @@ test.describe('Doc Export', () => {
120122
await page
121123
.getByRole('button', {
122124
name: 'download',
125+
exact: true,
123126
})
124127
.click();
125128

@@ -129,6 +132,7 @@ test.describe('Doc Export', () => {
129132
await expect(
130133
page.getByRole('button', {
131134
name: 'Download',
135+
exact: true,
132136
}),
133137
).toBeVisible();
134138

@@ -139,6 +143,7 @@ test.describe('Doc Export', () => {
139143
void page
140144
.getByRole('button', {
141145
name: 'Download',
146+
exact: true,
142147
})
143148
.click();
144149

@@ -312,12 +317,14 @@ test.describe('Doc Export', () => {
312317
await page
313318
.getByRole('button', {
314319
name: 'download',
320+
exact: true,
315321
})
316322
.click();
317323

318324
await expect(
319325
page.getByRole('button', {
320326
name: 'Download',
327+
exact: true,
321328
}),
322329
).toBeVisible();
323330

@@ -328,6 +335,7 @@ test.describe('Doc Export', () => {
328335
void page
329336
.getByRole('button', {
330337
name: 'Download',
338+
exact: true,
331339
})
332340
.click();
333341

src/frontend/apps/e2e/__tests__/app-impress/doc-grid.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ test.describe('Documents filters', () => {
226226

227227
await allDocs.click();
228228

229+
await page.waitForURL('**/?target=all_docs');
230+
229231
let url = new URL(page.url());
230232
let target = url.searchParams.get('target');
231233
expect(target).toBe('all_docs');

src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ test.describe('Doc Header', () => {
6969
page.getByRole('heading', { name: 'Delete a doc' }),
7070
).toBeVisible();
7171

72-
await expect(
73-
page.getByText(
74-
`Are you sure you want to delete the document "${randomDoc}"?`,
75-
),
76-
).toBeVisible();
72+
await expect(page.getByText(`This document and any sub-`)).toBeVisible();
7773

7874
await page
7975
.getByRole('button', {
@@ -134,32 +130,31 @@ test.describe('Doc Header', () => {
134130
await expect(shareModal).toBeVisible();
135131
await expect(page.getByText('Share the document')).toBeVisible();
136132

137-
// await expect(page.getByPlaceholder('Type a name or email')).toBeVisible();
138-
139133
const invitationCard = shareModal.getByLabel('List invitation card');
140134
await expect(invitationCard).toBeVisible();
141135
await expect(
142136
invitationCard.getByText('[email protected]').first(),
143137
).toBeVisible();
144-
await expect(invitationCard.getByLabel('doc-role-dropdown')).toBeVisible();
138+
const invitationRole = invitationCard.getByLabel('doc-role-dropdown');
139+
await expect(invitationRole).toBeVisible();
145140

146-
await invitationCard.getByRole('button', { name: 'more_horiz' }).click();
141+
await invitationRole.click();
147142

148-
await expect(page.getByLabel('Delete')).toBeEnabled();
149-
await invitationCard.click();
143+
await page.getByRole('menuitem', { name: 'Remove access' }).click();
144+
await expect(invitationCard).toBeHidden();
150145

151146
const memberCard = shareModal.getByLabel('List members card');
147+
const roles = memberCard.getByLabel('doc-role-dropdown');
152148
await expect(memberCard).toBeVisible();
153149
await expect(
154150
memberCard.getByText('[email protected]').first(),
155151
).toBeVisible();
156-
await expect(memberCard.getByLabel('doc-role-dropdown')).toBeVisible();
157-
await expect(
158-
memberCard.getByRole('button', { name: 'more_horiz' }),
159-
).toBeVisible();
160-
await memberCard.getByRole('button', { name: 'more_horiz' }).click();
152+
await expect(roles).toBeVisible();
161153

162-
await expect(page.getByLabel('Delete')).toBeEnabled();
154+
await roles.click();
155+
await expect(
156+
page.getByRole('menuitem', { name: 'Remove access' }),
157+
).toBeEnabled();
163158
});
164159

165160
test('it checks the options available if editor', async ({ page }) => {

0 commit comments

Comments
 (0)