Skip to content

Commit a4c03d5

Browse files
authored
fix: Phone playwright adjustment and attachment delete script failure fix (#408)
* fix: Phone playwright adjustment and attachment delete script failure fix * refactor: Added back download and delete file scenario
1 parent b687ef8 commit a4c03d5

File tree

6 files changed

+44
-46
lines changed

6 files changed

+44
-46
lines changed

packages/angular-sdk-components/src/lib/_components/field/phone/phone.component.html

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,24 @@
22
<component-mapper *ngIf="bVisible$ !== false" name="FieldValueList" [props]="{ label$, value$, displayMode$ }"></component-mapper>
33
</div>
44
<ng-template #noDisplayMode>
5-
<div *ngIf="bHasForm$; else noEdit">
6-
<div #f="ngForm" [formGroup]="formGroup$" *ngIf="bVisible$">
7-
<mat-form-field class="psdk-full-width" subscriptSizing="dynamic" [hintLabel]="helperText" floatLabel="always">
8-
<mat-tel-input
9-
[attr.data-test-id]="testId"
10-
[formControl]="fieldControl"
11-
[preferredCountries]="preferredCountries"
12-
[enablePlaceholder]="true"
13-
[enableSearch]="true"
14-
[placeholder]="placeholder"
15-
[required]="bRequired$"
16-
[disabled]="bDisabled$ || bReadonly$"
17-
(change)="fieldOnChange()"
18-
(blur)="fieldOnBlur()"
19-
>
20-
</mat-tel-input>
21-
<mat-label>{{ label$ }}</mat-label>
22-
<mat-error *ngIf="fieldControl.invalid">{{ getErrorMessage() }}</mat-error>
23-
</mat-form-field>
24-
</div>
5+
<div *ngIf="bHasForm$ && bVisible$; else noEdit">
6+
<mat-form-field class="psdk-full-width" subscriptSizing="dynamic" [hintLabel]="helperText" floatLabel="always">
7+
<mat-tel-input
8+
[attr.data-test-id]="testId"
9+
[formControl]="fieldControl"
10+
[preferredCountries]="preferredCountries"
11+
[enablePlaceholder]="true"
12+
[enableSearch]="true"
13+
[placeholder]="placeholder"
14+
[required]="bRequired$"
15+
[disabled]="bDisabled$ || bReadonly$"
16+
(change)="fieldOnChange()"
17+
(blur)="fieldOnBlur()"
18+
>
19+
</mat-tel-input>
20+
<mat-label>{{ label$ }}</mat-label>
21+
<mat-error *ngIf="fieldControl.invalid">{{ getErrorMessage() }}</mat-error>
22+
</mat-form-field>
2523
</div>
2624
</ng-template>
2725
<ng-template #noEdit>

packages/angular-sdk-components/src/lib/_components/field/phone/phone.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ export class PhoneComponent extends FieldBase {
5454
const isValueChanged = newVal?.toString() !== oldVal.toString();
5555

5656
if (isValueChanged) {
57-
const value = this.formGroup$.controls[this.controlName$].value;
58-
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
57+
handleEvent(this.actionsApi, 'changeNblur', this.propName, newVal);
5958
}
6059
}
6160

packages/angular-sdk-components/src/lib/_components/widget/attachment/attachment.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ export class AttachmentComponent implements OnInit, OnDestroy {
245245
}
246246
}
247247

248-
this.fileInput.nativeElement.value = '';
248+
if (this.fileInput?.nativeElement) {
249+
this.fileInput.nativeElement.value = '';
250+
}
249251
}
250252

