-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(elements/ino-range): migrate stencil e2e tests to playwright…
… tests (#1349) Part of #1258 ## Proposed Changes - migrate existing stencil e2e tests to jest spec tests --------- Co-authored-by: Jan-Niklas Voß <[email protected]>
- Loading branch information
Showing
13 changed files
with
130 additions
and
122 deletions.
There are no files selected for viewing
85 changes: 0 additions & 85 deletions
85
packages/elements/src/components/ino-range/ino-range.e2e.ts
This file was deleted.
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
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,13 @@ | ||
@import '../utils'; | ||
|
||
// only selects Stories of ino-fab-set without decorating stories with wrapper classes | ||
.sbdocs.sbdocs-content:has(#anchor--buttons-ino-fab-set--default) { | ||
[scale] { | ||
width: 100%; | ||
} | ||
} | ||
|
||
#root-inner { | ||
@include story-container { | ||
min-width: 10px; | ||
min-height: 10px; | ||
} |
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,12 +1,16 @@ | ||
@import '../utils'; | ||
|
||
.sbdocs.sbdocs-content:has(#anchor--input-ino-input--default) { | ||
[scale] { | ||
width: 100%; | ||
} | ||
|
||
#story--input-ino-input--states-inner #root-inner, | ||
#story--input-ino-input--labels-inner #root-inner { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 15px; | ||
#story--input-ino-input--states-inner, | ||
#story--input-ino-input--labels-inner { | ||
@include story-container { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 15px; | ||
} | ||
} | ||
} |
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,5 +1,11 @@ | ||
@import '../utils'; | ||
|
||
.sbdocs.sbdocs-content:has(#anchor--input-ino-range--default) { | ||
[scale] { | ||
width: 100%; | ||
} | ||
} | ||
|
||
@include story-container { | ||
min-width: 200px; | ||
} |
64 changes: 64 additions & 0 deletions
64
packages/storybook/src/stories/ino-range/ino-range.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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { expect, Page, test } from '@playwright/test'; | ||
import { goToStory, setAttribute } from '../test-utils'; | ||
|
||
test.describe('ino-range', () => { | ||
const move = async (page: Page, targetPercentage: number) => { | ||
const slider = page.locator('.mdc-slider'); | ||
const knob = slider.locator('.mdc-slider__thumb-knob'); | ||
const knobBox = await knob.boundingBox(); | ||
const sliderBox = await slider.boundingBox(); | ||
|
||
// Start from the middle of the slider's thumb | ||
const start = { | ||
x: knobBox.x + knobBox.width / 2, | ||
y: knobBox.y + knobBox.height / 2, | ||
}; | ||
// Slide it to some endpoint determined by the target percentage | ||
const end = { | ||
x: sliderBox.x + sliderBox.width * targetPercentage, | ||
y: knobBox.y + knobBox.height / 2, | ||
}; | ||
|
||
await page.mouse.move(start.x, start.y); | ||
await page.mouse.down(); | ||
await page.mouse.move(end.x, end.y); | ||
await page.mouse.up(); | ||
}; | ||
|
||
test('should not move thumb knob when is disabled', async ({ page }) => { | ||
await goToStory(page, ['Input', 'ino-range', 'default']); | ||
const inoRange = page.locator('ino-range'); | ||
const input = inoRange.getByRole('slider'); | ||
await expect(input).toHaveValue('70'); | ||
|
||
await setAttribute(inoRange, 'disabled', 'disabled'); | ||
await expect(input).toBeDisabled(); | ||
|
||
await move(page, 0.1); | ||
await expect(input).toHaveValue('70'); | ||
}); | ||
|
||
test('should move thumb knob', async ({ page }) => { | ||
await goToStory(page, ['Input', 'ino-range', 'default']); | ||
const input = page.getByRole('slider'); | ||
await expect(input).toHaveValue('70'); | ||
|
||
await move(page, 0.95); | ||
await expect(input).toHaveValue('95'); | ||
await move(page, 0.17); | ||
await expect(input).toHaveValue('17'); | ||
}); | ||
|
||
test('should apply custom step value', async ({ page }) => { | ||
await goToStory(page, ['Input', 'ino-range', 'default']); | ||
const inoRange = page.locator('ino-range'); | ||
await setAttribute(inoRange, 'step', '10'); | ||
const input = page.getByRole('slider'); | ||
await expect(input).toHaveValue('70'); | ||
|
||
await move(page, 0.61); | ||
await expect(input).toHaveValue('60'); | ||
await move(page, 0.86); | ||
await expect(input).toHaveValue('90'); | ||
}); | ||
}); |
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
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,9 @@ | ||
/** | ||
* Applies styling to the container of a story. | ||
* The styling is encapsulated within this mixin because the ID may change in the future. | ||
*/ | ||
@mixin story-container { | ||
#root-inner { | ||
@content; | ||
} | ||
} |