-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kit):
InputPhone
should erase value on blur if it's just countr…
…y code (#6214)
- Loading branch information
1 parent
0517d31
commit 0b0abe9
Showing
3 changed files
with
82 additions
and
21 deletions.
There are no files selected for viewing
90 changes: 74 additions & 16 deletions
90
projects/demo-playwright/tests/kit/input-phone/input-phone.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,85 @@ | ||
import {TuiDocumentationPagePO, tuiGoto, TuiInputPhonePO} from '@demo-playwright/utils'; | ||
import {expect, test} from '@playwright/test'; | ||
import {expect, Locator, test} from '@playwright/test'; | ||
|
||
const {describe} = test; | ||
const {beforeEach, describe} = test; | ||
|
||
describe(`InputPhone`, () => { | ||
test(`Don't duplicate Code 52 When Inputting Digit '2' After Clearing`, async ({ | ||
page, | ||
}) => { | ||
await tuiGoto( | ||
describe(`API page`, () => { | ||
let example: Locator; | ||
let inputPhone: TuiInputPhonePO; | ||
|
||
beforeEach(({page}) => { | ||
example = new TuiDocumentationPagePO(page).apiPageExample; | ||
inputPhone = new TuiInputPhonePO(example.locator(`tui-input-phone`)); | ||
}); | ||
|
||
test(`Don't duplicate Code 52 When Inputting Digit '2' After Clearing`, async ({ | ||
page, | ||
`components/input-phone/API?countryCode=%2B52&tuiTextfieldCleaner=true`, | ||
); | ||
}) => { | ||
await tuiGoto( | ||
page, | ||
`components/input-phone/API?countryCode=%2B52&tuiTextfieldCleaner=true`, | ||
); | ||
|
||
await inputPhone.textfield.fill(`52`); | ||
await expect(inputPhone.textfield).toHaveValue(`+52 (52`); | ||
|
||
await inputPhone.cleaner.click(); | ||
await expect(inputPhone.textfield).toHaveValue(`+52 `); | ||
|
||
await inputPhone.textfield.fill(`52`); | ||
await expect(inputPhone.textfield).toHaveValue(`+52 (52`); | ||
}); | ||
|
||
test(`Remove country prefix on blur if textfield does not contains any other symbols`, async ({ | ||
page, | ||
}) => { | ||
await tuiGoto( | ||
page, | ||
`components/input-phone/API?countryCode=%2B1&tuiTextfieldCleaner=true`, | ||
); | ||
|
||
await inputPhone.textfield.focus(); | ||
await expect(inputPhone.textfield).toHaveValue(`+1 `); | ||
|
||
await inputPhone.textfield.blur(); | ||
await expect(inputPhone.textfield).toHaveValue(``); | ||
|
||
await inputPhone.textfield.pressSequentially(`2125552368`); | ||
await expect(inputPhone.textfield).toHaveValue(`+1 (212) 555-23-68`); | ||
await inputPhone.textfield.blur(); | ||
await expect(inputPhone.textfield).toHaveValue(`+1 (212) 555-23-68`); | ||
|
||
await inputPhone.textfield.focus(); | ||
await inputPhone.cleaner.click(); | ||
await expect(inputPhone.textfield).toHaveValue(`+1 `); | ||
await inputPhone.textfield.blur(); | ||
await expect(inputPhone.textfield).toHaveValue(``); | ||
}); | ||
|
||
const {apiPageExample} = new TuiDocumentationPagePO(page); | ||
const input = new TuiInputPhonePO(apiPageExample.locator(`tui-input-phone`)); | ||
describe(`Angular form control is empty is textfield's value is just country code`, () => { | ||
beforeEach(async ({page}) => { | ||
await tuiGoto( | ||
page, | ||
`components/input-phone/API?countryCode=%2B1&tuiTextfieldCleaner=true&sandboxExpanded=true`, | ||
); | ||
}); | ||
|
||
await input.textfield.fill(`52`); | ||
await expect(input.textfield).toHaveValue(`+52 (52`); | ||
test(`Empty textfield => focus => textfield value is country code & form control is empty`, async () => { | ||
await inputPhone.textfield.focus(); | ||
await expect(inputPhone.textfield).toHaveValue(`+1 `); | ||
await expect(example).toContainText(`"testValue": ""`); | ||
}); | ||
|
||
await input.cleaner.click(); | ||
await expect(input.textfield).toHaveValue(`+52 `); | ||
test(`Click on cleaner => => textfield value is country code & form control is empty`, async () => { | ||
await inputPhone.textfield.pressSequentially(`2345`); | ||
await expect(inputPhone.textfield).toHaveValue(`+1 (234) 5`); | ||
await expect(example).toContainText(`"testValue": "+12345"`); | ||
|
||
await input.textfield.fill(`52`); | ||
await expect(input.textfield).toHaveValue(`+52 (52`); | ||
await inputPhone.cleaner.click(); | ||
await expect(inputPhone.textfield).toHaveValue(`+1 `); | ||
await expect(example).toContainText(`"testValue": ""`); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters