-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change allows the value to be set for the slider. The implemented behavior here is similar to the input/textarea value field. The value will update the value of the slider only if the value being passed in changes. This is for the following use cases: 1. Setting an initial value 2. Updating the value programmatically. For example if you wanted a textbox to control the slider value 3. Only updating the value if it changes, allows the slider to move smoothly (same issue as the text inputs)
- Loading branch information
1 parent
e598a7d
commit 3ec45e0
Showing
7 changed files
with
97 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,31 @@ | ||
import {test} from '@playwright/test'; | ||
import {test, expect} from '@playwright/test'; | ||
|
||
test('test', async ({page}) => { | ||
test('test slider behavior', async ({page}) => { | ||
await page.goto('/components/slider/e2e/slider_app'); | ||
await page.getByRole('slider').fill('57'); | ||
await page.getByRole('slider').click(); | ||
// TODO: fix the assertion (it's now flaky / off by 1) | ||
// expect(await page.getByText('Value: 57').textContent()).toContain( | ||
// 'Value: 57', | ||
// ); | ||
|
||
// Make sure the initial slider value is set to 50. | ||
const slider = await page.getByRole('slider'); | ||
expect(await slider.evaluate((el) => el.value)).toBe('50'); | ||
|
||
// Emulate moving the slider. | ||
await slider.evaluate((el, value) => { | ||
el.value = value; | ||
el.dispatchEvent(new Event('input', {bubbles: true})); | ||
el.dispatchEvent(new Event('change', {bubbles: true})); | ||
}, '20'); | ||
// Should update the slider value and the text. | ||
expect(await slider.evaluate((el) => el.value)).toBe('20'); | ||
expect(await page.getByText('Value: 20').textContent()).toContain( | ||
'Value: 20', | ||
); | ||
|
||
// Update the slider value via the textbox. | ||
await page.getByLabel('Slider value').fill('75'); | ||
// Need to wait for the input state to be saved first. | ||
await page.waitForTimeout(2000); | ||
// Should update the slider value and the text. | ||
expect(await slider.evaluate((el) => el.value)).toBe('75'); | ||
expect(await page.getByText('Value: 75').textContent()).toContain( | ||
'Value: 75', | ||
); | ||
}); |
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
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