Skip to content

Commit

Permalink
Add e2e test for solving warning for outlier values via resources view
Browse files Browse the repository at this point in the history
  • Loading branch information
tkleinke committed Nov 10, 2023
1 parent 66cd8f5 commit 4f1d43d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="input-group mb-2">
<input value="{{outlier}}" type="text" disabled class="form-control">
<div class="input-group-append">
<button class="btn btn-danger" type="button" (click)="remove(outlier)">
<button class="btn btn-danger remove-outlier-button" type="button" (click)="remove(outlier)">
<span class="mdi mdi-delete"></span>
</button>
</div>
Expand Down
26 changes: 22 additions & 4 deletions desktop/test/e2e/docedit/docedit.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
65 changes: 62 additions & 3 deletions desktop/test/e2e/warnings/warnings.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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');

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand All @@ -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();
}
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 4f1d43d

Please sign in to comment.