Skip to content

Commit

Permalink
✨(frontend) enhance document interaction tests
Browse files Browse the repository at this point in the history
- Updated test cases to improve accessibility by replacing 'more_vert'
with 'more_horiz' for action buttons across various components.
- Refactored document deletion confirmation messages to use consistent
heading roles for better visibility.
- Simplified keyboard interactions in document table content tests for
improved clarity.
- Adjusted visibility checks for the share button to utilize more
descriptive labels.
- Cleaned up test code for maintainability and consistency.
  • Loading branch information
PanchoutNathan committed Dec 23, 2024
1 parent b490c07 commit 15f1d05
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ test.describe('Document grid item options', () => {
await removeButton.click();

await expect(
page.locator('h2').getByText(`Deleting the document "${docs[0].title}"`),
page.getByRole('heading', { name: 'Delete a doc' }),
).toBeVisible();

await page
Expand Down
22 changes: 14 additions & 8 deletions src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ test.describe('Doc Header', () => {
.click();

await expect(
page.locator('h2').getByText(`Deleting the document "${randomDoc}"`),
page.getByRole('heading', { name: 'Delete a doc' }),
).toBeVisible();

await expect(
page.getByText(
`Are you sure you want to delete the document "${randomDoc}"?`,
),
).toBeVisible();

await page
Expand Down Expand Up @@ -167,7 +173,7 @@ test.describe('Doc Header', () => {
).toBeVisible();
await expect(invitationCard.getByLabel('doc-role-dropdown')).toBeVisible();

await invitationCard.getByRole('button', { name: 'more_vert' }).click();
await invitationCard.getByRole('button', { name: 'more_horiz' }).click();

await expect(
page.getByRole('button', {
Expand All @@ -183,9 +189,9 @@ test.describe('Doc Header', () => {
).toBeVisible();
await expect(memberCard.getByLabel('doc-role-dropdown')).toBeVisible();
await expect(
memberCard.getByRole('button', { name: 'more_vert' }),
memberCard.getByRole('button', { name: 'more_horiz' }),
).toBeVisible();
await memberCard.getByRole('button', { name: 'more_vert' }).click();
await memberCard.getByRole('button', { name: 'more_horiz' }).click();

await expect(
page.getByRole('button', {
Expand Down Expand Up @@ -245,14 +251,14 @@ test.describe('Doc Header', () => {
).toBeVisible();
await expect(invitationCard.getByLabel('doc-role-text')).toBeVisible();
await expect(
invitationCard.getByRole('button', { name: 'more_vert' }),
invitationCard.getByRole('button', { name: 'more_horiz' }),
).toBeHidden();

const memberCard = shareModal.getByLabel('List members card');
await expect(memberCard.getByText('[email protected]')).toBeVisible();
await expect(memberCard.getByLabel('doc-role-text')).toBeVisible();
await expect(
memberCard.getByRole('button', { name: 'more_vert' }),
memberCard.getByRole('button', { name: 'more_horiz' }),
).toBeHidden();
});

Expand Down Expand Up @@ -307,14 +313,14 @@ test.describe('Doc Header', () => {
).toBeVisible();
await expect(invitationCard.getByLabel('doc-role-text')).toBeVisible();
await expect(
invitationCard.getByRole('button', { name: 'more_vert' }),
invitationCard.getByRole('button', { name: 'more_horiz' }),
).toBeHidden();

const memberCard = shareModal.getByLabel('List members card');
await expect(memberCard.getByText('[email protected]')).toBeVisible();
await expect(memberCard.getByLabel('doc-role-text')).toBeVisible();
await expect(
memberCard.getByRole('button', { name: 'more_vert' }),
memberCard.getByRole('button', { name: 'more_horiz' }),
).toBeHidden();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ test.describe('Document create member', () => {
await page.getByRole('button', { name: 'Reader' }).click();

const moreActions = userInvitation.getByRole('button', {
name: 'more_vert',
name: 'more_horiz',
});
await moreActions.click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,26 +182,28 @@ test.describe('Document list members', () => {

const emailMyself = `user@${browserName}.e2e`;
const mySelf = list.getByTestId(`doc-share-member-row-${emailMyself}`);
const mySelfMoreActions = mySelf.getByRole('button', { name: 'more_vert' });
const mySelfMoreActions = mySelf.getByRole('button', {
name: 'more_horiz',
});

const userOwnerEmail = await addNewMember(page, 0, 'Owner');
const userOwner = list.getByTestId(
`doc-share-member-row-${userOwnerEmail}`,
);
const userOwnerMoreActions = userOwner.getByRole('button', {
name: 'more_vert',
name: 'more_horiz',
});

await page.getByRole('button', { name: 'close' }).first().click();
await page.getByRole('button', { name: 'Share' }).click();
await page.getByRole('button', { name: 'Share' }).first().click();

const userReaderEmail = await addNewMember(page, 0, 'Reader');

const userReader = list.getByTestId(
`doc-share-member-row-${userReaderEmail}`,
);
const userReaderMoreActions = userReader.getByRole('button', {
name: 'more_vert',
name: 'more_horiz',
});

await expect(mySelf).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ test.describe('Doc Table Content', () => {
await page.locator('.bn-block-outer').first().click();
await editor.click();
await page.locator('.bn-block-outer').last().click();

// Create space to fill the viewport
for (let i = 0; i < 2; i++) {
await page.keyboard.press('Enter');
}
await page.keyboard.press('Enter');

await editor.locator('.bn-block-outer').last().fill('/');
await page.getByText('Heading 2').click();
Expand All @@ -44,9 +40,7 @@ test.describe('Doc Table Content', () => {
await page.locator('.bn-block-outer').last().click();

// Create space to fill the viewport
for (let i = 0; i < 2; i++) {
await page.keyboard.press('Enter');
}
await page.keyboard.press('Enter');

await editor.locator('.bn-block-outer').last().fill('/');
await page.getByText('Heading 3').click();
Expand All @@ -55,7 +49,7 @@ test.describe('Doc Table Content', () => {
expect(true).toBe(true);

const summaryContainer = page.locator('#summaryContainer');
await summaryContainer.hover();
await summaryContainer.click();

const level1 = summaryContainer.getByText('Level 1');
const level2 = summaryContainer.getByText('Level 2');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ test.describe('Doc Version', () => {
await expect(panel).toBeVisible();
await expect(modal.getByText('No versions')).toBeVisible();

const editor = page.locator('.ProseMirror');
await modal.getByRole('button', { name: 'close' }).click();
await editor.locator('.bn-block-outer').last().fill('/');
await page.getByText('Heading 1').click();

await page.locator('.ProseMirror.bn-editor').click();
await page.locator('.ProseMirror.bn-editor').last().fill('Hello World');
await goToGridDoc(page, {
Expand Down Expand Up @@ -64,7 +68,7 @@ test.describe('Doc Version', () => {

await expect(panel).toBeVisible();
await expect(page.getByText('History', { exact: true })).toBeVisible();
await expect(page.getByRole('status')).toBeVisible();
// await expect(page.getByRole('status')).toBeVisible();
await expect(page.getByRole('status')).toBeHidden();
const items = await panel.locator('.version-item').all();
expect(items.length).toBe(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ test.describe('Doc Visibility: Restricted', () => {
await page.goto(urlDoc);

await verifyDocName(page, docTitle);
await expect(page.getByRole('button', { name: 'Share' })).toBeVisible();
await expect(page.getByLabel('Share button')).toBeVisible();
});
});

Expand Down

0 comments on commit 15f1d05

Please sign in to comment.