Skip to content

Commit 58beda3

Browse files
committed
fix playwright tests
1 parent fd87234 commit 58beda3

File tree

5 files changed

+17
-19
lines changed

5 files changed

+17
-19
lines changed

frontend/testing/playwright/pages/ProcessEditorPage/CustomReceiptConfig.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ export class CustomReceiptConfig extends BasePage {
5555
.click();
5656
}
5757

58-
public async waitForEditLayoutSetIdButtonToBeVisible(): Promise<void> {
58+
public async waitForEditLayoutSetIdButtonToBeVisible(layoutSetId: string): Promise<void> {
5959
const button = this.page.getByRole('button', {
60-
name: this.textMock('process_editor.configuration_panel_custom_receipt_textfield_label'),
60+
name: layoutSetId,
6161
});
6262
await expect(button).toBeVisible();
6363
}

frontend/testing/playwright/pages/ProcessEditorPage/ProcessEditorPage.ts

+8-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@playwright/test';
2-
import type { Page } from '@playwright/test';
2+
import type { Page, Locator } from '@playwright/test';
33
import { ActionsConfig } from './ActionsConfig';
44
import { PolicyConfig } from './PolicyConfig';
55
import { BasePage } from '../../helpers/BasePage';
@@ -73,15 +73,13 @@ export class ProcessEditorPage extends BasePage {
7373
}
7474

7575
public async getTaskIdFromOpenNewlyAddedTask(): Promise<string> {
76-
const selector = 'text=ID: Activity_';
77-
await this.page.waitForSelector(selector);
78-
return await this.getFullIdFromButtonSelector(selector);
76+
const button = this.page.getByRole('button', { name: /^Activity_/ });
77+
await button.waitFor();
78+
return await this.getFullIdFromButtonSelector(button);
7979
}
8080

8181
public async clickOnTaskIdEditButton(id: string): Promise<void> {
82-
await this.page
83-
.getByText(`${this.textMock('process_editor.configuration_panel_id_label')} ${id}`)
84-
.click();
82+
await this.page.getByRole('button', { name: id }).click();
8583
}
8684

8785
public async waitForEditIdInputFieldToBeVisible(): Promise<void> {
@@ -123,9 +121,7 @@ export class ProcessEditorPage extends BasePage {
123121
}
124122

125123
public async waitForNewTaskIdButtonToBeVisible(id: string): Promise<void> {
126-
const button = this.page.getByText(
127-
`${this.textMock('process_editor.configuration_panel_id_label')} ${id}`,
128-
);
124+
const button = this.page.getByRole('button', { name: id });
129125
await expect(button).toBeVisible();
130126
}
131127

@@ -165,10 +161,9 @@ export class ProcessEditorPage extends BasePage {
165161
await this.page.mouse.up();
166162
}
167163

168-
private async getFullIdFromButtonSelector(selector: string): Promise<string> {
169-
const button = this.page.locator(selector);
164+
private async getFullIdFromButtonSelector(button: Locator): Promise<string> {
170165
const fullText = await button.textContent();
171-
const extractedText = fullText.match(/ID: (Activity_\w+)/);
166+
const extractedText = fullText.match(/(Activity_\w+)/);
172167
return extractedText[1];
173168
}
174169
}

frontend/testing/playwright/pages/UiEditorPage.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ export class UiEditorPage extends BasePage {
231231
await expect(newTreeItemLabel).toBeVisible();
232232
}
233233

234-
public async deleteOldComponentId(): Promise<void> {
235-
await this.page.getByRole('button', { name: /ID:/ }).click();
234+
public async deleteOldComponentId(componentId: string): Promise<void> {
235+
const button = this.page.getByRole('button', { name: componentId });
236+
await button.click();
236237
await this.page
237238
.getByLabel(this.textMock('ux_editor.modal_properties_component_change_id'))
238239
.clear();

frontend/testing/playwright/tests/process-editor/process-editor.spec.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ test('That it is possible to create a custom receipt', async ({ page, testAppNam
184184

185185
await processEditorPage.customReceiptConfig.waitForSaveNewCustomReceiptButtonToBeVisible();
186186
await processEditorPage.customReceiptConfig.clickOnSaveNewCustomReceiptButton();
187-
await processEditorPage.customReceiptConfig.waitForEditLayoutSetIdButtonToBeVisible();
187+
await processEditorPage.customReceiptConfig.waitForEditLayoutSetIdButtonToBeVisible(
188+
newLayoutSetId,
189+
);
188190

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

frontend/testing/playwright/tests/text-editor/text-editor.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ test('That it is possible to create a text at the ui-editor page, and that the t
5959
await navigateToUiEditorAndVerifyPage(header, uiEditorPage);
6060
await uiEditorPage.dragComponentIntoDroppableList(ComponentType.Input);
6161

62-
await uiEditorPage.deleteOldComponentId();
62+
await uiEditorPage.deleteOldComponentId(COMPONENT_ID);
6363
await uiEditorPage.writeNewComponentId(COMPONENT_ID);
6464
await uiEditorPage.waitForXAmountOfMilliseconds(1000); // Wait for the API call to be done
6565

0 commit comments

Comments
 (0)