|
|
@ -31,7 +31,6 @@ export class FieldsPage extends BasePage { |
|
|
|
|
|
|
|
|
|
|
|
async clickNewField() { |
|
|
|
async clickNewField() { |
|
|
|
await this.addNewFieldButton.click(); |
|
|
|
await this.addNewFieldButton.click(); |
|
|
|
await this.addOrEditColumn.waitFor({ state: 'visible' }); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async create({ |
|
|
|
async create({ |
|
|
@ -68,17 +67,9 @@ export class FieldsPage extends BasePage { |
|
|
|
insertBelowColumnTitle?: string; |
|
|
|
insertBelowColumnTitle?: string; |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
if (insertAboveColumnTitle) { |
|
|
|
if (insertAboveColumnTitle) { |
|
|
|
await this.grid.get().locator(`th[data-title="${insertBeforeColumnTitle}"] .nc-ui-dt-dropdown`).click(); |
|
|
|
await this.selectFieldAction({ title: insertAboveColumnTitle, action: 'insert-above' }); |
|
|
|
|
|
|
|
|
|
|
|
if (isDisplayValue) { |
|
|
|
|
|
|
|
await expect(this.rootPage.locator('li[role="menuitem"]:has-text("Insert Before")')).toHaveCount(0); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.rootPage.locator('li[role="menuitem"]:has-text("Insert Before"):visible').click(); |
|
|
|
|
|
|
|
} else if (insertBelowColumnTitle) { |
|
|
|
} else if (insertBelowColumnTitle) { |
|
|
|
await this.grid.get().locator(`th[data-title="${insertAfterColumnTitle}"] .nc-ui-dt-dropdown`).click(); |
|
|
|
await this.selectFieldAction({ title: insertBelowColumnTitle, action: 'insert-below' }); |
|
|
|
await this.rootPage.locator('li[role="menuitem"]:has-text("Insert After"):visible').click(); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
await this.clickNewField(); |
|
|
|
await this.clickNewField(); |
|
|
|
} |
|
|
|
} |
|
|
@ -96,7 +87,7 @@ export class FieldsPage extends BasePage { |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'Duration': |
|
|
|
case 'Duration': |
|
|
|
if (format) { |
|
|
|
if (format) { |
|
|
|
await this.get().locator('.ant-select-single').nth(1).click(); |
|
|
|
await this.addOrEditColumn.locator('.ant-select-single').nth(1).click(); |
|
|
|
await this.rootPage |
|
|
|
await this.rootPage |
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
hasText: format, |
|
|
|
hasText: format, |
|
|
@ -105,30 +96,30 @@ export class FieldsPage extends BasePage { |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'Date': |
|
|
|
case 'Date': |
|
|
|
await this.get().locator('.nc-date-select').click(); |
|
|
|
await this.addOrEditColumn.locator('.nc-date-select').click(); |
|
|
|
await this.rootPage.locator('.nc-date-select').pressSequentially(dateFormat); |
|
|
|
await this.rootPage.locator('.nc-date-select').pressSequentially(dateFormat); |
|
|
|
await this.rootPage.locator('.ant-select-item').locator(`text="${dateFormat}"`).click(); |
|
|
|
await this.rootPage.locator('.ant-select-item').locator(`text="${dateFormat}"`).click(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'DateTime': |
|
|
|
case 'DateTime': |
|
|
|
// Date Format
|
|
|
|
// Date Format
|
|
|
|
await this.get().locator('.nc-date-select').click(); |
|
|
|
await this.addOrEditColumn.locator('.nc-date-select').click(); |
|
|
|
await this.rootPage.locator('.ant-select-item').locator(`text="${dateFormat}"`).click(); |
|
|
|
await this.rootPage.locator('.ant-select-item').locator(`text="${dateFormat}"`).click(); |
|
|
|
// Time Format
|
|
|
|
// Time Format
|
|
|
|
await this.get().locator('.nc-time-select').click(); |
|
|
|
await this.addOrEditColumn.locator('.nc-time-select').click(); |
|
|
|
await this.rootPage.locator('.ant-select-item').locator(`text="${timeFormat}"`).click(); |
|
|
|
await this.rootPage.locator('.ant-select-item').locator(`text="${timeFormat}"`).click(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'Formula': |
|
|
|
case 'Formula': |
|
|
|
await this.get().locator('.nc-formula-input').fill(formula); |
|
|
|
await this.addOrEditColumn.locator('.nc-formula-input').fill(formula); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'QrCode': |
|
|
|
case 'QrCode': |
|
|
|
await this.get().locator('.ant-select-single').nth(1).click(); |
|
|
|
await this.addOrEditColumn.locator('.ant-select-single').nth(1).click(); |
|
|
|
await this.rootPage |
|
|
|
await this.rootPage |
|
|
|
.locator(`.ant-select-item`) |
|
|
|
.locator(`.ant-select-item`) |
|
|
|
.locator(`[data-testid="nc-qr-${qrCodeValueColumnTitle}"]`) |
|
|
|
.locator(`[data-testid="nc-qr-${qrCodeValueColumnTitle}"]`) |
|
|
|
.click(); |
|
|
|
.click(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'Barcode': |
|
|
|
case 'Barcode': |
|
|
|
await this.get().locator('.ant-select-single').nth(1).click(); |
|
|
|
await this.addOrEditColumn.locator('.ant-select-single').nth(1).click(); |
|
|
|
await this.rootPage |
|
|
|
await this.rootPage |
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
hasText: new RegExp(`^${barcodeValueColumnTitle}$`), |
|
|
|
hasText: new RegExp(`^${barcodeValueColumnTitle}$`), |
|
|
@ -136,13 +127,13 @@ export class FieldsPage extends BasePage { |
|
|
|
.click(); |
|
|
|
.click(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'Lookup': |
|
|
|
case 'Lookup': |
|
|
|
await this.get().locator('.ant-select-single').nth(1).click(); |
|
|
|
await this.addOrEditColumn.locator('.ant-select-single').nth(1).click(); |
|
|
|
await this.rootPage |
|
|
|
await this.rootPage |
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
hasText: childTable, |
|
|
|
hasText: childTable, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.click(); |
|
|
|
.click(); |
|
|
|
await this.get().locator('.ant-select-single').nth(2).click(); |
|
|
|
await this.addOrEditColumn.locator('.ant-select-single').nth(2).click(); |
|
|
|
await this.rootPage |
|
|
|
await this.rootPage |
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
hasText: childColumn, |
|
|
|
hasText: childColumn, |
|
|
@ -151,19 +142,19 @@ export class FieldsPage extends BasePage { |
|
|
|
.click(); |
|
|
|
.click(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'Rollup': |
|
|
|
case 'Rollup': |
|
|
|
await this.get().locator('.ant-select-single').nth(1).click(); |
|
|
|
await this.addOrEditColumn.locator('.ant-select-single').nth(1).click(); |
|
|
|
await this.rootPage |
|
|
|
await this.rootPage |
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
hasText: childTable, |
|
|
|
hasText: childTable, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.click(); |
|
|
|
.click(); |
|
|
|
await this.get().locator('.ant-select-single').nth(2).click(); |
|
|
|
await this.addOrEditColumn.locator('.ant-select-single').nth(2).click(); |
|
|
|
await this.rootPage |
|
|
|
await this.rootPage |
|
|
|
.locator(`.nc-dropdown-relation-column >> .ant-select-item`, { |
|
|
|
.locator(`.nc-dropdown-relation-column >> .ant-select-item`, { |
|
|
|
hasText: childColumn, |
|
|
|
hasText: childColumn, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.click(); |
|
|
|
.click(); |
|
|
|
await this.get().locator('.ant-select-single').nth(3).click(); |
|
|
|
await this.addOrEditColumn.locator('.ant-select-single').nth(3).click(); |
|
|
|
await this.rootPage |
|
|
|
await this.rootPage |
|
|
|
.locator(`.nc-dropdown-rollup-function >> .ant-select-item`, { |
|
|
|
.locator(`.nc-dropdown-rollup-function >> .ant-select-item`, { |
|
|
|
hasText: rollupType, |
|
|
|
hasText: rollupType, |
|
|
@ -172,11 +163,11 @@ export class FieldsPage extends BasePage { |
|
|
|
.click(); |
|
|
|
.click(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'Links': |
|
|
|
case 'Links': |
|
|
|
await this.get() |
|
|
|
await this.addOrEditColumn |
|
|
|
.locator('.nc-ltar-relation-type >> .ant-radio') |
|
|
|
.locator('.nc-ltar-relation-type >> .ant-radio') |
|
|
|
.nth(relationType === 'Has Many' ? 0 : 1) |
|
|
|
.nth(relationType === 'Has Many' ? 0 : 1) |
|
|
|
.click(); |
|
|
|
.click(); |
|
|
|
await this.get().locator('.ant-select-single').nth(1).click(); |
|
|
|
await this.addOrEditColumn.locator('.ant-select-single').nth(1).click(); |
|
|
|
await this.rootPage.locator(`.nc-ltar-child-table >> input[type="search"]`).fill(childTable); |
|
|
|
await this.rootPage.locator(`.nc-ltar-child-table >> input[type="search"]`).fill(childTable); |
|
|
|
await this.rootPage |
|
|
|
await this.rootPage |
|
|
|
.locator(`.nc-dropdown-ltar-child-table >> .ant-select-item`, { |
|
|
|
.locator(`.nc-dropdown-ltar-child-table >> .ant-select-item`, { |
|
|
@ -193,37 +184,36 @@ export class FieldsPage extends BasePage { |
|
|
|
|
|
|
|
|
|
|
|
await this.saveChanges(); |
|
|
|
await this.saveChanges(); |
|
|
|
|
|
|
|
|
|
|
|
const headersText = []; |
|
|
|
const fieldsText = []; |
|
|
|
const locator = this.grid.get().locator(`th`); |
|
|
|
const locator = this.fieldListWrapper.locator('>div'); |
|
|
|
const count = await locator.count(); |
|
|
|
const count = await locator.count(); |
|
|
|
for (let i = 0; i < count; i++) { |
|
|
|
for (let i = 0; i < count; i++) { |
|
|
|
const header = locator.nth(i); |
|
|
|
const text = await locator.nth(i).getByTestId('nc-field-title').textContent(); |
|
|
|
const text = await getTextExcludeIconText(header); |
|
|
|
fieldsText.push(text); |
|
|
|
headersText.push(text); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// verify column inserted after the target column
|
|
|
|
// verify field inserted above the target field
|
|
|
|
if (insertAboveColumnTitle) { |
|
|
|
if (insertAboveColumnTitle) { |
|
|
|
expect(headersText[headersText.findIndex(title => title.startsWith(insertAboveColumnTitle)) + 1]).toBe(title); |
|
|
|
expect(fieldsText[fieldsText.findIndex(title => title.startsWith(insertAboveColumnTitle)) - 1]).toBe(title); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// verify column inserted before the target column
|
|
|
|
// verify field inserted below the target field
|
|
|
|
if (insertBelowColumnTitle) { |
|
|
|
if (insertBelowColumnTitle) { |
|
|
|
expect(headersText[headersText.findIndex(title => title.startsWith(insertAboveColumnTitle)) - 1]).toBe(title); |
|
|
|
expect(fieldsText[fieldsText.findIndex(title => title.startsWith(insertAboveColumnTitle)) + 1]).toBe(title); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async fillTitle({ title }: { title: string }) { |
|
|
|
async fillTitle({ title }: { title: string }) { |
|
|
|
const fieldTitleInput = this.get().locator('.nc-fields-input'); |
|
|
|
const fieldTitleInput = this.addOrEditColumn.locator('.nc-fields-input'); |
|
|
|
await fieldTitleInput.click(); |
|
|
|
await fieldTitleInput.click(); |
|
|
|
await fieldTitleInput.fill(title); |
|
|
|
await fieldTitleInput.fill(title); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async selectType({ type }: { type: string }) { |
|
|
|
async selectType({ type }: { type: string }) { |
|
|
|
await this.get().locator('.ant-select-selector > .ant-select-selection-item').click(); |
|
|
|
await this.addOrEditColumn.locator('.ant-select-selector > .ant-select-selection-item').click(); |
|
|
|
|
|
|
|
|
|
|
|
await this.get().locator('.ant-select-selection-search-input[aria-expanded="true"]').waitFor(); |
|
|
|
await this.addOrEditColumn.locator('.ant-select-selection-search-input[aria-expanded="true"]').waitFor(); |
|
|
|
await this.get().locator('.ant-select-selection-search-input[aria-expanded="true"]').fill(type); |
|
|
|
await this.addOrEditColumn.locator('.ant-select-selection-search-input[aria-expanded="true"]').fill(type); |
|
|
|
|
|
|
|
|
|
|
|
// Select column type
|
|
|
|
// Select column type
|
|
|
|
await this.rootPage.locator('.rc-virtual-list-holder-inner > div').locator(`text="${type}"`).click(); |
|
|
|
await this.rootPage.locator('.rc-virtual-list-holder-inner > div').locator(`text="${type}"`).click(); |
|
|
@ -241,4 +231,32 @@ export class FieldsPage extends BasePage { |
|
|
|
async getField({ title }: { title: string }) { |
|
|
|
async getField({ title }: { title: string }) { |
|
|
|
return this.fieldListWrapper.getByTestId('nc-field-title').locator(`text=${title}`); |
|
|
|
return this.fieldListWrapper.getByTestId('nc-field-title').locator(`text=${title}`); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async getFieldVisibilityCheckbox({ title }: { title: string }) { |
|
|
|
|
|
|
|
return (await this.getField({ title })).getByTestId('nc-field-visibility-checkbox'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async selectFieldAction({ |
|
|
|
|
|
|
|
title, |
|
|
|
|
|
|
|
action, |
|
|
|
|
|
|
|
isDisplayValueField = false, |
|
|
|
|
|
|
|
}: { |
|
|
|
|
|
|
|
title: string; |
|
|
|
|
|
|
|
action: 'copy-id' | 'duplicate' | 'insert-above' | 'insert-below' | 'delete'; |
|
|
|
|
|
|
|
isDisplayValueField?: boolean; |
|
|
|
|
|
|
|
}) { |
|
|
|
|
|
|
|
const field = await this.getField({ title }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await field.hover(); |
|
|
|
|
|
|
|
await field.getByTestId('nc-field-item-action-button').waitFor({ state: 'visible' }); |
|
|
|
|
|
|
|
await field.getByTestId('nc-field-item-action-button').click(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fieldActionDropdown = isDisplayValueField |
|
|
|
|
|
|
|
? this.rootPage.locator('.nc-field-item-action-dropdown-display-column') |
|
|
|
|
|
|
|
: this.rootPage.locator('.nc-field-item-action-dropdown'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await fieldActionDropdown.waitFor({ state: 'visible' }); |
|
|
|
|
|
|
|
await fieldActionDropdown.getByTestId(`nc-field-item-action-${action}`).click(); |
|
|
|
|
|
|
|
await fieldActionDropdown.waitFor({ state: 'hidden' }); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|