-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathProcessEditorPage.ts
177 lines (149 loc) · 5.99 KB
/
ProcessEditorPage.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import { expect } from '@playwright/test';
import type { Page, Locator } from '@playwright/test';
import { ActionsConfig } from './ActionsConfig';
import { PolicyConfig } from './PolicyConfig';
import { BasePage } from '../../helpers/BasePage';
import { DataModelConfig } from './DataModelConfig';
import { SigningTaskConfig } from './SigningTaskConfig';
import { CustomReceiptConfig } from './CustomReceiptConfig';
import { type BpmnTaskType } from '../../types/BpmnTaskType';
import type { Environment } from '../../helpers/StudioEnvironment';
const connectionArrowText: string = 'Connect using Sequence/MessageFlow or Association';
export class ProcessEditorPage extends BasePage {
public readonly dataModelConfig: DataModelConfig;
public readonly actionsConfig: ActionsConfig;
public readonly policyConfig: PolicyConfig;
public readonly customReceiptConfig: CustomReceiptConfig;
public readonly signingTaskConfig: SigningTaskConfig;
constructor(page: Page, environment?: Environment) {
super(page, environment);
this.dataModelConfig = new DataModelConfig(page);
this.actionsConfig = new ActionsConfig(page);
this.policyConfig = new PolicyConfig(page);
this.customReceiptConfig = new CustomReceiptConfig(page);
this.signingTaskConfig = new SigningTaskConfig(page);
}
public async loadProcessEditorPage(): Promise<void> {
await this.page.goto(this.getRoute('editorProcess'));
}
public async verifyProcessEditorPage(): Promise<void> {
await this.page.waitForURL(this.getRoute('editorProcess'));
}
public async clickOnTaskInBpmnEditor(elementSelector: string): Promise<void> {
await this.page.click(elementSelector);
}
public async waitForInitialTaskHeaderToBeVisible(): Promise<void> {
const heading = this.page.getByRole('heading', {
name: this.textMock('process_editor.configuration_panel_data_task'),
});
await expect(heading).toBeVisible();
}
public async dragTaskInToBpmnEditor(
task: BpmnTaskType,
dropElementSelector: string,
extraDistanceX?: number,
extraDistanceY?: number,
) {
const boundingBox = await this.page.locator(dropElementSelector).boundingBox();
const targetX = boundingBox.width / 2 + (extraDistanceX ?? 0);
const targetY = boundingBox.y + boundingBox.height / 2 + (extraDistanceY ?? 0);
const title = `Create Altinn ${task} task`;
await this.startDragElement(title);
await this.stopDragElement(targetX, targetY);
}
public async skipRecommendedTask(): Promise<void> {
const skipButton = this.page.getByRole('button', { name: this.textMock('general.skip') });
await skipButton.click();
}
public async waitForTaskToBeVisibleInConfigPanel(task: BpmnTaskType): Promise<void> {
const text = this.page.getByText(`Navn: Altinn ${task} task`);
await expect(text).toBeVisible();
}
public async getTaskIdFromOpenNewlyAddedTask(): Promise<string> {
const button = this.page.getByRole('button', {
name: this.textMock('process_editor.configuration_panel_change_task_id_label'),
});
await button.waitFor();
return await this.getFullIdFromButtonSelector(button);
}
public async clickOnTaskIdEditButton(): Promise<void> {
await this.page
.getByRole('button', {
name: this.textMock('process_editor.configuration_panel_change_task_id_label'),
})
.click();
}
public async waitForEditIdInputFieldToBeVisible(): Promise<void> {
const inputField = this.page.getByRole('textbox', {
name: this.textMock('process_editor.configuration_panel_change_task_id_label'),
});
await expect(inputField).toBeVisible();
}
public async emptyIdTextfield(): Promise<void> {
await this.page
.getByRole('textbox', {
name: this.textMock('process_editor.configuration_panel_change_task_id_label'),
})
.clear();
}
public async writeNewId(id: string): Promise<void> {
await this.page
.getByRole('textbox', {
name: this.textMock('process_editor.configuration_panel_change_task_id_label'),
})
.fill(id);
}
public async waitForTextBoxToHaveValue(id: string): Promise<void> {
const textBox = this.page.getByRole('textbox', {
name: this.textMock('process_editor.configuration_panel_change_task_id_label'),
});
await expect(textBox).toHaveValue(id);
}
public async saveNewId(): Promise<void> {
await this.page
.getByRole('textbox', {
name: this.textMock('process_editor.configuration_panel_change_task_id_label'),
})
.blur();
}
public async waitForNewTaskIdButtonToBeVisible(): Promise<void> {
const button = this.page.getByRole('button', {
name: this.textMock('process_editor.configuration_panel_change_task_id_label'),
});
await expect(button).toBeVisible();
}
public async pressEscapeOnKeyboard(): Promise<void> {
await this.page.keyboard.press('Escape');
}
public async clickOnConnectionArrow(): Promise<void> {
await this.page.getByTitle(connectionArrowText).click();
}
public async waitForEndEventHeaderToBeVisible(): Promise<void> {
const heading = this.page.getByRole('heading', {
name: this.textMock('process_editor.configuration_panel_end_event'),
});
await expect(heading).toBeVisible();
}
public async clickOnTaskTextInBpmnEditor(text: string): Promise<void> {
await this.page.getByText(text).click();
}
/**
*
* Helper methods below this
*
*/
private async startDragElement(title: string): Promise<void> {
await this.page.getByTitle(title).hover();
await this.page.mouse.down();
}
private async stopDragElement(xPosition: number, yPosition: number): Promise<void> {
const numberOfMouseMoveEvents: number = 20;
await this.page.mouse.move(xPosition, yPosition, { steps: numberOfMouseMoveEvents });
await this.page.mouse.up();
}
private async getFullIdFromButtonSelector(button: Locator): Promise<string> {
const fullText = await button.textContent();
const extractedText = fullText.match(/(Activity_\w+)/);
return extractedText[1];
}
}