Skip to content

Commit 7cce22a

Browse files
authored
Merge pull request #564 from microting/copilot/fix-page-objects-dom-fetching
Refactor BackendConfigurationFiles page object to use indexed ID selectors
2 parents 3910617 + 142030a commit 7cce22a

File tree

2 files changed

+36
-39
lines changed

2 files changed

+36
-39
lines changed

eform-client/e2e/Page objects/BackendConfiguration/BackendConfigurationFiles.page.ts

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,6 @@ export class FileRowObject {
268268
constructor() {
269269
}
270270

271-
public row: WebdriverIO.Element;
272-
public checkbox: WebdriverIO.Element;
273271
public id: number;
274272
public createDate: string;
275273
public fileName: string;
@@ -282,41 +280,27 @@ export class FileRowObject {
282280

283281
public async getRow(rowNum: number): Promise<FileRowObject> {
284282
rowNum = rowNum - 1;
285-
this.row = (await $$('tbody > tr'))[rowNum];
286-
if (this.row) {
287-
this.checkbox = await this.row.$('.mat-column-select .column-select');
288-
this.id = +await (await this.row.$('.mat-column-id span')).getText();
289-
this.createDate = await (await this.row.$('.mat-column-createDate span')).getText();
290-
this.fileName = await (await this.row.$('.mat-column-fileName span')).getText();
291-
const properties = await this.row.$$('.mat-column-property mat-chip');
292-
this.properties = [];
293-
for (let i = 0; i < properties.length; i++) {
294-
const text = await properties[i].getText();
295-
this.properties.push(text.toString());
296-
}
297-
// if (properties.length > 0) {
298-
// properties[properties.length - 1] = properties[properties.length - 1].replace('edit', ''); // delete button
299-
// this.properties = properties
300-
// .filter(x => x) // delete empty strings
301-
// .map(x => x.replaceAll('\n', '')); // delete enters
302-
// }
303-
const tags = await this.row.$$('.mat-column-tags mat-chip');
304-
this.tags = [];
305-
for (let i = 0; i < tags.length; i++) {
306-
const text = await tags[i].getText();
307-
this.tags.push(text.toString());
308-
}
309-
// if (tags.length > 0) {
310-
// // tags[tags.length - 1] = tags[tags.length - 1].replace('edit', ''); // delete button
311-
// this.tags = tags
312-
// //.filter(x => x.te) // delete empty strings
313-
// .map(x => (await x.getText()).replaceAll('\n', '')); // delete enters
314-
// }
315-
this.editTagsBtn = await this.row.$('.mat-column-tags button');
316-
this.viewPDFBtn = await this.row.$$('.mat-column-actions button')[0];
317-
this.editFileNameBtn = await this.row.$$('.mat-column-actions button')[1];
318-
this.deleteFileBtn = await this.row.$$('.mat-column-actions button')[2];
283+
this.id = +await (await $('#fileId-'+rowNum)).getText();
284+
this.createDate = await (await $('#fileCreateDate-'+rowNum)).getText();
285+
this.fileName = await (await $('#fileName-'+rowNum)).getText();
286+
// Get properties from mat-chip elements - need to use row context since it's dynamic
287+
const row = (await $$('tbody > tr'))[rowNum];
288+
const properties = await row.$$('.mat-column-property mat-chip');
289+
this.properties = [];
290+
for (let i = 0; i < properties.length; i++) {
291+
const text = await properties[i].getText();
292+
this.properties.push(text.toString());
293+
}
294+
const tags = await row.$$('.mat-column-tags mat-chip');
295+
this.tags = [];
296+
for (let i = 0; i < tags.length; i++) {
297+
const text = await tags[i].getText();
298+
this.tags.push(text.toString());
319299
}
300+
this.editTagsBtn = await $('#editTagsBtn-'+rowNum);
301+
this.viewPDFBtn = await $('#viewPdfBtn-'+rowNum);
302+
this.editFileNameBtn = await $('#editFilenameBtn-'+rowNum);
303+
this.deleteFileBtn = await $('#deleteFileBtn-'+rowNum);
320304
return this;
321305
}
322306

eform-client/src/app/plugins/modules/backend-configuration-pn/modules/files/components/files-table/files-table.component.html

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<mtx-grid
22
[data]="_files.entities"
33
[columns]="tableHeaders"
4-
[cellTemplate]="{select: selectTpl, property: propertyTpl, tags: tagsTpl, actions: actionsTpl}"
4+
[cellTemplate]="{select: selectTpl, id: idTpl, createDate: createDateTpl, fileName: fileNameTpl, property: propertyTpl, tags: tagsTpl, actions: actionsTpl}"
55
[headerExtraTemplate]="selectHeaderTpl"
66
[showPaginator]="false"
77
[pageOnFront]="false"
@@ -43,7 +43,19 @@
4343
</div>
4444
</ng-template>
4545

46-
<ng-template #propertyTpl let-row>
46+
<ng-template #idTpl let-row let-i="index">
47+
<div class="fileId" id="fileId-{{i}}">{{ row.id }}</div>
48+
</ng-template>
49+
50+
<ng-template #createDateTpl let-row let-i="index">
51+
<div class="fileCreateDate" id="fileCreateDate-{{i}}">{{ row.createDate | date:'dd.MM.yyyy HH:mm:ss' }}</div>
52+
</ng-template>
53+
54+
<ng-template #fileNameTpl let-row let-i="index">
55+
<div class="fileName" id="fileName-{{i}}">{{ row.fileName }}.{{ row.fileExtension }}</div>
56+
</ng-template>
57+
58+
<ng-template #propertyTpl let-row let-i="index">
4759
<div class="d-flex flex-wrap align-items-center">
4860
<mat-chip-list>
4961
<mat-chip *ngFor="let property of row.properties">
@@ -53,7 +65,7 @@
5365
</div>
5466
</ng-template>
5567

56-
<ng-template #tagsTpl let-row>
68+
<ng-template #tagsTpl let-row let-i="index">
5769
<div class="d-flex flex-wrap align-items-center">
5870
<mat-chip-list>
5971
<mat-chip *ngFor="let tag of row.tags" color="primary" (click)="onClickTag(tag)">
@@ -63,6 +75,7 @@
6375
<button
6476
mat-icon-button
6577
color="primary"
78+
id="editTagsBtn-{{i}}"
6679
matTooltip="{{'Edit tags file' | translate}}"
6780
(click)="openEditTags(row)">
6881
<mat-icon>edit</mat-icon>

0 commit comments

Comments
 (0)