Skip to content

Commit

Permalink
Add e2e test for solving warning for invalid field data via resources…
Browse files Browse the repository at this point in the history
… view
  • Loading branch information
tkleinke committed Nov 10, 2023
1 parent 531b97f commit 9f0cb7c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 15 deletions.
6 changes: 6 additions & 0 deletions desktop/test/e2e/docedit/docedit.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ export class DoceditPage {
}


public static async clickDeleteInvalidFieldDataButton(fieldName: string) {

return click((await this.getField(fieldName).locator('.delete-invalid-field-data-button')));
}


public static async clickLanguageTab(fieldName: string, language: string) {

return click((await this.getField(fieldName)).locator('.language-tab-' + language));
Expand Down
72 changes: 57 additions & 15 deletions desktop/test/e2e/warnings/warnings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,31 @@ test.describe('warnings --', () => {
});


async function createMissingIdentifierPrefixWarning(resourceIdentifier: string) {
async function createUnconfiguredFieldWarning(resourceIdentifier: string, fieldName: string) {

await ResourcesPage.performCreateResource(resourceIdentifier, 'place');
await navigateTo('configuration');
await createField(fieldName);

const completeFieldName: string = 'test:' + fieldName;

await NavbarPage.clickCloseNonResourcesTab();
await ResourcesPage.performCreateResource(resourceIdentifier, 'place', completeFieldName, 'Text');

await navigateTo('configuration');
await CategoryPickerPage.clickOpenContextMenu('Place');
await ConfigurationPage.clickContextMenuEditOption();
await EditConfigurationPage.typeInIdentifierPrefix('P');
await EditConfigurationPage.clickConfirm();
await CategoryPickerPage.clickSelectCategory('Place');
await ConfigurationPage.clickOpenContextMenuForField(completeFieldName);
await ConfigurationPage.clickContextMenuDeleteOption();
await ConfigurationPage.clickConfirmFieldDeletionButton();
await ConfigurationPage.save();

await NavbarPage.clickCloseNonResourcesTab();
};


async function createUnconfiguredFieldWarning(resourceIdentifier: string, fieldName: string) {
async function createInvalidFieldDataWarning(resourceIdentifier: string, fieldName: string) {

await navigateTo('configuration');
await CategoryPickerPage.clickSelectCategory('Place');
await ConfigurationPage.clickAddFieldButton();
await AddFieldModalPage.typeInSearchFilterInput(fieldName);
await AddFieldModalPage.clickCreateNewField();
await EditConfigurationPage.clickConfirm();
await ConfigurationPage.save();
await createField(fieldName);

const completeFieldName: string = 'test:' + fieldName;

Expand All @@ -71,14 +72,41 @@ test.describe('warnings --', () => {
await navigateTo('configuration');
await CategoryPickerPage.clickSelectCategory('Place');
await ConfigurationPage.clickOpenContextMenuForField(completeFieldName);
await ConfigurationPage.clickContextMenuDeleteOption();
await ConfigurationPage.clickConfirmFieldDeletionButton();
await ConfigurationPage.clickContextMenuEditOption();
await EditConfigurationPage.clickInputTypeSelectOption('int', 'field');
await EditConfigurationPage.clickConfirm();
await ConfigurationPage.save();

await NavbarPage.clickCloseNonResourcesTab();
};


async function createMissingIdentifierPrefixWarning(resourceIdentifier: string) {

await ResourcesPage.performCreateResource(resourceIdentifier, 'place');

await navigateTo('configuration');
await CategoryPickerPage.clickOpenContextMenu('Place');
await ConfigurationPage.clickContextMenuEditOption();
await EditConfigurationPage.typeInIdentifierPrefix('P');
await EditConfigurationPage.clickConfirm();
await ConfigurationPage.save();

await NavbarPage.clickCloseNonResourcesTab();
};


async function createField(fieldName: string) {

await CategoryPickerPage.clickSelectCategory('Place');
await ConfigurationPage.clickAddFieldButton();
await AddFieldModalPage.typeInSearchFilterInput(fieldName);
await AddFieldModalPage.clickCreateNewField();
await EditConfigurationPage.clickConfirm();
await ConfigurationPage.save();
}


test('solve single warning for unconfigured field via warnings modal', async () => {

await waitForNotExist(await NavbarPage.getWarnings());
Expand Down Expand Up @@ -128,6 +156,20 @@ test.describe('warnings --', () => {
});


test('solve warning for invalid field data via resources view', async () => {

await waitForNotExist(await NavbarPage.getWarnings());
await createInvalidFieldDataWarning('1', 'field');
expect(await NavbarPage.getNumberOfWarnings()).toBe('1');

await ResourcesPage.openEditByDoubleClickResource('1');
await DoceditPage.clickDeleteInvalidFieldDataButton('test:field');
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 9f0cb7c

Please sign in to comment.