From 4f1d43d6ad50a75b578afe7eedfb19174bebf6d8 Mon Sep 17 00:00:00 2001 From: tkleinke Date: Fri, 10 Nov 2023 16:18:16 +0100 Subject: [PATCH] Add e2e test for solving warning for outlier values via resources view --- .../docedit/core/forms/widgets/outliers.html | 2 +- desktop/test/e2e/docedit/docedit.page.ts | 26 ++++++-- desktop/test/e2e/warnings/warnings.spec.ts | 65 ++++++++++++++++++- 3 files changed, 85 insertions(+), 8 deletions(-) diff --git a/desktop/src/app/components/docedit/core/forms/widgets/outliers.html b/desktop/src/app/components/docedit/core/forms/widgets/outliers.html index b271a3909f..170de2b67f 100644 --- a/desktop/src/app/components/docedit/core/forms/widgets/outliers.html +++ b/desktop/src/app/components/docedit/core/forms/widgets/outliers.html @@ -6,7 +6,7 @@
-
diff --git a/desktop/test/e2e/docedit/docedit.page.ts b/desktop/test/e2e/docedit/docedit.page.ts index c325117981..c610a42f83 100644 --- a/desktop/test/e2e/docedit/docedit.page.ts +++ b/desktop/test/e2e/docedit/docedit.page.ts @@ -139,16 +139,20 @@ export class DoceditPage { public static async clickCheckbox(fieldName: string, checkboxIndex: number) { - await waitForExist('#edit-form-element-' + fieldName); - const element = ((await this.getField(fieldName)).locator('.checkbox')).nth(checkboxIndex); + const field = await this.getField(fieldName); + await waitForExist(field); + + const element = await (await field.locator('.checkbox')).nth(checkboxIndex); return click(element); } public static async clickBooleanRadioButton(fieldName: string, radioButtonIndex: number) { - await waitForExist('#edit-form-element-' + fieldName); - const element = ((await this.getField(fieldName)).locator('input')).nth(radioButtonIndex); + const field = await this.getField(fieldName); + await waitForExist(field); + + const element = await (await field.locator('input')).nth(radioButtonIndex); return click(element); } @@ -171,6 +175,14 @@ export class DoceditPage { } + public static async clickRemoveOutlierValue(fieldName: string, outlierValueIndex: number) { + + const outlierValues = await this.getOutlierValues(fieldName); + const valueToRemove = await outlierValues.nth(outlierValueIndex); + return click(valueToRemove.locator('.remove-outlier-button')); + } + + // get text public static async getSimpleInputFieldValue(index) { @@ -257,6 +269,12 @@ export class DoceditPage { } + public static async getOutlierValues(fieldName: string) { + + return (await this.getField(fieldName)).locator('.outlier'); + } + + // type in public static async typeInInputField(fieldName: string, text: string) { diff --git a/desktop/test/e2e/warnings/warnings.spec.ts b/desktop/test/e2e/warnings/warnings.spec.ts index 58a65599e4..5dcb610ce2 100644 --- a/desktop/test/e2e/warnings/warnings.spec.ts +++ b/desktop/test/e2e/warnings/warnings.spec.ts @@ -1,3 +1,4 @@ +import { Field } from 'idai-field-core'; import { NavbarPage } from '../navbar.page'; import { ResourcesPage } from '../resources/resources.page'; import { navigateTo, resetApp, start, stop, waitForExist, waitForNotExist } from '../app'; @@ -8,6 +9,7 @@ import { DoceditPage } from '../docedit/docedit.page'; import { WarningsModalPage } from './warnings-modal.page'; import { AddFieldModalPage } from '../configuration/add-field-modal.page'; import { DeleteFieldDataModalPage } from './delete-field-data-modal.page'; +import { ManageValuelistsModalPage } from '../configuration/manage-valuelists-modal.page'; const { test, expect } = require('@playwright/test'); @@ -46,8 +48,8 @@ test.describe('warnings --', () => { const completeFieldName: string = 'test:' + fieldName; await NavbarPage.clickCloseNonResourcesTab(); - for (let identifer of resourceIdentifiers) { - await ResourcesPage.performCreateResource(identifer, 'place', completeFieldName, 'Text'); + for (let identifier of resourceIdentifiers) { + await ResourcesPage.performCreateResource(identifier, 'place', completeFieldName, 'Text'); } await navigateTo('configuration'); @@ -85,6 +87,36 @@ test.describe('warnings --', () => { }; + async function createOutlierValuesWarnings(resourceIdentifiers: string[], fieldName: string) { + + await navigateTo('configuration'); + await createField(fieldName, 'checkboxes', 'Wood-color-default'); + + const completeFieldName: string = 'test:' + fieldName; + + await NavbarPage.clickCloseNonResourcesTab(); + for (let identifier of resourceIdentifiers) { + await ResourcesPage.performCreateResource(identifier, 'place'); + await ResourcesPage.openEditByDoubleClickResource(identifier); + await DoceditPage.clickCheckbox(completeFieldName, 0); + await DoceditPage.clickSaveDocument(); + } + + await navigateTo('configuration'); + await CategoryPickerPage.clickSelectCategory('Place'); + await ConfigurationPage.clickOpenContextMenuForField(completeFieldName); + await ConfigurationPage.clickContextMenuEditOption(); + await EditConfigurationPage.clickSwapValuelist(); + await ManageValuelistsModalPage.typeInSearchFilterInput('Wood-objectType-default'); + await ManageValuelistsModalPage.clickSelectValuelist('Wood-objectType-default'); + await ManageValuelistsModalPage.clickConfirmSelection(); + await EditConfigurationPage.clickConfirm(); + await ConfigurationPage.save(); + + await NavbarPage.clickCloseNonResourcesTab(); + }; + + async function createMissingIdentifierPrefixWarning(resourceIdentifier: string) { await ResourcesPage.performCreateResource(resourceIdentifier, 'place'); @@ -100,12 +132,21 @@ test.describe('warnings --', () => { }; - async function createField(fieldName: string) { + async function createField(fieldName: string, inputType?: Field.InputType, valuelistName?: string) { await CategoryPickerPage.clickSelectCategory('Place'); await ConfigurationPage.clickAddFieldButton(); await AddFieldModalPage.typeInSearchFilterInput(fieldName); await AddFieldModalPage.clickCreateNewField(); + + if (inputType) await EditConfigurationPage.clickInputTypeSelectOption(inputType, 'field'); + if (valuelistName) { + await EditConfigurationPage.clickAddValuelist(); + await ManageValuelistsModalPage.typeInSearchFilterInput(valuelistName); + await ManageValuelistsModalPage.clickSelectValuelist(valuelistName); + await ManageValuelistsModalPage.clickConfirmSelection(); + } + await EditConfigurationPage.clickConfirm(); await ConfigurationPage.save(); } @@ -232,6 +273,24 @@ test.describe('warnings --', () => { }); + test('solve warning for outlier values via resources view', async () => { + + await waitForNotExist(await NavbarPage.getWarnings()); + await createOutlierValuesWarnings(['1'], 'field'); + expect(await NavbarPage.getNumberOfWarnings()).toBe('1'); + + await ResourcesPage.openEditByDoubleClickResource('1'); + const outlierValues = await DoceditPage.getOutlierValues('test:field'); + expect(await outlierValues.count()).toBe(1); + + await DoceditPage.clickRemoveOutlierValue('test:field', 0); + expect(await outlierValues.count()).toBe(0); + + await DoceditPage.clickSaveDocument(); + await waitForNotExist(await NavbarPage.getWarnings()); + }); + + test('solve warning for missing identifier prefix via resources view', async () => { await waitForNotExist(await NavbarPage.getWarnings());