251253
onFileAdded(event) {

projects/angular-test-app/tests/e2e/DigV2/FormFields/Phone.spec.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@ test.describe('E2E test', () => {
5656
// /** Disable tests */
5757
const alwaysDisabledPhone = page.locator('mat-tel-input[data-test-id="d415da67e9764d6e7cdf3d993cb54f51"] >> input');
5858
attributes = await common.getAttributes(alwaysDisabledPhone);
59-
await expect(attributes.includes('disabled')).toBeTruthy();
59+
expect(attributes.includes('disabled')).toBeTruthy();
6060

6161
const conditionallyDisabledPhone = page.locator('mat-tel-input[data-test-id="b6cee3728235ed1f6cef7b11ac850ea9"] >> input');
6262
attributes = await common.getAttributes(conditionallyDisabledPhone);
6363
if (isDisabled) {
64-
await expect(attributes.includes('disabled')).toBeTruthy();
64+
expect(attributes.includes('disabled')).toBeTruthy();
6565
} else {
66-
await expect(attributes.includes('disabled')).toBeFalsy();
66+
expect(attributes.includes('disabled')).toBeFalsy();
6767
}
6868

6969
const neverDisabledPhone = page.locator('mat-tel-input[data-test-id="b23e38f877c8a40f18507b39893a8d61"] >> input');
7070
attributes = await common.getAttributes(neverDisabledPhone);
71-
await expect(attributes.includes('disabled')).toBeFalsy();
71+
expect(attributes.includes('disabled')).toBeFalsy();
7272

7373
/** Selecting Update from the Sub Category dropdown */
7474
await common.selectSubCategory('Update', page);
@@ -102,11 +102,14 @@ test.describe('E2E test', () => {
102102

103103
/** Entering a valid Phone number */
104104
await editablePhoneInput.clear();
105+
/** Todo: Modified this script because mat-tel-input doesn't provide blur event and fix need to be implemented in blur callback
106+
* Keeping this comment for reference until this control provides blur callback
107+
*/
108+
await editablePhoneInput.fill('6175551212');
109+
await editablePhoneInput.blur();
105110
await countrySelector.click();
106111
await page.locator('text=United States >> nth=0').click();
107-
await editablePhoneInput.fill('6175551212');
108112

109-
await editablePhoneInput.blur();
110113
/** Expecting the invalid Phone number error be no longer present */
111114
await expect(page.locator(`mat-error:has-text("${validationMsg}")`)).toBeHidden();
112115

projects/angular-test-app/tests/e2e/DigV2/FormFields/attachment.spec.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,19 @@ test.describe('E2E test', () => {
9191
/** Testing invalid attachment case by uploading an empty file */
9292
await page.setInputFiles(`#AttachmentList`, [zeroBytesFilePath]);
9393
await expect(page.locator(`div >> text="Empty file can't be uploaded."`)).toBeVisible();
94-
9594
await page.locator('div[class="psdk-attachment-card"]').filter({ hasText: 'Unable to upload file' }).locator('#delete-attachment').click();
96-
9795
await page.locator('button:has-text("submit")').click();
9896

99-
// Raised bug BUG-960405
100-
// await page.locator('button[id="setting-button"] >> nth=0').click();
101-
102-
// /** Download attachment */
103-
// const menuSelector = await page.locator('div[role="menu"]');
104-
// await menuSelector.locator('button >> text="Download"').click();
97+
/** Download attachment */
98+
await page.locator('button[id="setting-button"] >> nth=0').click();
99+
const menuSelector = await page.locator('div[role="menu"]');
100+
await menuSelector.locator('button >> text="Download"').click();
105101

106-
// await page.locator('button[id="setting-button"] >> nth=0').click();
107-
108-
// /** Delete attachment */
109-
// await menuSelector.locator('button >> text="Delete"').click();
110-
// await expect(page.locator('div >> text="cableinfo.jpg"')).toBeVisible();
111-
// await expect(page.locator('div >> text="cablechat.jpg"')).toBeHidden();
102+
/** Delete attachment */
103+
await page.locator('button[id="setting-button"] >> nth=0').click();
104+
await menuSelector.locator('button >> text="Delete"').click();
105+
await expect(page.locator('div >> text="cableinfo.jpg"')).toBeVisible();
106+
await expect(page.locator('div >> text="cablechat.jpg"')).toBeHidden();
112107
}, 10000);
113108
});
114109

projects/angular-test-app/tests/e2e/MediaCo/portal.spec.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ test.describe('E2E test', () => {
105105
const todo = await page.locator('div[class="psdk-todo-assignments"]');
106106
await expect(todo).toBeVisible();
107107

108-
// Todo: This will be fixed as part of BUG-960405
109-
// const attachmentCount = await page.locator('div[id="attachments-count"]').textContent();
110-
// await expect(Number(attachmentCount)).toBeGreaterThan(0);
108+
await expect(page.locator('button[id="setting-button"] >> nth=0')).toBeVisible();
109+
110+
const attachmentCount = await page.locator('div[id="attachments-count"]').textContent();
111+
expect(Number(attachmentCount)).toBeGreaterThan(0);
111112
}, 10000);
112113

113114
test('should enter a discount value($) and send to tech', async ({ page }) => {

0 commit comments

Comments
 (0)