Browse Source

test: fix flakiness

pull/6360/head
DarkPhoenix2704 1 year 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>
<div class="flex flex-col gap-1 flex-grow justify-center"> <div class="flex flex-col gap-1 flex-grow justify-center">
<div class="flex justify-between"> <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 <MdiCheck
v-if="isLinked" v-if="isLinked"
:class="{ :class="{

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

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

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

@ -19,26 +19,36 @@ export class ChildList extends BasePage {
// title: Child list // title: Child list
// button: Link to 'City' // button: Link to 'City'
// icon: reload // 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) // child list body validation (card count, card title)
const cardCount = cardTitle.length; const cardCount = cardTitle.length;
await this.get().locator('.ant-modal-content').waitFor(); await this.get().locator('.ant-modal-content').waitFor();
{ {
const childList = this.get().locator(`.ant-card`); let isOk = false;
const childCards = await childList.count(); let count = 0;
expect(childCards).toEqual(cardCount); 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++) { for (let i = 0; i < cardCount; i++) {
await childList.nth(i).locator('.name').waitFor({ state: 'visible' }); await childList.nth(i).locator('.nc-display-value').waitFor({ state: 'visible' });
await childList.nth(i).locator('.name').scrollIntoViewIfNeeded(); await childList.nth(i).locator('.nc-display-value').scrollIntoViewIfNeeded();
await this.rootPage.waitForTimeout(100); await this.rootPage.waitForTimeout(100);
expect(await childList.nth(i).locator('.name').textContent()).toContain(cardTitle[i]); expect(await childList.nth(i).locator('.nc-display-value').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();
} }
} }
} }
@ -49,7 +59,7 @@ export class ChildList extends BasePage {
} }
async openLinkRecord({ linkTableTitle }: { linkTableTitle: string }) { 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({ await this.waitForResponse({
requestUrlPathToMatch: '/exclude', requestUrlPathToMatch: '/exclude',
httpMethodsToMatch: ['GET'], httpMethodsToMatch: ['GET'],

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

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

Loading…
Cancel
Save