Browse Source

test(playwright): add method to verify selected options

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4406/head
Pranav C 2 years ago
parent
commit
7d5fb68d2e
  1. 3
      packages/nc-gui/components/cell/MultiSelect.vue
  2. 25
      tests/playwright/pages/Dashboard/common/Cell/SelectOptionCell.ts
  3. 7
      tests/playwright/tests/columnMultiSelect.spec.ts

3
packages/nc-gui/components/cell/MultiSelect.vue

@ -212,6 +212,7 @@ async function addIfMissingAndSave() {
vModel.value = [...vModel.value]; vModel.value = [...vModel.value];
tempVal.splice(0, tempVal.length); tempVal.splice(0, tempVal.length);
} }
} else { } else {
activeOptCreateInProgress.value-- activeOptCreateInProgress.value--
} }
@ -281,7 +282,7 @@ const search = () => {
<template #tagRender="{ value: val, onClose }"> <template #tagRender="{ value: val, onClose }">
<a-tag <a-tag
v-if="options.find((el) => el.title === val)" v-if="options.find((el) => el.title === val)"
class="rounded-tag" class="rounded-tag nc-selected-option"
:style="{ display: 'flex', alignItems: 'center' }" :style="{ display: 'flex', alignItems: 'center' }"
:color="options.find((el) => el.title === val)?.color" :color="options.find((el) => el.title === val)?.color"
:closable="(active || editable) && (vModel.length > 1 || !column?.rqd)" :closable="(active || editable) && (vModel.length > 1 || !column?.rqd)"

25
tests/playwright/pages/Dashboard/common/Cell/SelectOptionCell.ts

@ -136,13 +136,24 @@ export class SelectOptionCellPageObject extends BasePage {
await selectCell.locator('.ant-select-selection-search-input').press('Enter'); await selectCell.locator('.ant-select-selection-search-input').press('Enter');
if (multiSelect) await selectCell.locator('.ant-select-selection-search-input').press('Escape'); if (multiSelect) await selectCell.locator('.ant-select-selection-search-input').press('Escape');
// todo: wait for update api call
}
// await this.rootPage.getByTestId(`select-option-${columnHeader}-${index}`).getByText(option).click(); async verifySelectedOptions({
// index,
// options,
// await this.rootPage columnHeader,
// .getByTestId(`select-option-${columnHeader}-${index}`) }: {
// .getByText(option) columnHeader: string;
// .waitFor({ state: 'hidden' }); options: string[];
index: number;
}) {
const selectCell = this.get({ index, columnHeader });
let counter = 0;
for (const option of options) {
await expect(selectCell.locator(`.nc-selected-option`).nth(counter)).toHaveText(option);
counter++;
}
} }
} }

7
tests/playwright/tests/columnMultiSelect.spec.ts

@ -129,7 +129,7 @@ test.describe('Multi select', () => {
await grid.column.delete({ title: 'MultiSelect' }); await grid.column.delete({ title: 'MultiSelect' });
}); });
test.only('Add new option directly from cell', async () => { test('Add new option directly from cell', async () => {
await grid.cell.selectOption.addNewOption({ await grid.cell.selectOption.addNewOption({
index: 0, index: 0,
columnHeader: 'MultiSelect', columnHeader: 'MultiSelect',
@ -144,13 +144,12 @@ test.describe('Multi select', () => {
multiSelect: true, multiSelect: true,
}); });
await grid.cell.selectOption.verifyOptions({ await grid.cell.selectOption.verifySelectedOptions({
index: 0, index: 0,
columnHeader: 'MultiSelect', columnHeader: 'MultiSelect',
options: ['Option added from cell 1', 'Option added from cell 2'], options: ['Option added from cell 1', 'Option added from cell 2'],
}); });
await new Promise(resolve => setTimeout(resolve, 100000));
await grid.column.delete({ title: 'SingleSelect' }); await grid.column.delete({ title: 'MultiSelect' });
}); });
}); });

Loading…
Cancel
Save