-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fix(textarea): add reflect option to disabled and readonly props #30910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KillerCodeMonkey
wants to merge
4
commits into
ionic-team:main
Choose a base branch
from
KillerCodeMonkey:patch-3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+532
−206
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8e7d5b2
fix(textarea): add reflect option to disabled and readonly props
KillerCodeMonkey 2ba7cba
Merge branch 'ionic-team:main' into patch-3
KillerCodeMonkey a6a284f
fix(textarea): update api.txt
KillerCodeMonkey b333cb4
test(angular, react, vue): add reflect tests for inputs
thetaPC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -5,105 +5,126 @@ test.describe('Inputs', () => { | |
| await page.goto('/lazy/inputs'); | ||
| }); | ||
|
|
||
| test('should have default values', async ({ page }) => { | ||
| // Check primary elements for default values | ||
| await expect(page.locator('ion-checkbox').first()).toHaveJSProperty('checked', true); | ||
| await expect(page.locator('ion-radio-group').first()).toHaveJSProperty('value', 'nes'); | ||
| await expect(page.locator('ion-toggle').first()).toHaveJSProperty('checked', true); | ||
| await expect(page.locator('ion-input').first()).toHaveJSProperty('value', 'some text'); | ||
| await expect(page.locator('ion-input-otp').first()).toHaveJSProperty('value', '1234'); | ||
| await expect(page.locator('ion-datetime').first()).toHaveJSProperty('value', '1994-03-15'); | ||
| await expect(page.locator('ion-select').first()).toHaveJSProperty('value', 'nes'); | ||
| await expect(page.locator('ion-range').first()).toHaveJSProperty('value', 50); | ||
| }); | ||
| test.describe('basic functionality', () => { | ||
| test('should have default values', async ({ page }) => { | ||
| // Check primary elements for default values | ||
| await expect(page.locator('ion-checkbox').first()).toHaveJSProperty('checked', true); | ||
| await expect(page.locator('ion-radio-group').first()).toHaveJSProperty('value', 'nes'); | ||
| await expect(page.locator('ion-toggle').first()).toHaveJSProperty('checked', true); | ||
| await expect(page.locator('ion-input').first()).toHaveJSProperty('value', 'some text'); | ||
| await expect(page.locator('ion-input-otp').first()).toHaveJSProperty('value', '1234'); | ||
| await expect(page.locator('ion-datetime').first()).toHaveJSProperty('value', '1994-03-15'); | ||
| await expect(page.locator('ion-select').first()).toHaveJSProperty('value', 'nes'); | ||
| await expect(page.locator('ion-range').first()).toHaveJSProperty('value', 50); | ||
| }); | ||
|
|
||
| test('should reset values', async ({ page }) => { | ||
| await page.locator('#reset-button').click(); | ||
|
|
||
| // Check primary elements after reset | ||
| await expect(page.locator('ion-checkbox').first()).toHaveJSProperty('checked', false); | ||
| await expect(page.locator('ion-radio-group').first()).toHaveJSProperty('value', undefined); | ||
| await expect(page.locator('ion-toggle').first()).toHaveJSProperty('checked', false); | ||
| /** | ||
| * The `value` property gets set to undefined | ||
| * for these components, so we need to check | ||
| * that the value property is undefined. | ||
| */ | ||
| await expect(page.locator('ion-input').first()).toHaveJSProperty('value', undefined); | ||
| await expect(page.locator('ion-input-otp').first()).toHaveJSProperty('value', undefined); | ||
| await expect(page.locator('ion-datetime').first()).toHaveJSProperty('value', undefined); | ||
| await expect(page.locator('ion-select').first()).toHaveJSProperty('value', undefined); | ||
| await expect(page.locator('ion-range').first()).toHaveJSProperty('value', undefined); | ||
| }); | ||
| test('should reset values', async ({ page }) => { | ||
| await page.locator('#reset-button').click(); | ||
|
|
||
| // Check primary elements after reset | ||
| await expect(page.locator('ion-checkbox').first()).toHaveJSProperty('checked', false); | ||
| await expect(page.locator('ion-radio-group').first()).toHaveJSProperty('value', undefined); | ||
| await expect(page.locator('ion-toggle').first()).toHaveJSProperty('checked', false); | ||
| /** | ||
| * The `value` property gets set to undefined | ||
| * for these components, so we need to check | ||
| * that the value property is undefined. | ||
| */ | ||
| await expect(page.locator('ion-input').first()).toHaveJSProperty('value', undefined); | ||
| await expect(page.locator('ion-input-otp').first()).toHaveJSProperty('value', undefined); | ||
| await expect(page.locator('ion-datetime').first()).toHaveJSProperty('value', undefined); | ||
| await expect(page.locator('ion-select').first()).toHaveJSProperty('value', undefined); | ||
| await expect(page.locator('ion-range').first()).toHaveJSProperty('value', undefined); | ||
| }); | ||
|
|
||
| test('should set values', async ({ page }) => { | ||
| await page.locator('#reset-button').click(); | ||
| await page.locator('#set-button').click(); | ||
|
|
||
| // Check primary elements after setting values | ||
| await expect(page.locator('ion-checkbox').first()).toHaveJSProperty('checked', true); | ||
| await expect(page.locator('ion-radio-group').first()).toHaveJSProperty('value', 'nes'); | ||
| await expect(page.locator('ion-toggle').first()).toHaveJSProperty('checked', true); | ||
| await expect(page.locator('ion-input').first()).toHaveJSProperty('value', 'some text'); | ||
| await expect(page.locator('ion-input-otp').first()).toHaveJSProperty('value', '1234'); | ||
| await expect(page.locator('ion-datetime').first()).toHaveJSProperty('value', '1994-03-15'); | ||
| await expect(page.locator('ion-select').first()).toHaveJSProperty('value', 'nes'); | ||
| await expect(page.locator('ion-range').first()).toHaveJSProperty('value', 50); | ||
| }); | ||
| test('should set values', async ({ page }) => { | ||
| await page.locator('#reset-button').click(); | ||
| await page.locator('#set-button').click(); | ||
|
|
||
| // Check primary elements after setting values | ||
| await expect(page.locator('ion-checkbox').first()).toHaveJSProperty('checked', true); | ||
| await expect(page.locator('ion-radio-group').first()).toHaveJSProperty('value', 'nes'); | ||
| await expect(page.locator('ion-toggle').first()).toHaveJSProperty('checked', true); | ||
| await expect(page.locator('ion-input').first()).toHaveJSProperty('value', 'some text'); | ||
| await expect(page.locator('ion-input-otp').first()).toHaveJSProperty('value', '1234'); | ||
| await expect(page.locator('ion-datetime').first()).toHaveJSProperty('value', '1994-03-15'); | ||
| await expect(page.locator('ion-select').first()).toHaveJSProperty('value', 'nes'); | ||
| await expect(page.locator('ion-range').first()).toHaveJSProperty('value', 50); | ||
| }); | ||
|
|
||
| test('should update angular when values change', async ({ page }) => { | ||
| await page.locator('#reset-button').click(); | ||
|
|
||
| await page.locator('ion-checkbox#first-checkbox').click(); | ||
| await page.locator('ion-radio').first().click(); | ||
| await page.locator('ion-toggle').first().click(); | ||
|
|
||
| await page.locator('ion-input').nth(0).locator('input').fill('hola'); | ||
| await page.locator('ion-input').nth(0).locator('input').blur(); | ||
|
|
||
| await page.locator('ion-input-otp input').nth(0).fill('1'); | ||
| await page.locator('ion-input-otp input').nth(1).fill('2'); | ||
| await page.locator('ion-input-otp input').nth(2).fill('3'); | ||
| await page.locator('ion-input-otp input').nth(3).fill('4'); | ||
| await page.locator('ion-input-otp input').nth(3).blur(); | ||
|
|
||
| // Set date to 1994-03-14 | ||
| await page.locator('ion-datetime').first().click(); | ||
| await page.locator('ion-datetime').first().locator('.calendar-day:not([disabled])').first().click(); | ||
|
|
||
| await page.locator('ion-select#game-console').click(); | ||
| await expect(page.locator('ion-alert')).toBeVisible(); | ||
| // Playstation option | ||
| await page.locator('ion-alert .alert-radio-button').nth(3).click(); | ||
| // Click confirm button | ||
| await page.locator('ion-alert .alert-button:not(.alert-button-role-cancel)').click(); | ||
|
|
||
| // Check note text (Angular binding updates) | ||
| await expect(page.locator('#checkbox-note')).toHaveText('true'); | ||
| await expect(page.locator('#radio-note')).toHaveText('nes'); | ||
| await expect(page.locator('#toggle-note')).toHaveText('true'); | ||
| await expect(page.locator('#input-note')).toHaveText('hola'); | ||
| await expect(page.locator('#input-otp-note')).toHaveText('1234'); | ||
| await expect(page.locator('#datetime-note')).toHaveText('1994-03-14'); | ||
| await expect(page.locator('#select-note')).toHaveText('ps'); | ||
| }); | ||
| test('should update angular when values change', async ({ page }) => { | ||
| await page.locator('#reset-button').click(); | ||
|
|
||
| test('should update values when erasing input', async ({ page }) => { | ||
| // Focus the input and press backspace to remove last character | ||
| await page.locator('ion-input').nth(0).locator('input').click(); | ||
| await page.locator('ion-input').nth(0).locator('input').press('Backspace'); | ||
| // Check mirror element reflects the change | ||
| await expect(page.locator('ion-input').nth(1)).toHaveJSProperty('value', 'some tex'); | ||
| // Check note text (Angular binding) | ||
| await expect(page.locator('#input-note')).toHaveText('some tex'); | ||
|
|
||
| // Focus the last OTP input and press backspace | ||
| await page.locator('ion-input-otp input').last().click(); | ||
| await page.locator('ion-input-otp input').last().press('Backspace'); | ||
| // Check mirror element reflects the change | ||
| await expect(page.locator('ion-input-otp').nth(1)).toHaveJSProperty('value', '123'); | ||
| // Check note text (Angular binding) | ||
| await expect(page.locator('#input-otp-note')).toHaveText('123'); | ||
| await page.locator('ion-checkbox#first-checkbox').click(); | ||
| await page.locator('ion-radio').first().click(); | ||
| await page.locator('ion-toggle').first().click(); | ||
|
|
||
| await page.locator('ion-input').nth(0).locator('input').fill('hola'); | ||
| await page.locator('ion-input').nth(0).locator('input').blur(); | ||
|
|
||
| await page.locator('ion-input-otp input').nth(0).fill('1'); | ||
| await page.locator('ion-input-otp input').nth(1).fill('2'); | ||
| await page.locator('ion-input-otp input').nth(2).fill('3'); | ||
| await page.locator('ion-input-otp input').nth(3).fill('4'); | ||
| await page.locator('ion-input-otp input').nth(3).blur(); | ||
|
|
||
| // Set date to 1994-03-14 | ||
| await page.locator('ion-datetime').first().click(); | ||
| await page.locator('ion-datetime').first().locator('.calendar-day:not([disabled])').first().click(); | ||
|
|
||
| await page.locator('ion-select#game-console').click(); | ||
| await expect(page.locator('ion-alert')).toBeVisible(); | ||
| // Playstation option | ||
| await page.locator('ion-alert .alert-radio-button').nth(3).click(); | ||
| // Click confirm button | ||
| await page.locator('ion-alert .alert-button:not(.alert-button-role-cancel)').click(); | ||
|
|
||
| // Check note text (Angular binding updates) | ||
| await expect(page.locator('#checkbox-note')).toHaveText('true'); | ||
| await expect(page.locator('#radio-note')).toHaveText('nes'); | ||
| await expect(page.locator('#toggle-note')).toHaveText('true'); | ||
| await expect(page.locator('#input-note')).toHaveText('hola'); | ||
| await expect(page.locator('#input-otp-note')).toHaveText('1234'); | ||
| await expect(page.locator('#datetime-note')).toHaveText('1994-03-14'); | ||
| await expect(page.locator('#select-note')).toHaveText('ps'); | ||
| }); | ||
|
|
||
| test('should update values when erasing input', async ({ page }) => { | ||
| // Focus the input and press backspace to remove last character | ||
| await page.locator('ion-input').nth(0).locator('input').click(); | ||
| await page.locator('ion-input').nth(0).locator('input').press('Backspace'); | ||
| // Check mirror element reflects the change | ||
| await expect(page.locator('ion-input').nth(1)).toHaveJSProperty('value', 'some tex'); | ||
| // Check note text (Angular binding) | ||
| await expect(page.locator('#input-note')).toHaveText('some tex'); | ||
|
|
||
| // Focus the last OTP input and press backspace | ||
| await page.locator('ion-input-otp input').last().click(); | ||
| await page.locator('ion-input-otp input').last().press('Backspace'); | ||
| // Check mirror element reflects the change | ||
| await expect(page.locator('ion-input-otp').nth(1)).toHaveJSProperty('value', '123'); | ||
| // Check note text (Angular binding) | ||
| await expect(page.locator('#input-otp-note')).toHaveText('123'); | ||
| }); | ||
|
|
||
| test('should reflect props when component has a default value', async ({ page }) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the new test added. |
||
| // Disable inputs | ||
| await page.locator('#disable-button').click(); | ||
|
|
||
| // Disabled prop | ||
| await expect(page.locator('ion-input').first()).toHaveAttribute('disabled', ''); | ||
| await expect(page.locator('ion-input-otp').first()).toHaveAttribute('disabled', ''); | ||
| await expect(page.locator('ion-textarea').first()).toHaveAttribute('disabled', ''); | ||
|
|
||
| // Reset disabled state and set readonly state | ||
| await page.locator('#disable-button').click(); | ||
| await page.locator('#readonly-button').click(); | ||
|
|
||
| // Readonly prop | ||
| await expect(page.locator('ion-input').first()).toHaveAttribute('readonly', ''); | ||
| await expect(page.locator('ion-input-otp').first()).toHaveAttribute('readonly', ''); | ||
| await expect(page.locator('ion-textarea').first()).toHaveAttribute('readonly', ''); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('updating text input refs', () => { | ||
|
|
||
28 changes: 28 additions & 0 deletions
28
packages/angular/test/base/e2e/src/standalone/inputs.spec.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
|
|
||
| test.describe('Inputs', () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto('/standalone/inputs'); | ||
| }); | ||
|
|
||
| test.describe('basic functionality', () => { | ||
| test('should reflect props when component has a default value', async ({ page }) => { | ||
| // Disable inputs | ||
| await page.locator('#disable-button').click(); | ||
|
|
||
| // Disabled prop | ||
| await expect(page.locator('ion-input')).toHaveAttribute('disabled', ''); | ||
| await expect(page.locator('ion-input-otp')).toHaveAttribute('disabled', ''); | ||
| await expect(page.locator('ion-textarea')).toHaveAttribute('disabled', ''); | ||
|
|
||
| // Reset disabled state and set readonly state | ||
| await page.locator('#disable-button').click(); | ||
| await page.locator('#readonly-button').click(); | ||
|
|
||
| // Readonly prop | ||
| await expect(page.locator('ion-input')).toHaveAttribute('readonly', ''); | ||
| await expect(page.locator('ion-input-otp')).toHaveAttribute('readonly', ''); | ||
| await expect(page.locator('ion-textarea')).toHaveAttribute('readonly', ''); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like a lot of changes but I only moved the tests under a
describe.