|
|
|
@ -31,7 +31,6 @@ export class FieldsPage extends BasePage {
|
|
|
|
|
|
|
|
|
|
async clickNewField() { |
|
|
|
|
await this.addNewFieldButton.click(); |
|
|
|
|
await this.addOrEditColumn.waitFor({ state: 'visible' }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async create({ |
|
|
|
@ -68,17 +67,9 @@ export class FieldsPage extends BasePage {
|
|
|
|
|
insertBelowColumnTitle?: string; |
|
|
|
|
}) { |
|
|
|
|
if (insertAboveColumnTitle) { |
|
|
|
|
await this.grid.get().locator(`th[data-title="${insertBeforeColumnTitle}"] .nc-ui-dt-dropdown`).click(); |
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
await this.selectFieldAction({ title: insertAboveColumnTitle, action: 'insert-above' }); |
|
|
|
|
} else if (insertBelowColumnTitle) { |
|
|
|
|
await this.grid.get().locator(`th[data-title="${insertAfterColumnTitle}"] .nc-ui-dt-dropdown`).click(); |
|
|
|
|
await this.rootPage.locator('li[role="menuitem"]:has-text("Insert After"):visible').click(); |
|
|
|
|
await this.selectFieldAction({ title: insertBelowColumnTitle, action: 'insert-below' }); |
|
|
|
|
} else { |
|
|
|
|
await this.clickNewField(); |
|
|
|
|
} |
|
|
|
@ -96,7 +87,7 @@ export class FieldsPage extends BasePage {
|
|
|
|
|
break; |
|
|
|
|
case 'Duration': |
|
|
|
|
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 |
|
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
|
hasText: format, |
|
|
|
@ -105,30 +96,30 @@ export class FieldsPage extends BasePage {
|
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
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('.ant-select-item').locator(`text="${dateFormat}"`).click(); |
|
|
|
|
break; |
|
|
|
|
case 'DateTime': |
|
|
|
|
// 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(); |
|
|
|
|
// 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(); |
|
|
|
|
break; |
|
|
|
|
case 'Formula': |
|
|
|
|
await this.get().locator('.nc-formula-input').fill(formula); |
|
|
|
|
await this.addOrEditColumn.locator('.nc-formula-input').fill(formula); |
|
|
|
|
break; |
|
|
|
|
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 |
|
|
|
|
.locator(`.ant-select-item`) |
|
|
|
|
.locator(`[data-testid="nc-qr-${qrCodeValueColumnTitle}"]`) |
|
|
|
|
.click(); |
|
|
|
|
break; |
|
|
|
|
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 |
|
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
|
hasText: new RegExp(`^${barcodeValueColumnTitle}$`), |
|
|
|
@ -136,13 +127,13 @@ export class FieldsPage extends BasePage {
|
|
|
|
|
.click(); |
|
|
|
|
break; |
|
|
|
|
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 |
|
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
|
hasText: childTable, |
|
|
|
|
}) |
|
|
|
|
.click(); |
|
|
|
|
await this.get().locator('.ant-select-single').nth(2).click(); |
|
|
|
|
await this.addOrEditColumn.locator('.ant-select-single').nth(2).click(); |
|
|
|
|
await this.rootPage |
|
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
|
hasText: childColumn, |
|
|
|
@ -151,19 +142,19 @@ export class FieldsPage extends BasePage {
|
|
|
|
|
.click(); |
|
|
|
|
break; |
|
|
|
|
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 |
|
|
|
|
.locator(`.ant-select-item`, { |
|
|
|
|
hasText: childTable, |
|
|
|
|
}) |
|
|
|
|
.click(); |
|
|
|
|
await this.get().locator('.ant-select-single').nth(2).click(); |
|
|
|
|
await this.addOrEditColumn.locator('.ant-select-single').nth(2).click(); |
|
|
|
|
await this.rootPage |
|
|
|
|
.locator(`.nc-dropdown-relation-column >> .ant-select-item`, { |
|
|
|
|
hasText: childColumn, |
|
|
|
|
}) |
|
|
|
|
.click(); |
|
|
|
|
await this.get().locator('.ant-select-single').nth(3).click(); |
|
|
|
|
await this.addOrEditColumn.locator('.ant-select-single').nth(3).click(); |
|
|
|
|
await this.rootPage |
|
|
|
|
.locator(`.nc-dropdown-rollup-function >> .ant-select-item`, { |
|
|
|
|
hasText: rollupType, |
|
|
|
@ -172,11 +163,11 @@ export class FieldsPage extends BasePage {
|
|
|
|
|
.click(); |
|
|
|
|
break; |
|
|
|
|
case 'Links': |
|
|
|
|
await this.get() |
|
|
|
|
await this.addOrEditColumn |
|
|
|
|
.locator('.nc-ltar-relation-type >> .ant-radio') |
|
|
|
|
.nth(relationType === 'Has Many' ? 0 : 1) |
|
|
|
|
.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-dropdown-ltar-child-table >> .ant-select-item`, { |
|
|
|
@ -193,37 +184,36 @@ export class FieldsPage extends BasePage {
|
|
|
|
|
|
|
|
|
|
await this.saveChanges(); |
|
|
|
|
|
|
|
|
|
const headersText = []; |
|
|
|
|
const locator = this.grid.get().locator(`th`); |
|
|
|
|
const fieldsText = []; |
|
|
|
|
const locator = this.fieldListWrapper.locator('>div'); |
|
|
|
|
const count = await locator.count(); |
|
|
|
|
for (let i = 0; i < count; i++) { |
|
|
|
|
const header = locator.nth(i); |
|
|
|
|
const text = await getTextExcludeIconText(header); |
|
|
|
|
headersText.push(text); |
|
|
|
|
const text = await locator.nth(i).getByTestId('nc-field-title').textContent(); |
|
|
|
|
fieldsText.push(text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// verify column inserted after the target column
|
|
|
|
|
// verify field inserted above the target field
|
|
|
|
|
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) { |
|
|
|
|
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 }) { |
|
|
|
|
const fieldTitleInput = this.get().locator('.nc-fields-input'); |
|
|
|
|
const fieldTitleInput = this.addOrEditColumn.locator('.nc-fields-input'); |
|
|
|
|
await fieldTitleInput.click(); |
|
|
|
|
await fieldTitleInput.fill(title); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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.get().locator('.ant-select-selection-search-input[aria-expanded="true"]').fill(type); |
|
|
|
|
await this.addOrEditColumn.locator('.ant-select-selection-search-input[aria-expanded="true"]').waitFor(); |
|
|
|
|
await this.addOrEditColumn.locator('.ant-select-selection-search-input[aria-expanded="true"]').fill(type); |
|
|
|
|
|
|
|
|
|
// Select column type
|
|
|
|
|
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 }) { |
|
|
|
|
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' }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|