-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from TRIPTYK/feature/tk-ui-64
fix: add ...attributes on the right element + add css for prefab password error + add test for attributes + add tabindex on button show/hide password
- Loading branch information
Showing
10 changed files
with
209 additions
and
140 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
...ation/components/ember-input-validation/generic-test-functions/setup-prefab-component.gts
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 { render } from "@ember/test-helpers"; | ||
import { initializeParams, type TpkFormParams } from './initialize-params-tpk-form'; | ||
import TpkForm from '@triptyk/ember-input-validation/components/tpk-form'; | ||
|
||
export async function setupCompletePrefabComponent(params?: TpkFormParams) { | ||
const { changeset, onSubmit, validationSchema, reactive, removeErrorsOnSubmit, autoScrollOnError, executeOnValid } = initializeParams(params); | ||
const selectOptions = ['option1', 'option2']; | ||
const onCreate = () => {}; | ||
const onSearch = () => {}; | ||
await render( | ||
<template> | ||
<TpkForm | ||
@changeset={{changeset}} | ||
@validationSchema={{validationSchema}} | ||
@onSubmit={{onSubmit}} | ||
@reactive={{reactive}} | ||
@autoScrollOnError={{autoScrollOnError}} | ||
@removeErrorsOnSubmit={{removeErrorsOnSubmit}} | ||
@executeOnValid={{executeOnValid}} | ||
as |F|> | ||
<F.TpkInputPrefab @label="test" @validationField="input" class="custom-class"/> | ||
<F.TpkBicPrefab @label="test" @validationField="bic" class="custom-class"/> | ||
<F.TpkIbanPrefab @label="test" @validationField="iban" class="custom-class"/> | ||
<F.TpkEmailPrefab @label="test" @validationField="email" class="custom-class"/> | ||
<F.TpkMobilePrefab @label="test" @validationField="mobile" class="custom-class"/> | ||
<F.TpkDatepickerPrefab @label="test" @validationField="datepicker" class="custom-class"/> | ||
<F.TpkTimepickerPrefab @label="test" @validationField="timepicker" class="custom-class"/> | ||
<F.TpkCurrencyPrefab @label="test" @validationField="currency" class="custom-class"/> | ||
<F.TpkIntegerPrefab @label="test" @validationField="integer" class="custom-class"/> | ||
<F.TpkNumberPrefab @label="test" @validationField="number" class="custom-class"/> | ||
<F.TpkPasswordPrefab @label="test" @validationField="password" class="custom-class"/> | ||
<F.TpkRadioPrefab @label="test" @validationField="radio" @value="radio" class="custom-class" /> | ||
<F.TpkRadioGroupPrefab @label="test" @validationField="radiogroup" class="custom-class" as |Radio|> | ||
<Radio @value="radio1" @label="Radio 1" /> | ||
<Radio @value="radio2" @label="Radio 2" /> | ||
</F.TpkRadioGroupPrefab> | ||
<F.TpkSelectPrefab @label="test" @validationField="select" @options={{selectOptions}} class="custom-class" /> | ||
<F.TpkSelectCreatePrefab @label="test" @validationField="selectcreate" @options={{selectOptions}} @onCreate={{onCreate}} class="custom-class" /> | ||
<F.TpkSelectSearchPrefab @label="test" @validationField="selectsearch" @options={{selectOptions}} @onSearch={{onSearch}} class="custom-class" /> | ||
<F.TpkCheckboxPrefab @label="test" @validationField="checkbox" class="custom-class" /> | ||
<F.TpkFilePrefab @label="test" @validationField="file" class="custom-class" /> | ||
<button type="submit">Submit</button> | ||
</TpkForm> | ||
</template> | ||
); | ||
|
||
return changeset; | ||
} | ||
|
||
export async function setupComponent(params?: TpkFormParams) { | ||
const { changeset, onSubmit, validationSchema, reactive, removeErrorsOnSubmit, autoScrollOnError, executeOnValid } = initializeParams(params); | ||
|
||
await render( | ||
<template> | ||
<TpkForm | ||
@changeset={{changeset}} | ||
@validationSchema={{validationSchema}} | ||
@onSubmit={{onSubmit}} | ||
@reactive={{reactive}} | ||
@autoScrollOnError={{autoScrollOnError}} | ||
@removeErrorsOnSubmit={{removeErrorsOnSubmit}} | ||
@executeOnValid={{executeOnValid}} | ||
as |F|> | ||
<F.TpkInputPrefab @label="test" @validationField="name" /> | ||
<F.TpkInput @label="test" @type="email" @validationField="email" as |I|> | ||
<I.Label /> | ||
<I.Input anchorScrollUp="email" /> | ||
</F.TpkInput> | ||
<button type="submit">Submit</button> | ||
</TpkForm> | ||
</template> | ||
); | ||
|
||
return changeset; | ||
} |
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
83 changes: 83 additions & 0 deletions
83
doc-app/tests/integration/components/ember-input-validation/tpk-attributes-test.gts
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,83 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { setupIntl } from 'ember-intl/test-support'; | ||
import { ImmerChangeset } from 'ember-immer-changeset'; | ||
import { object, string, date, number, boolean } from 'yup'; | ||
import { setupCompletePrefabComponent } from './generic-test-functions/setup-prefab-component'; | ||
|
||
module('Integration | Component | tpk-attributes', function (hooks) { | ||
setupRenderingTest(hooks); | ||
setupIntl(hooks, 'fr-fr'); | ||
const prefabs = [ | ||
'input', | ||
'bic', | ||
'iban', | ||
'email', | ||
'mobile', | ||
'datepicker', | ||
'timepicker', | ||
'currency', | ||
'integer', | ||
'number', | ||
'password', | ||
'radio-group', | ||
'radio', | ||
'select', | ||
'select-create', | ||
'select-search', | ||
'checkbox', | ||
'file', | ||
]; | ||
|
||
const validationSchema = object().shape({ | ||
input: string().required(), | ||
bic: string().required(), | ||
iban: string().required(), | ||
email: string().required(), | ||
mobile: string().required(), | ||
datepicker: date().required(), | ||
timepicker: date().required(), | ||
currency: number().required(), | ||
integer: number().required(), | ||
number: number().required(), | ||
password: string().required(), | ||
radiogroup: string().required(), | ||
radio: string().required(), | ||
select: string().required(), | ||
selectcreate: string().required(), | ||
selectsearch: string().required(), | ||
checkbox: boolean().required(), | ||
file: string().required(), | ||
}); | ||
|
||
const baseChangeset = new ImmerChangeset({ | ||
input: '', | ||
bic: '', | ||
iban: '', | ||
email: '', | ||
mobile: '', | ||
datepicker: null, | ||
timepicker: null, | ||
currency: 0, | ||
integer: 0, | ||
number: 0, | ||
password: '', | ||
radiogroup: '', | ||
radio: '', | ||
select: '', | ||
selectcreate: '', | ||
selectsearch: '', | ||
checkbox: false, | ||
file: '', | ||
}); | ||
|
||
for (const prefab of prefabs) { | ||
test(`Attributes should be passed to the container for ${prefab}`, async function (assert) { | ||
await setupCompletePrefabComponent({ | ||
changeset: baseChangeset, | ||
validationSchema, | ||
}); | ||
assert.dom(`[data-test-tpk-prefab-${prefab}-container]`).hasClass('custom-class'); | ||
}); | ||
} | ||
}); |
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
Oops, something went wrong.