Skip to content

Commit ecc8dc9

Browse files
author
GiCharkviani
committed
PW-DSM-Tissue-request-flow Alex's review 2
1 parent 908055c commit ecc8dc9

File tree

10 files changed

+36
-309
lines changed

10 files changed

+36
-309
lines changed

playwright-e2e/dsm/component/modal.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import { waitForNoSpinner } from 'utils/test-utils';
77
export default class Modal {
88
private readonly rootSelector: Locator;
99

10-
constructor(private readonly page: Page, opts: {root?: Locator} = {}) {
11-
const {root} = opts;
10+
constructor(private readonly page: Page) {
1211
this.page = page;
13-
this.rootSelector = root || this.page.locator('.modal-dialog');
12+
this.rootSelector = this.page.locator('app-modal, .modal-dialog');
1413
}
1514

1615
public toLocator(): Locator {

playwright-e2e/dsm/component/smid.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ export default class SMID {
1313
private readonly modalComponent: Modal;
1414

1515
constructor(private readonly page: Page, private readonly tissueIndex: number) {
16-
this.modalComponent = new Modal(this.page, {root: this.modal});
16+
this.modalComponent = new Modal(this.page);
1717
}
1818

1919
public async getValueAt(index: number): Promise<string> {
2020
const input = await this.getInputAt(index);
21-
return input.currentValue;
21+
return input.currentValue();
2222
}
2323

2424
public async fillInputs(inputData: (InputData | string)[]): Promise<void> {
@@ -63,7 +63,7 @@ export default class SMID {
6363

6464
private async fillField(value: string, index: number): Promise<void> {
6565
const fieldInput = await this.getInputAt(index);
66-
const currentValue = await fieldInput.currentValue;
66+
const currentValue = await fieldInput.currentValue();
6767
if (currentValue.trim() !== value) {
6868
await fieldInput.fillSimple(value);
6969
await waitForResponse(this.page, {uri: 'patch'});
@@ -83,17 +83,11 @@ export default class SMID {
8383
}
8484

8585
private async clickModalBtn(label: 'Only keep selected SM-IDs' | 'close'): Promise<void> {
86-
const modalLocator = this.modalFooter;
87-
const closeBtn = new Button(this.page, {root: modalLocator, label});
88-
await closeBtn.click();
86+
await this.modalComponent.getButton({label}).click();
8987
}
9088

9189

9290
/* Locators */
93-
private get modalFooter(): Locator {
94-
return this.modalComponent.footerLocator();
95-
}
96-
9791
private get modalBody(): Locator {
9892
return this.modalComponent.bodyLocator();
9993
}

playwright-e2e/dsm/component/tables/onc-history-table.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@ export default class OncHistoryTable extends Table {
5757

5858
switch (inputType) {
5959
case InputTypeEnum.INPUT: {
60-
value = new Input(this.page, {root: cell}).currentValue;
60+
value = new Input(this.page, {root: cell}).currentValue();
6161
break;
6262
}
6363
case InputTypeEnum.DATE: {
64-
value = new Input(this.page, {root: cell}).currentValue;
64+
value = new Input(this.page, {root: cell}).currentValue();
6565
break;
6666
}
6767
case InputTypeEnum.TEXTAREA: {
68-
value = new TextArea(this.page, {root: cell}).currentValue;
68+
value = new TextArea(this.page, {root: cell}).currentValue();
6969
break;
7070
}
7171
case InputTypeEnum.SELECT: {
72-
value = new Select(this.page, {root: cell}).currentValue;
72+
value = new Select(this.page, {root: cell}).currentValue();
7373
break;
7474
}
7575
default:
@@ -86,7 +86,7 @@ export default class OncHistoryTable extends Table {
8686
const notesModalContent = this.notesModalContent;
8787
await expect(notesModalContent, `Notes modal at ${index} index is not visible`).toBeVisible();
8888
const textarea = new TextArea(this.page, {root: notesModalContent});
89-
const currentValue = await textarea.currentValue;
89+
const currentValue = await textarea.currentValue();
9090
if (currentValue.trim() !== note) {
9191
await textarea.fill(note);
9292
await waitForResponse(this.page, {uri: 'patch'});
@@ -134,7 +134,7 @@ export default class OncHistoryTable extends Table {
134134
const inputElement = new Input(this.page, {root});
135135
const currentValue = await this.getCurrentValue(inputElement);
136136
let actualValue = typeof value === 'number' ? value.toString() : value;
137-
const maxLength = await inputElement.maxLength;
137+
const maxLength = await inputElement.maxLength();
138138

139139
if (maxLength && actualValue.length > Number(maxLength)) {
140140
actualValue = actualValue.slice(0, Number(maxLength));
@@ -165,7 +165,7 @@ export default class OncHistoryTable extends Table {
165165
const textarea = new TextArea(this.page, {root});
166166
const currentValue = await this.getCurrentValue(textarea);
167167
let actualValue = typeof value === 'number' ? value.toString() : value;
168-
const maxLength = await textarea.maxLength;
168+
const maxLength = await textarea.maxLength();
169169

170170
if (maxLength && actualValue.length > Number(maxLength)) {
171171
actualValue = actualValue.slice(0, Number(maxLength));
@@ -199,7 +199,7 @@ export default class OncHistoryTable extends Table {
199199
}
200200

201201
private async getCurrentValue(element: Input | Select | TextArea): Promise<string> {
202-
const currentValue = await element.currentValue;
202+
const currentValue = await element.currentValue();
203203
const isDisabled = await element.isDisabled();
204204

205205
await expect(isDisabled, `Input field is disabled`).toBeFalsy();
@@ -255,7 +255,7 @@ export default class OncHistoryTable extends Table {
255255
.toBeVisible();
256256

257257
const cell: Locator = this.td(columnName).nth(rowIndex);
258-
await expect(cell, `Kits Table - more than one column was found with the same name ${columnName}`)
258+
await expect(cell, `Kits Table - more than one or no column was found with the name ${columnName}`)
259259
.toHaveCount(1);
260260

261261
return cell;

playwright-e2e/dsm/component/tabs/onc-history-tab.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import Button from '../../../dss/component/button';
66

77

88
export default class OncHistoryTab {
9-
private readonly oncHistoryTable = new OncHistoryTable(this.page);
9+
private readonly oncHistoryTable: OncHistoryTable;
1010

11-
constructor(private readonly page: Page) {}
11+
constructor(private readonly page: Page) {
12+
this.oncHistoryTable = new OncHistoryTable(this.page);
13+
}
1214

1315
public get table(): OncHistoryTable {
1416
return this.oncHistoryTable;
@@ -40,13 +42,11 @@ export default class OncHistoryTab {
4042
}
4143

4244
public async downloadPDFBundle(): Promise<void> {
43-
const downloadPDFBundleBtn = this.downloadPDFBundleButton;
44-
await this.downloadPDFFlow(downloadPDFBundleBtn);
45+
await this.downloadPDFFlow(this.downloadPDFBundleButton);
4546
}
4647

4748
public async downloadRequestDocuments(): Promise<void> {
48-
const downloadPDFBundleBtn = this.downloadRequestDocumentsButton;
49-
await this.downloadPDFFlow(downloadPDFBundleBtn);
49+
await this.downloadPDFFlow(this.downloadRequestDocumentsButton);
5050
}
5151

5252

playwright-e2e/dsm/component/tissue.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {waitForResponse} from '../../utils/test-utils';
1+
import {waitForResponse} from 'utils/test-utils';
22
import {expect, Locator, Page} from '@playwright/test';
33
import {
44
SequencingResultsEnum,
@@ -35,26 +35,23 @@ export default class Tissue {
3535
} = tissueInputs.get(dynamicField) as TissueInputsMapValue;
3636

3737
let value: Promise<any>;
38+
const inputLocator = await this.getField(dynamicField, byText);
3839

3940
switch (inputType) {
4041
case InputTypeEnum.INPUT: {
41-
const inputLocator = await this.getField(dynamicField, byText);
42-
value = new Input(this.page, {root: inputLocator}).currentValue;
42+
value = new Input(this.page, {root: inputLocator}).currentValue();
4343
break;
4444
}
4545
case InputTypeEnum.DATE: {
46-
const inputLocator = await this.getField(dynamicField);
47-
value = new Input(this.page, {root: inputLocator}).currentValue;
46+
value = new Input(this.page, {root: inputLocator}).currentValue();
4847
break;
4948
}
5049
case InputTypeEnum.TEXTAREA: {
51-
const textAreaLocator = await this.getField(dynamicField);
52-
value = new TextArea(this.page, {root: textAreaLocator}).currentValue;
50+
value = new TextArea(this.page, {root: inputLocator}).currentValue();
5351
break;
5452
}
5553
case InputTypeEnum.SELECT: {
56-
const selectLocator = await this.getField(dynamicField);
57-
value = new Select(this.page, {root: selectLocator}).currentValue;
54+
value = new Select(this.page, {root: inputLocator}).currentValue();
5855
break;
5956
}
6057
default:
@@ -111,7 +108,7 @@ export default class Tissue {
111108
const textarea = new TextArea(this.page, {root: textAreaLocator});
112109
const currentValue = await this.getCurrentValue(dynamicField, textarea);
113110
let actualValue = typeof value === 'number' ? value.toString() : value;
114-
const maxLength = await textarea.maxLength;
111+
const maxLength = await textarea.maxLength();
115112

116113
if (maxLength && actualValue.length > Number(maxLength)) {
117114
actualValue = actualValue.slice(0, Number(maxLength));
@@ -142,7 +139,7 @@ export default class Tissue {
142139
const inputElement = new Input(this.page, {root: inputLocator});
143140
const currentValue = await this.getCurrentValue(dynamicField, inputElement);
144141
let actualValue = typeof value === 'number' ? value.toString() : value;
145-
const maxLength = await inputElement.maxLength;
142+
const maxLength = await inputElement.maxLength();
146143

147144
if (maxLength && actualValue.length > Number(maxLength)) {
148145
actualValue = actualValue.slice(0, Number(maxLength));
@@ -189,7 +186,7 @@ export default class Tissue {
189186
}
190187

191188
private async getCurrentValue(dynamicField: TissueDynamicFieldsEnum, element: Input | Select | TextArea): Promise<string> {
192-
const currentValue = await element.currentValue;
189+
const currentValue = await element.currentValue();
193190
const isDisabled = await element.isDisabled();
194191

195192
await expect(isDisabled, `'${dynamicField}' is disabled`).toBeFalsy();

playwright-e2e/dsm/pages/tissue-information-page/tissue-information-page.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export default class TissueInformationPage {
8888

8989
const textarea = new TextArea(this.page, {root: notesLocator});
9090
const isTextareaDisabled = await textarea.isDisabled();
91-
const existingValue = await textarea.currentValue;
91+
const existingValue = await textarea.currentValue();
9292

9393
if (!isTextareaDisabled && existingValue !== value) {
9494
await textarea.fill(value, false);
@@ -106,7 +106,7 @@ export default class TissueInformationPage {
106106

107107
await this.checkCheckbox(destructionPolicyLocator, keptIndefinitelySelection);
108108

109-
const existingValue = await destructionPolicyYears.currentValue;
109+
const existingValue = await destructionPolicyYears.currentValue();
110110
const isAllowedToEnterValue = !keptIndefinitelySelection && !isInputDisabled && existingValue.trim() !== value.toString();
111111

112112
if (isAllowedToEnterValue) {
@@ -123,7 +123,7 @@ export default class TissueInformationPage {
123123
.toBeVisible();
124124

125125
const selectElement = new Select(this.page, {root: problemsWithTissueLocator});
126-
const selectedValue = await selectElement.currentValue;
126+
const selectedValue = await selectElement.currentValue();
127127
const isDisabled = await selectElement.isSelectDisabled();
128128
const allowSelection = !isDisabled && selectedValue?.trim() !== newValue;
129129

@@ -141,7 +141,7 @@ export default class TissueInformationPage {
141141
.toBeVisible();
142142

143143
const selectElement = new Select(this.page, {root: genderLocator});
144-
const selectedValue = await selectElement.currentValue;
144+
const selectedValue = await selectElement.currentValue();
145145
const isDisabled = await selectElement.isSelectDisabled();
146146

147147
if (!isDisabled && selectedValue?.trim() !== gender) {

playwright-e2e/dss/component/select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default class Select extends WidgetBase {
101101
return options!;
102102
}
103103

104-
get currentValue(): Promise<string> {
104+
async currentValue(): Promise<string> {
105105
return this.toLocator().locator('span.mat-select-min-line').textContent() as Promise<string>;
106106
}
107107

playwright-e2e/dss/component/textarea.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default class TextArea extends WidgetBase {
3434
await this.toLocator().blur();
3535
}
3636

37-
public get maxLength(): Promise<string | null> {
37+
public async maxLength(): Promise<string | null> {
3838
return this.toLocator().getAttribute('maxlength');
3939
}
4040
}

0 commit comments

Comments
 (0)