🐛(e2e) sync doc grid sorting check

The sorting check was not the same between
what django provide and what the e2e test
check, it was giving some flakiness.
Django seems to ignore the punctuation (space)
in its sorting.
We improve other test to be more robust
as well.
This commit is contained in:
Anthony LC
2024-07-09 13:57:14 +02:00
committed by Anthony LC
parent 164ed885ca
commit 132da0837f
5 changed files with 20 additions and 8 deletions

View File

@@ -120,11 +120,13 @@ export const goToGridDoc = async (
const header = page.locator('header').first();
await header.locator('h2').getByText('Docs').click();
const rows = page
const datagrid = page
.getByLabel('Datagrid of the documents page 1')
.getByRole('table')
.getByRole('row');
.getByRole('table');
await expect(datagrid.getByLabel('Loading data')).toBeHidden();
const rows = datagrid.getByRole('row');
const row = title
? rows.filter({
hasText: title,

View File

@@ -62,6 +62,8 @@ test.describe('Doc Create', () => {
.getByLabel('Datagrid of the documents page 1')
.getByRole('table');
await expect(datagrid.getByLabel('Loading data')).toBeHidden();
await expect(datagrid.getByText(docTitle)).toBeVisible();
const row = datagrid.getByRole('row').filter({

View File

@@ -125,8 +125,10 @@ test.describe('Documents Grid', () => {
expect(
textDocNameRow1Asc &&
textDocNameRow2Asc &&
textDocNameRow1Asc.toLocaleLowerCase() <=
textDocNameRow2Asc.toLocaleLowerCase(),
textDocNameRow1Asc.localeCompare(textDocNameRow2Asc, 'en', {
caseFirst: 'false',
ignorePunctuation: true,
}) <= 0,
).toBeTruthy();
// Ordering Desc
@@ -145,8 +147,10 @@ test.describe('Documents Grid', () => {
expect(
textDocNameRow1Desc &&
textDocNameRow2Desc &&
textDocNameRow1Desc.toLocaleLowerCase() >=
textDocNameRow2Desc.toLocaleLowerCase(),
textDocNameRow1Desc.localeCompare(textDocNameRow2Desc, 'en', {
caseFirst: 'false',
ignorePunctuation: true,
}) >= 0,
).toBeTruthy();
});
});

View File

@@ -90,6 +90,8 @@ test.describe('Document grid members', () => {
await goToGridDoc(page);
await expect(page.locator('h2').getByText('Mocked document')).toBeVisible();
await page.getByLabel('Open the document options').click();
await page.getByRole('button', { name: 'Manage members' }).click();

View File

@@ -123,10 +123,12 @@ test.describe('Doc Tools', () => {
page.getByText('The document has been updated.'),
).toBeVisible();
await goToGridDoc(page, {
const docTitle = await goToGridDoc(page, {
title: `${randomDoc}-updated`,
});
await expect(page.locator('h2').getByText(docTitle)).toBeVisible();
await page.getByLabel('Open the document options').click();
await page
.getByRole('button', {