Browse Source

test: fix flakiness

pull/6360/head
DarkPhoenix2704 11 months ago
parent
commit
4ed5c119a4
  1. 2
      packages/nc-gui/components/virtual-cell/components/ListItem.vue
  2. 3
      packages/nc-gui/components/virtual-cell/components/ListItems.vue
  3. 38
      tests/playwright/pages/Dashboard/Grid/Column/LTAR/ChildList.ts
  4. 14
      tests/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts

2
packages/nc-gui/components/virtual-cell/components/ListItem.vue

@ -67,7 +67,7 @@ const attachments: Attachment[] = computed(() => {
</div>
<div class="flex flex-col gap-1 flex-grow justify-center">
<div class="flex justify-between">
<span class="font-bold text-gray-800 ml-1"> {{ row[relatedTableDisplayValueProp] }} </span>
<span class="font-bold text-gray-800 ml-1 nc-display-value"> {{ row[relatedTableDisplayValueProp] }} </span>
<MdiCheck
v-if="isLinked"
:class="{

3
packages/nc-gui/components/virtual-cell/components/ListItems.vue

@ -157,7 +157,7 @@ watch(expandedFormDlg, () => {
ref="filterQueryRef"
v-model:value="childrenExcludedListPagination.query"
:placeholder="`Search in ${relatedTableMeta?.title}`"
class="w-full !rounded-md"
class="w-full !rounded-md nc-excluded-search"
size="small"
:bordered="false"
@focus="isFocused = true"
@ -191,6 +191,7 @@ watch(expandedFormDlg, () => {
<div class="pb-2 pt-1">
<div class="h-[420px] overflow-scroll nc-scrollbar-md pr-1 cursor-pointer">
<LazyVirtualCellComponentsListItem
data-testid="nc-excluded-list-item"
v-for="(refRow, id) in childrenExcludedList?.list ?? []"
:key="id"
:row="refRow"

38
tests/playwright/pages/Dashboard/Grid/Column/LTAR/ChildList.ts

@ -19,26 +19,36 @@ export class ChildList extends BasePage {
// title: Child list
// button: Link to 'City'
// icon: reload
await expect(this.get().locator(`.ant-modal-title`)).toHaveText(`Child list`);
expect(await this.get().locator(`text=/Link to '.*${linkField}'/i`).isVisible()).toBeTruthy();
expect(await this.get().locator(`[data-testid="nc-child-list-reload"]`).isVisible()).toBeTruthy();
// child list body validation (card count, card title)
const cardCount = cardTitle.length;
await this.get().locator('.ant-modal-content').waitFor();
{
const childList = this.get().locator(`.ant-card`);
const childCards = await childList.count();
expect(childCards).toEqual(cardCount);
let isOk = false;
let count = 0;
let childList;
while (!isOk && count < 5) {
try {
childList = this.get().getByTestId('nc-child-list-item');
const childCards = await childList.count();
if (childCards === cardCount) {
isOk = true;
}
} catch (e) {
await this.rootPage.waitForTimeout(100);
} finally {
count++;
}
}
expect(childList).toBeDefined();
for (let i = 0; i < cardCount; i++) {
await childList.nth(i).locator('.name').waitFor({ state: 'visible' });
await childList.nth(i).locator('.name').scrollIntoViewIfNeeded();
await childList.nth(i).locator('.nc-display-value').waitFor({ state: 'visible' });
await childList.nth(i).locator('.nc-display-value').scrollIntoViewIfNeeded();
await this.rootPage.waitForTimeout(100);
expect(await childList.nth(i).locator('.name').textContent()).toContain(cardTitle[i]);
// icon: unlink
// icon: delete
expect(await childList.nth(i).locator(`[data-testid="nc-child-list-icon-unlink"]`).isVisible()).toBeTruthy();
expect(await childList.nth(i).locator(`[data-testid="nc-child-list-icon-delete"]`).isVisible()).toBeTruthy();
expect(await childList.nth(i).locator('.nc-display-value').textContent()).toContain(cardTitle[i]);
}
}
}
@ -49,7 +59,7 @@ export class ChildList extends BasePage {
}
async openLinkRecord({ linkTableTitle }: { linkTableTitle: string }) {
const openActions = () => this.get().locator(`text=/Link to '.*${linkTableTitle}'/i`).click();
const openActions = () => this.get().getByTestId('nc-child-list-button-link-to').click();
await this.waitForResponse({
requestUrlPathToMatch: '/exclude',
httpMethodsToMatch: ['GET'],

14
tests/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts

@ -18,20 +18,18 @@ export class LinkRecord extends BasePage {
// title: Link Record
// button: Add new record
// icon: reload
await expect(this.get().locator(`.ant-modal-title`)).toHaveText(`Link record`);
expect(await linkRecord.locator(`button:has-text("Add new record")`).isVisible()).toBeTruthy();
expect(await linkRecord.locator(`.nc-reload`).isVisible()).toBeTruthy();
expect(await linkRecord.locator(`button:has-text("New record")`).isVisible()).toBeTruthy();
// placeholder: Filter query
expect(await linkRecord.locator(`[placeholder="Filter query"]`).isVisible()).toBeTruthy();
expect(await linkRecord.locator('.nc-excluded-search').isVisible()).toBeTruthy();
{
const childList = linkRecord.locator(`.ant-card`);
const childList = linkRecord.getByTestId(`nc-excluded-list-item`);
const childCards = await childList.count();
expect(childCards).toEqual(cardTitle.length);
for (let i = 0; i < cardTitle.length; i++) {
await childList.nth(i).locator('.name').scrollIntoViewIfNeeded();
await childList.nth(i).locator('.name').waitFor({ state: 'visible' });
expect(await childList.nth(i).locator('.name').textContent()).toContain(cardTitle[i]);
await childList.nth(i).locator('.nc-display-value').scrollIntoViewIfNeeded();
await childList.nth(i).locator('.nc-display-value').waitFor({ state: 'visible' });
expect(await childList.nth(i).locator('.nc-display-value').textContent()).toContain(cardTitle[i]);
}
}
}

Loading…
Cancel
Save