-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cypress): add index to fill command
- Loading branch information
1 parent
2b552a8
commit 1e93f0c
Showing
6 changed files
with
51 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useState } from 'react' | ||
|
||
import { Output } from '../../../.storybook/components/Output' | ||
import { StoryBox } from '../../../.storybook/components/StoryBox' | ||
import { useFieldControl, type TextInputProps, TextInput } from '../../../src' | ||
import { mountAndWait, outputShouldBe, outputShouldNotBe } from '../utils' | ||
|
||
function TextInputStory({ value, ...otherProps }: TextInputProps) { | ||
const [outputValue, setOutputValue] = useState<string | undefined | '∅'>('∅') | ||
|
||
const { controlledOnChange, controlledValue } = useFieldControl(value, setOutputValue) | ||
|
||
return ( | ||
<> | ||
<TextInput {...otherProps} value={controlledValue} /> | ||
<TextInput {...otherProps} onChange={controlledOnChange} value={controlledValue} /> | ||
|
||
{outputValue !== '∅' && <Output value={outputValue} />} | ||
</> | ||
) | ||
} | ||
|
||
context('Fill', () => { | ||
const commonProps: TextInputProps = { | ||
label: 'A text input', | ||
name: 'myTextInput' | ||
} | ||
|
||
it('Should fill the second input', () => { | ||
mountAndWait( | ||
<StoryBox> | ||
<TextInputStory {...commonProps} /> | ||
</StoryBox> | ||
) | ||
|
||
outputShouldNotBe() | ||
|
||
cy.fill('A text input', 'abcd', { index: 1 }) | ||
|
||
outputShouldBe('abcd') | ||
}) | ||
}) |
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,6 @@ | ||
export const DEFAULT_OPTIONS: Cypress.FillOptions = { | ||
delay: 10, | ||
force: true, | ||
index: 0, | ||
retries: 5 | ||
} |
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