Skip to content

Commit

Permalink
wip: testit kuntoon
Browse files Browse the repository at this point in the history
  • Loading branch information
ilkkahanninen committed Jan 9, 2025
1 parent f6e9b37 commit 9685eaa
Show file tree
Hide file tree
Showing 27 changed files with 1,769 additions and 285 deletions.
2 changes: 1 addition & 1 deletion web/app/components-v2/controls/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const Checkbox: React.FC<CheckboxProps> = (props) => {
onChange={(event) => props.onChange(event.target.checked)}
data-testid={testId}
/>
<label htmlFor={id}>
<label htmlFor={id} onClick={() => props.onChange(!props.checked)}>
<span className="Checkbox__label">{t(props.label)}</span>
</label>
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/app/components-v2/opiskeluoikeus/ArvosanaField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const ArvosanaEdit = <T extends Arviointi>(
options={groupedKoodisto as OptionList<ArvosanaOf<T>>}
onChange={onChange}
disabled={props.disabled}
testId="arvosana.edit"
testId={`${props.testId || 'arvosana'}.edit`}
/>
)
)
Expand Down
15 changes: 9 additions & 6 deletions web/app/components-v2/opiskeluoikeus/KoodistoField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { t } from '../../i18n/i18n'
import { Koodistokoodiviite } from '../../types/fi/oph/koski/schema/Koodistokoodiviite'
import { CommonProps, common } from '../CommonProps'
import { FieldEditorProps, FieldViewerProps } from '../forms/FormField'
import { TestIdLayer } from '../../appstate/useTestId'
import { TestIdLayer, useTestId } from '../../appstate/useTestId'
import {
Select,
SelectOption,
Expand All @@ -24,11 +24,14 @@ export type KoodistoViewProps<T extends string> = CommonProps<
>
>

export const KoodistoView = <T extends string>(props: KoodistoViewProps<T>) => (
<div {...common(props)} data-testid={props.testId}>
{t(props.value?.nimi) || '–'}
</div>
)
export const KoodistoView = <T extends string>(props: KoodistoViewProps<T>) => {
const testId = useTestId(props.testId)
return (
<div {...common(props)} data-testid={testId}>
{t(props.value?.nimi) || '–'}
</div>
)
}

export type KoodistoEditProps<T extends string> = CommonProps<
FieldEditorProps<
Expand Down
20 changes: 9 additions & 11 deletions web/app/components-v2/opiskeluoikeus/KoodistoSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,14 @@ export function KoodistoSelect<T extends string>(
)

return (
<TestIdLayer id="addOsasuoritus">
<Select
inlineOptions={props.inlineOptions}
placeholder={props.addNewText}
options={options}
hideEmpty
onChange={onChangeCB}
testId="select"
value={props.value}
/>
</TestIdLayer>
<Select
inlineOptions={props.inlineOptions}
placeholder={props.addNewText}
options={options}
hideEmpty
onChange={onChangeCB}
testId={props.testId}
value={props.value}
/>
)
}
17 changes: 10 additions & 7 deletions web/app/components-v2/opiskeluoikeus/OpiskeluoikeudenTila.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,16 @@ export const OpiskeluoikeudenTilaView = <T extends OpiskeluoikeudenTila>(
</TestIdText>
</time>,
<React.Fragment key={`jakso_tila_lisatiedot_${index}`}>
<TestIdText id="tila">
<span>{t(jakso.tila.nimi)}</span>
<span>
{isRahoituksellinenOpiskeluoikeusjakso(jakso) &&
` (${t(jakso.opintojenRahoitus?.nimi)})`}
</span>
</TestIdText>
<TestIdText id="tila">{t(jakso.tila.nimi)}</TestIdText>
{isRahoituksellinenOpiskeluoikeusjakso(jakso) && (
<>
{' ('}
<TestIdText id="rahoitus">
{t(jakso.opintojenRahoitus?.nimi)}
</TestIdText>
{')'}
</>
)}
</React.Fragment>
]}
</KeyColumnedValuesRow>
Expand Down
Loading

0 comments on commit 9685eaa

Please sign in to comment.