Repository navigation
feat(angular): apply form status classes with signal forms #31813
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ab08e6f
fix(angular): set ionic form status classes for signal forms controls
ShaneK f4705ea
fix(angular): sync ionic form classes when async validators settle wi…
ShaneK 20a4568
Merge branch 'feature-9.1' of github.com:ionic-team/ionic-framework i…
ShaneK 2c2826e
fix(angular): build ionic form classes from the element's own control
ShaneK ab96a9d
Merge branch 'feature-9.1' into FW-7897
ShaneK 72017ce
test(angular): wait for animation frame before asserting ionic form c…
ShaneK dfb7d3d
Merge branch 'feature-9.1' into FW-7897
ShaneK 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
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
33 changes: 33 additions & 0 deletions
33
packages/angular/test/apps/ng21/e2e/src/lazy/signal-forms.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,33 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
|
|
||
| test.describe('Signal Forms: lazy', () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto('/lazy/version-test/signal-forms'); | ||
| }); | ||
|
|
||
| test('should show the error text after the form is marked as touched', async ({ page }) => { | ||
| const name = page.locator('ion-input#name'); | ||
|
|
||
| await page.locator('ion-button#submit').click(); | ||
|
|
||
| await expect(name).toHaveClass(/\bion-touched\b/); | ||
| await expect(name).toHaveClass(/\bion-invalid\b/); | ||
| await expect(name.locator('.error-text')).toBeVisible(); | ||
| }); | ||
|
|
||
| test('should keep the status classes when the model checks a checkbox or toggle', async ({ page }) => { | ||
| const terms = page.locator('ion-checkbox#terms'); | ||
| const notifications = page.locator('ion-toggle#notifications'); | ||
|
|
||
| await page.locator('ion-button#submit').click(); | ||
| await expect(terms).toHaveClass(/\bion-touched\b/); | ||
| await expect(notifications).toHaveClass(/\bion-touched\b/); | ||
|
|
||
| await page.locator('ion-button#check-all').click(); | ||
|
|
||
| await expect(terms).toHaveJSProperty('checked', true); | ||
| await expect(notifications).toHaveJSProperty('checked', true); | ||
| await expect(terms).toHaveClass(/\bion-touched\b/); | ||
| await expect(notifications).toHaveClass(/\bion-touched\b/); | ||
| }); | ||
| }); |
88 changes: 88 additions & 0 deletions
88
packages/angular/test/apps/ng21/e2e/src/standalone/signal-forms.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,88 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
|
|
||
| // The classes come from the control state, so opting into Angular's `ng-*` classes must not change them. | ||
| const pages = [ | ||
| { title: 'without NG_STATUS_CLASSES', path: '/standalone/version-test/signal-forms' }, | ||
| { title: 'with NG_STATUS_CLASSES', path: '/standalone/version-test/signal-forms-status-classes' }, | ||
| ]; | ||
|
|
||
| for (const { title, path } of pages) { | ||
| test.describe(`Signal Forms: ${title}`, () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto(path); | ||
| }); | ||
|
|
||
| test('should show the error text after the form is marked as touched', async ({ page }) => { | ||
| const name = page.locator('ion-input#name'); | ||
|
|
||
| await page.locator('ion-button#submit').click(); | ||
|
|
||
| await expect(name).toHaveClass(/\bion-touched\b/); | ||
| await expect(name).toHaveClass(/\bion-invalid\b/); | ||
| await expect(name.locator('.error-text')).toBeVisible(); | ||
| }); | ||
|
|
||
| test('should update validity when it changes from another field', async ({ page }) => { | ||
| const confirm = page.locator('ion-input#confirm'); | ||
|
|
||
| await expect(confirm).toHaveClass(/\bion-valid\b/); | ||
|
|
||
| await page.locator('ion-input#password input').fill('a'); | ||
|
|
||
| await expect(confirm).toHaveClass(/\bion-invalid\b/); | ||
|
|
||
| await page.locator('ion-input#confirm input').fill('a'); | ||
|
|
||
| await expect(confirm).toHaveClass(/\bion-valid\b/); | ||
| }); | ||
|
|
||
| test('should keep the status classes after more typing and another blur', async ({ page }) => { | ||
| const name = page.locator('ion-input#name'); | ||
| const nativeInput = name.locator('input'); | ||
|
|
||
| await nativeInput.pressSequentially('ab'); | ||
| await nativeInput.blur(); | ||
| await nativeInput.focus(); | ||
| await nativeInput.blur(); | ||
|
|
||
| await expect(name).toHaveClass(/\bion-touched\b/); | ||
| await expect(name).toHaveClass(/\bion-dirty\b/); | ||
| await expect(name).toHaveClass(/\bion-valid\b/); | ||
| }); | ||
|
|
||
| test('should keep the status classes when the model checks a checkbox or toggle', async ({ page }) => { | ||
| const terms = page.locator('ion-checkbox#terms'); | ||
| const notifications = page.locator('ion-toggle#notifications'); | ||
|
|
||
| await page.locator('ion-button#submit').click(); | ||
| await expect(terms).toHaveClass(/\bion-touched\b/); | ||
| await expect(notifications).toHaveClass(/\bion-touched\b/); | ||
|
|
||
| await page.locator('ion-button#check-all').click(); | ||
|
|
||
| await expect(terms).toHaveJSProperty('checked', true); | ||
| await expect(notifications).toHaveJSProperty('checked', true); | ||
| await expect(terms).toHaveClass(/\bion-touched\b/); | ||
| await expect(notifications).toHaveClass(/\bion-touched\b/); | ||
| }); | ||
|
|
||
| test('should mark a field as pending, not valid or invalid, while async validation is running', async ({ page }) => { | ||
| const username = page.locator('ion-input#username'); | ||
|
|
||
| await expect(username).toHaveClass(/\bion-pending\b/); | ||
| await expect(username).not.toHaveClass(/\bion-valid\b/); | ||
| await expect(username).not.toHaveClass(/\bion-invalid\b/); | ||
| }); | ||
|
|
||
| test('should remove the pending class after async validation finishes', async ({ page }) => { | ||
| const username = page.locator('ion-input#username'); | ||
|
|
||
| await expect(username).toHaveClass(/\bion-pending\b/); | ||
|
|
||
| await page.locator('ion-button#settle-username').click(); | ||
|
|
||
| await expect(username).toHaveClass(/\bion-valid\b/); | ||
| await expect(username).not.toHaveClass(/\bion-pending\b/); | ||
| }); | ||
| }); | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.