Skip to content

Commit e8a1ad8

Browse files
authored
feat: Allow rename of MERIT tasks (M2-10595) (#2206)
πŸ”— [Jira Ticket M2-10595](https://mindlogger.atlassian.net/browse/M2-10595) Changes include: - Add `<NameDescription />` to enable editing MERIT task name and description.
1 parent 261cbe8 commit e8a1ad8

8 files changed

Lines changed: 27 additions & 12 deletions

File tree

β€Žsrc/modules/Builder/features/PerformanceTasks/Flanker/Flanker.tsxβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import { RoundSettings } from './RoundSettings';
1212
export const Flanker = () => {
1313
const { t } = useTranslation();
1414

15+
const dataTestid = 'builder-activity-flanker';
16+
1517
return (
1618
<Box sx={{ overflowY: 'auto' }}>
1719
<StyledPerformanceTaskBody sx={{ p: theme.spacing(2.4, 6.4) }}>
1820
<StyledHeadlineLarge sx={{ mb: theme.spacing(3) }}>{t('flanker')}</StyledHeadlineLarge>
19-
<NameDescription />
21+
<NameDescription data-testid={dataTestid} />
2022
<GeneralSettings />
2123
<RoundSettings uiType={RoundTypeEnum.Practice} />
2224
<RoundSettings uiType={RoundTypeEnum.Test} />

β€Žsrc/modules/Builder/features/PerformanceTasks/GyroscopeAndTouch/GyroscopeAndTouch.test.tsxβ€Ž

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ describe('GyroscopeAndTouch', () => {
199199
test('Panels: are rendered correctly', () => {
200200
renderGyroscopeOrTouch(isGyroscope);
201201

202-
expect(screen.getByTestId('builder-activity-flanker-common')).toBeVisible();
202+
expect(screen.getByTestId(`${mockedTestid}-common`)).toBeVisible();
203203
expect(screen.getByTestId(mockedTestid)).toBeVisible();
204204
expect(screen.getByTestId(`${mockedTestid}-overview-instruction`));
205205
expect(screen.getByTestId(`${mockedTestid}-practice-round-instruction`));
@@ -210,11 +210,11 @@ describe('GyroscopeAndTouch', () => {
210210
renderGyroscopeOrTouch(isGyroscope);
211211
expandAllPanels();
212212

213+
expect(screen.getByTestId(`${mockedTestid}-name`).querySelector('input')).toHaveValue(
214+
isGyroscope ? 'CST Gyroscope' : 'CST Touch',
215+
);
213216
expect(
214-
screen.getByTestId('builder-activity-flanker-name').querySelector('input'),
215-
).toHaveValue(isGyroscope ? 'CST Gyroscope' : 'CST Touch');
216-
expect(
217-
screen.getByTestId('builder-activity-flanker-description').querySelector('textarea'),
217+
screen.getByTestId(`${mockedTestid}-description`).querySelector('textarea'),
218218
).toHaveTextContent(
219219
`This Activity contains Stability Tracker (${isGyroscope ? 'Gyroscope' : 'Touch'}) Item.`,
220220
);
@@ -265,7 +265,7 @@ describe('GyroscopeAndTouch', () => {
265265

266266
test.each`
267267
testId | inputType | error | description
268-
${'builder-activity-flanker-name'} | ${'input'} | ${'Activity Name is required'} | ${'Validation: Activity Name is required'}
268+
${`${mockedTestid}-name`} | ${'input'} | ${'Activity Name is required'} | ${'Validation: Activity Name is required'}
269269
${`${mockedTestid}-overview-instruction-instruction`} | ${'textarea'} | ${'Overview Instruction is required'} | ${'Validation: Overview Instruction is required'}
270270
${`${mockedTestid}-practice-round-instruction-instruction`} | ${'textarea'} | ${'Practice Round Instruction is required'} | ${'Validation: Practice Round Instruction is required'}
271271
${`${mockedTestid}-test-round-instruction-instruction`} | ${'textarea'} | ${'Test Round Instruction is required'} | ${'Validation: Test Round Instruction is required'}

β€Žsrc/modules/Builder/features/PerformanceTasks/GyroscopeAndTouch/GyroscopeAndTouch.tsxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const GyroscopeAndTouch = ({ type }: GyroscopeAndTouchProps) => {
2020
<Box sx={{ overflowY: 'auto' }}>
2121
<StyledPerformanceTaskBody sx={{ p: theme.spacing(2.4, 6.4) }}>
2222
<StyledHeadlineLarge sx={{ mb: theme.spacing(3) }}>{t(type || '')}</StyledHeadlineLarge>
23-
<NameDescription />
23+
<NameDescription data-testid={dataTestid} />
2424
<GeneralSettings />
2525
<StyledTitleLarge sx={{ mb: theme.spacing(2.4) }}>{t('instructions')}</StyledTitleLarge>
2626
<Instruction

β€Žsrc/modules/Builder/features/PerformanceTasks/NameDescription/NameDescription.tsxβ€Ž

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@ import { useTranslation } from 'react-i18next';
33
import { ToggleContainerUiType, ToggleItemContainer } from 'modules/Builder/components';
44

55
import { NameDescriptionContent } from './NameDescriptionContent';
6+
import { NameDescriptionProps } from './NameDescription.types';
67

7-
export const NameDescription = () => {
8+
export const NameDescription = ({ 'data-testid': dataTestid }: NameDescriptionProps) => {
89
const { t } = useTranslation();
910

1011
return (
1112
<ToggleItemContainer
1213
uiType={ToggleContainerUiType.PerformanceTask}
1314
title={t('nameAndDescription')}
1415
Content={NameDescriptionContent}
16+
contentProps={{ 'data-testid': dataTestid }}
1517
headerToggling
16-
data-testid="builder-activity-flanker-common"
18+
data-testid={`${dataTestid}-common`}
1719
/>
1820
);
1921
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export type NameDescriptionProps = {
2+
'data-testid'?: string;
3+
};

β€Žsrc/modules/Builder/features/PerformanceTasks/NameDescription/NameDescriptionContent/NameDescriptionContent.tsxβ€Ž

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ import { useCurrentActivity, useCustomFormContext } from 'modules/Builder/hooks'
66
import { InputController } from 'shared/components/FormComponents';
77
import { MAX_NAME_LENGTH, MAX_DESCRIPTION_LENGTH, TEXTAREA_ROWS_COUNT } from 'shared/consts';
88

9-
export const NameDescriptionContent = () => {
9+
import { NameDescriptionContentProps } from './NameDescriptionContent.types';
10+
11+
export const NameDescriptionContent = ({
12+
'data-testid': dataTestid,
13+
}: NameDescriptionContentProps) => {
1014
const { t } = useTranslation();
1115
const { control } = useCustomFormContext();
1216
const { fieldName } = useCurrentActivity();
1317

14-
const dataTestid = 'builder-activity-flanker';
1518
const commonProps = {
1619
control,
1720
fullWidth: true,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export type NameDescriptionContentProps = {
2+
'data-testid'?: string;
3+
};

β€Žsrc/modules/Builder/features/PerformanceTasks/Unity/Unity.tsxβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ToggleContainerUiType, ToggleItemContainer } from 'modules/Builder/comp
77
import { Svg } from 'shared/components';
88
import { useCurrentActivity, useCustomFormContext } from 'modules/Builder/hooks';
99

10+
import { NameDescription } from '../NameDescription';
1011
import { StyledPerformanceTaskBody } from '../PerformanceTasks.styles';
1112
import UnityFileModal from './UnityFileModal/UnityFileModal';
1213
import { UnityFilePreview } from './UnityFilePreview';
@@ -92,6 +93,7 @@ export const Unity = () => {
9293
<StyledHeadlineLarge sx={{ mb: theme.spacing(3) }}>
9394
{t('performanceTasks.unity')}
9495
</StyledHeadlineLarge>
96+
<NameDescription data-testid={dataTestid} />
9597
<StyledTitleLarge sx={{ mb: theme.spacing(2.4) }}>
9698
{t('unityInstructions')}
9799
</StyledTitleLarge>

0 commit comments

Comments
Β (0)