Skip to content

Commit

Permalink
refactored e2e-tests, splitted up in multiple tests and simplified th…
Browse files Browse the repository at this point in the history
…em (#13025)

refactored e2e-tests, splitted up in multiple tests and simplified them
  • Loading branch information
framitdavid authored Jun 26, 2024
1 parent 7e5236c commit adfbfbb
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 110 deletions.
19 changes: 0 additions & 19 deletions frontend/testing/playwright/pages/GiteaPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,29 +170,10 @@ export class GiteaPage extends BasePage {
await this.page.getByText(`<altinn:action>${action}</altinn:action>`).isVisible();
}

public async verifyThatActionIsHidden(action: string): Promise<void> {
await this.page.getByText(`<altinn:action>${action}</altinn:action>`).isHidden();
}

public async verifyThatTaskIsHidden(task: string): Promise<void> {
await this.page.getByText(`<altinn:taskType>${task}</altinn:taskType>`).isHidden();
}

public async verifyThatTaskIsVisible(task: string): Promise<void> {
await this.page.getByText(`<altinn:taskType>${task}</altinn:taskType>`).isVisible();
}

public async verifyThatDataTypeToSignIsHidden(dataTypeToSign: string): Promise<void> {
const text = `
<altinn:signatureConfig>
<altinn:dataTypesToSign>
<altinn:dataType>${dataTypeToSign}</altinn:dataType>
</altinn:dataTypesToSign>
</altinn:signatureConfig>
`;
await this.page.getByText(text).isHidden();
}

public async verifyThatDataTypeToSignIsVisible(dataTypeToSign: string): Promise<void> {
const text = `
<altinn:signatureConfig>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class DataModelConfig extends BasePage {
.isVisible();
}

public async verifyThatAddNewDataModelButtonIsHidden(): Promise<void> {
public async verifyThatAddNewDataModelLinkButtonIsHidden(): Promise<void> {
await this.page
.getByRole('button', {
name: this.textMock('process_editor.configuration_panel_set_data_model_link'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,6 @@ export class ProcessEditorPage extends BasePage {
.click();
}

public async waitForPolicyEditorModalTabToBeVisible(): Promise<void> {
const heading = this.page.getByRole('heading', {
name: this.textMock('policy_editor.rules'),
level: 2,
});
await expect(heading).toBeVisible();
}

public async dragTaskInToBpmnEditor(
task: BpmnTaskType,
dropElementSelector: string,
Expand Down Expand Up @@ -359,7 +351,6 @@ export class ProcessEditorPage extends BasePage {
* Helper methods below this
*
*/

private async startDragElement(title: string): Promise<void> {
await this.page.getByTitle(title).hover();
await this.page.mouse.down();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,9 @@ const setupAndVerifyProcessEditorPage = async (
return processEditorPage;
};

test('That it is possible to add and remove datamodel, and add actions to the default task in the process editor', async ({
page,
testAppName,
}): Promise<void> => {
test('that the user is able to add and delete data model', async ({ page, testAppName }) => {
const processEditorPage = await setupAndVerifyProcessEditorPage(page, testAppName);
const bpmnJSQuery = new BpmnJSQuery(page);
const header = new Header(page, { app: testAppName });
const giteaPage = new GiteaPage(page, { app: testAppName });

const initialTaskDataElementIdSelector: string = await bpmnJSQuery.getTaskByIdAndType(
'Task_1',
Expand All @@ -53,7 +48,6 @@ test('That it is possible to add and remove datamodel, and add actions to the de
await processEditorPage.clickOnTaskInBpmnEditor(initialTaskDataElementIdSelector);
await processEditorPage.waitForInitialTaskHeaderToBeVisible();

// --------------------- Add and delete datamodel ---------------------
await processEditorPage.dataModelConfig.waitForDataModelButtonToBeVisibleWithValue('model');
await processEditorPage.dataModelConfig.clickOnDataModelButton('model');
await processEditorPage.dataModelConfig.waitForComboboxToBeVisible();
Expand All @@ -72,9 +66,23 @@ test('That it is possible to add and remove datamodel, and add actions to the de
await processEditorPage.dataModelConfig.verifyDataModelButtonTextIsSelectedDataModel(
dataModelName,
);
await processEditorPage.dataModelConfig.verifyThatAddNewDataModelButtonIsHidden();
await processEditorPage.dataModelConfig.verifyThatAddNewDataModelLinkButtonIsHidden();
});

test('that the user is able to add actions', async ({ page, testAppName }) => {
const processEditorPage = await setupAndVerifyProcessEditorPage(page, testAppName);
const bpmnJSQuery = new BpmnJSQuery(page);
const header = new Header(page, { app: testAppName });
const giteaPage = new GiteaPage(page, { app: testAppName });

const initialTaskDataElementIdSelector: string = await bpmnJSQuery.getTaskByIdAndType(
'Task_1',
'g',
);

await processEditorPage.clickOnTaskInBpmnEditor(initialTaskDataElementIdSelector);
await processEditorPage.waitForInitialTaskHeaderToBeVisible();

// --------------------- Add actions ---------------------
await processEditorPage.clickOnActionsAccordion();
await processEditorPage.waitForAddActionsButtonToBeVisible();

Expand All @@ -89,29 +97,33 @@ test('That it is possible to add and remove datamodel, and add actions to the de
await processEditorPage.clickOnSaveActionButton();
await processEditorPage.waitForActionButtonToBeVisible(actionIndex1, actionOptionWrite);

// --------------------- Verify policy editor ---------------------
await commitAndPushToGitea(header);

await goToGiteaAndNavigateToProcessBpmnFile(header, giteaPage);
await giteaPage.verifyThatActionIsVisible(actionOptionWrite);
});

test('that the user able to open policy editor', async ({ page, testAppName }) => {
const processEditorPage = await setupAndVerifyProcessEditorPage(page, testAppName);
const bpmnJSQuery = new BpmnJSQuery(page);

const initialTaskDataElementIdSelector: string = await bpmnJSQuery.getTaskByIdAndType(
'Task_1',
'g',
);
await processEditorPage.clickOnTaskInBpmnEditor(initialTaskDataElementIdSelector);
await processEditorPage.waitForInitialTaskHeaderToBeVisible();

await processEditorPage.clickOnPolicyAccordion();
await processEditorPage.waitForNavigateToPolicyButtonIsVisible();
await processEditorPage.clickOnNavigateToPolicyEditorButton();

await processEditorPage.verifyThatPolicyEditorIsOpen();
await processEditorPage.closePolicyEditor();
await processEditorPage.verifyThatPolicyEditorIsClosed();

// --------------------- Check that files are uploaded to Gitea ---------------------
await goToGiteaAndNavigateToProcessBpmnFile(header, giteaPage);

const numberOfPagesBackToAltinnStudio: number = 5;
await giteaPage.goBackNPages(numberOfPagesBackToAltinnStudio);

await processEditorPage.verifyProcessEditorPage();
await commitAndPushToGitea(header);

await goToGiteaAndNavigateToProcessBpmnFile(header, giteaPage);
await giteaPage.verifyThatActionIsVisible(actionOptionWrite);
});

test('That it is possible to add a new task to the process editor, configure some of its data', async ({
test('that the user can add a new data model, assign it to a task, and create a sequence between tasks.', async ({
page,
testAppName,
}): Promise<void> => {
Expand All @@ -128,10 +140,6 @@ test('That it is possible to add a new task to the process editor, configure som
await processEditorPage.waitForTaskToBeVisibleInConfigPanel(dataTask);
const randomGeneratedId = await processEditorPage.getTaskIdFromOpenNewlyAddedTask();

// --------------------- Edit the id ---------------------
const newId: string = 'my_new_id';
await editRandomGeneratedId(processEditorPage, randomGeneratedId, newId);

// --------------------- Add new data model ---------------------
await processEditorPage.dataModelConfig.waitForAddDataModelButtonWithoutValueToBeVisible();
await processEditorPage.dataModelConfig.clickOnAddButton();
Expand All @@ -147,7 +155,7 @@ test('That it is possible to add a new task to the process editor, configure som
header,
newDataModel,
);
const newTaskSelector: string = await bpmnJSQuery.getTaskByIdAndType(newId, 'g');
const newTaskSelector: string = await bpmnJSQuery.getTaskByIdAndType(randomGeneratedId, 'g');
await processEditorPage.clickOnTaskInBpmnEditor(newTaskSelector);

await processEditorPage.dataModelConfig.waitForAddDataModelButtonWithoutValueToBeVisible();
Expand All @@ -160,94 +168,49 @@ test('That it is possible to add a new task to the process editor, configure som
newDataModel,
);

// --------------------- Connect the task to the process ---------------------
// --------------------- Draw sequence between tasks ---------------------
await processEditorPage.clickOnConnectionArrow();

const initialId: string = 'Task_1';
const initialTaskSelector: string = await bpmnJSQuery.getTaskByIdAndType(initialId, 'g');
await processEditorPage.clickOnTaskInBpmnEditor(initialTaskSelector);

// --------------------- Check that files are uploaded to Gitea ---------------------
await goToGiteaAndNavigateToProcessBpmnFile(header, giteaPage);
await giteaPage.verifyThatTheNewTaskIsHidden(newId, dataTask);

const numberOfPagesBackToAltinnStudio: number = 5;
await giteaPage.goBackNPages(numberOfPagesBackToAltinnStudio);

await processEditorPage.verifyProcessEditorPage();
await commitAndPushToGitea(header);

await goToGiteaAndNavigateToProcessBpmnFile(header, giteaPage);
await giteaPage.verifyThatTheNewTaskIsVisible(newId, dataTask);
await giteaPage.verifyThatTheNewTaskIsVisible(randomGeneratedId, dataTask);

await giteaPage.verifySequenceFlowDirection(newId, initialId);
await giteaPage.verifySequenceFlowDirection(randomGeneratedId, initialId);
const numblerBackToConfig: number = 2;
await giteaPage.goBackNPages(numblerBackToConfig);
await giteaPage.clickOnApplicationMetadataFile();
await giteaPage.verifyIdInDataModel(newId, newDataModel);
await giteaPage.verifyIdInDataModel(randomGeneratedId, newDataModel);
});

test('That it is possible to add a new signing task, and update the datatypes to sign', async ({
test('that the user can edit the id of a task and add data-types to sign', async ({
page,
testAppName,
}): Promise<void> => {
}) => {
const processEditorPage = await setupAndVerifyProcessEditorPage(page, testAppName);
const bpmnJSQuery = new BpmnJSQuery(page);
const header = new Header(page, { app: testAppName });
const giteaPage = new GiteaPage(page, { app: testAppName });

// --------------------- Drag new task into the editor ---------------------
const svgSelector = await bpmnJSQuery.getTaskByIdAndType('SingleDataTask', 'svg');
const signingTask: BpmnTaskType = 'signing';
const signingTask = await addNewSigningTaskToProcessEditor(page);

const extraMovingDistanceX: number = -120;
const extraMovingDistanceY: number = 0;
await processEditorPage.dragTaskInToBpmnEditor(
signingTask,
svgSelector,
extraMovingDistanceX,
extraMovingDistanceY,
);
await processEditorPage.waitForTaskToBeVisibleInConfigPanel(signingTask);
const randomGeneratedId = await processEditorPage.getTaskIdFromOpenNewlyAddedTask();

// --------------------- Edit the id ---------------------
const newId: string = 'signing_id';
await editRandomGeneratedId(processEditorPage, randomGeneratedId, newId);

// --------------------- Add data types to sign ---------------------
await processEditorPage.clickDataTypesToSignCombobox();
const dataTypeToSign: string = 'ref-data-as-pdf';
await processEditorPage.clickOnDataTypesToSignOption(dataTypeToSign);
await processEditorPage.waitForDataTypeToSignButtonToBeVisible(dataTypeToSign);
await processEditorPage.pressEscapeOnKeyboard();

// --------------------- Verify correct actions ---------------------
await processEditorPage.clickOnActionsAccordion();

const actionIndex1: string = '1';
const actionIndex2: string = '2';
const actionOptionSign: string = 'sign';
const actionOptionReject: string = 'reject';
await processEditorPage.waitForActionButtonToBeVisible(actionIndex1, actionOptionSign);
await processEditorPage.waitForActionButtonToBeVisible(actionIndex2, actionOptionReject);

// --------------------- Check that files are uploaded to Gitea ---------------------
await goToGiteaAndNavigateToProcessBpmnFile(header, giteaPage);
await giteaPage.verifyThatTaskIsHidden(signingTask);
await giteaPage.verifyThatActionIsHidden(actionOptionSign);
await giteaPage.verifyThatActionIsHidden(actionOptionReject);
await giteaPage.verifyThatDataTypeToSignIsHidden(dataTypeToSign);

const numberOfPagesBackToAltinnStudio: number = 5;
await giteaPage.goBackNPages(numberOfPagesBackToAltinnStudio);

await processEditorPage.verifyProcessEditorPage();
await commitAndPushToGitea(header);

await goToGiteaAndNavigateToProcessBpmnFile(header, giteaPage);
await giteaPage.verifyThatTaskIsVisible(signingTask);
await giteaPage.verifyThatActionIsVisible(actionOptionSign);
await giteaPage.verifyThatActionIsVisible(actionOptionReject);
await giteaPage.verifyThatDataTypeToSignIsVisible(signingTask);
});

Expand Down Expand Up @@ -302,6 +265,26 @@ test('That it is possible to create a custom receipt', async ({ page, testAppNam
});

// --------------------- Helper Functions ---------------------

const addNewSigningTaskToProcessEditor = async (page: Page): Promise<string> => {
const bpmnJSQuery = new BpmnJSQuery(page);
const processEditorPage = new ProcessEditorPage(page);
const svgSelector = await bpmnJSQuery.getTaskByIdAndType('SingleDataTask', 'svg');
const signingTask: BpmnTaskType = 'signing';

const extraMovingDistanceX: number = -120;
const extraMovingDistanceY: number = 0;
await processEditorPage.dragTaskInToBpmnEditor(
signingTask,
svgSelector,
extraMovingDistanceX,
extraMovingDistanceY,
);
await processEditorPage.waitForTaskToBeVisibleInConfigPanel(signingTask);

return signingTask;
};

const editRandomGeneratedId = async (
processEditorPage: ProcessEditorPage,
randomGeneratedId: string,
Expand Down

0 comments on commit adfbfbb

Please sign in to comment.