Browse Source

test: select options- move out adding options to test spec

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/4882/head
Raju Udava 2 years ago
parent
commit
5b1265e5a6
  1. 12
      tests/playwright/pages/Dashboard/Grid/Column/SelectOptionColumn.ts
  2. 10
      tests/playwright/pages/Dashboard/Grid/Column/index.ts
  3. 4
      tests/playwright/tests/columnMultiSelect.spec.ts
  4. 4
      tests/playwright/tests/columnSingleSelect.spec.ts

12
tests/playwright/pages/Dashboard/Grid/Column/SelectOptionColumn.ts

@ -36,6 +36,18 @@ export class SelectOptionColumnPageObject extends BasePage {
if (!skipColumnModal && columnTitle) await this.column.save({ isUpdated: true });
}
// add multiple options at once after column creation is completed
//
async addOptions({ columnTitle, options }: { columnTitle: string; options: string[] }) {
await this.column.openEdit({ title: columnTitle });
for (let i = 0; i < options.length; i++) {
await this.column.get().locator('button:has-text("Add option")').click();
await this.column.get().locator(`[data-testid="select-column-option-input-${i}"]`).click();
await this.column.get().locator(`[data-testid="select-column-option-input-${i}"]`).fill(options[i]);
}
await this.column.save({ isUpdated: true });
}
async editOption({ columnTitle, index, newOption }: { index: number; columnTitle: string; newOption: string }) {
await this.column.openEdit({ title: columnTitle });

10
tests/playwright/pages/Dashboard/Grid/Column/index.ts

@ -77,16 +77,6 @@ export class ColumnPageObject extends BasePage {
switch (type) {
case 'SingleSelect':
case 'MultiSelect':
await this.selectOption.addOption({
index: 0,
option: 'Option 1',
skipColumnModal: true,
});
await this.selectOption.addOption({
index: 1,
option: 'Option 2',
skipColumnModal: true,
});
break;
case 'Duration':
if (format) {

4
tests/playwright/tests/columnMultiSelect.spec.ts

@ -15,6 +15,10 @@ test.describe('Multi select', () => {
await dashboard.treeView.createTable({ title: 'sheet1' });
await grid.column.create({ title: 'MultiSelect', type: 'MultiSelect' });
await grid.column.selectOption.addOptions({
columnTitle: 'MultiSelect',
options: ['Option 1', 'Option 2'],
});
await grid.addNewRow({ index: 0, value: 'Row 0' });
});

4
tests/playwright/tests/columnSingleSelect.spec.ts

@ -15,6 +15,10 @@ test.describe('Single select', () => {
await dashboard.treeView.createTable({ title: 'sheet1' });
await grid.column.create({ title: 'SingleSelect', type: 'SingleSelect' });
await grid.column.selectOption.addOptions({
columnTitle: 'SingleSelect',
options: ['Option 1', 'Option 2'],
});
await grid.addNewRow({ index: 0, value: 'Row 0' });
});

Loading…
Cancel
Save