-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6001db
commit ab9cc5c
Showing
6 changed files
with
123 additions
and
94 deletions.
There are no files selected for viewing
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { type Page, type Locator, test, expect } from '@playwright/test'; | ||
import { getPlayground } from '../helpers'; | ||
|
||
function getFieldset(form: Locator) { | ||
return { | ||
name: form.locator('[name="name"]'), | ||
message: form.locator('[name="message"]'), | ||
validateName: form.locator('button:text("Validate Name")'), | ||
validateMessage: form.locator('button:text("Validate Message")'), | ||
updateMessage: form.locator('button:text("Update message")'), | ||
clearMessage: form.locator('button:text("Clear message")'), | ||
resetMessage: form.locator('button:text("Reset message")'), | ||
resetForm: form.locator('button:text("Reset form")'), | ||
}; | ||
} | ||
|
||
async function runValidationScenario(page: Page) { | ||
const playground = getPlayground(page); | ||
const fieldset = getFieldset(playground.container); | ||
|
||
await expect(playground.error).toHaveText(['', '']); | ||
|
||
await fieldset.validateName.click(); | ||
await expect(playground.error).toHaveText(['Name is required', '']); | ||
|
||
await fieldset.validateMessage.click(); | ||
await expect(playground.error).toHaveText([ | ||
'Name is required', | ||
'Message is required', | ||
]); | ||
|
||
await fieldset.updateMessage.click(); | ||
await expect(fieldset.name).toHaveValue(''); | ||
await expect(fieldset.message).toHaveValue('Hello World'); | ||
await expect(playground.error).toHaveText(['Name is required', '']); | ||
|
||
await fieldset.clearMessage.click(); | ||
await expect(fieldset.name).toHaveValue(''); | ||
await expect(fieldset.message).toHaveValue(''); | ||
await expect(playground.error).toHaveText([ | ||
'Name is required', | ||
'Message is required', | ||
]); | ||
|
||
await fieldset.resetMessage.click(); | ||
await expect(fieldset.name).toHaveValue(''); | ||
await expect(fieldset.message).toHaveValue(''); | ||
await expect(playground.error).toHaveText(['Name is required', '']); | ||
|
||
await fieldset.resetForm.click(); | ||
await expect(fieldset.name).toHaveValue(''); | ||
await expect(fieldset.message).toHaveValue(''); | ||
await expect(playground.error).toHaveText(['', '']); | ||
} | ||
|
||
test.describe('With JS', () => { | ||
test('Client Validation', async ({ page }) => { | ||
await page.goto('/intent'); | ||
await runValidationScenario(page); | ||
}); | ||
|
||
test('Server Validation', async ({ page }) => { | ||
await page.goto('/intent?noClientValidate=yes'); | ||
await runValidationScenario(page); | ||
}); | ||
}); | ||
|
||
test.describe('No JS', () => { | ||
test.use({ javaScriptEnabled: false }); | ||
|
||
test('Validation', async ({ page }) => { | ||
await page.goto('/intent'); | ||
await runValidationScenario(page); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.