diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/HintsEditor/HintsEditor.spec.js b/contentcuration/contentcuration/frontend/channelEdit/components/HintsEditor/HintsEditor.spec.js index ddf9838d19..4cc2035f3e 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/HintsEditor/HintsEditor.spec.js +++ b/contentcuration/contentcuration/frontend/channelEdit/components/HintsEditor/HintsEditor.spec.js @@ -20,6 +20,10 @@ const renderComponent = props => { }); }; +const openHintsSection = async user => { + await user.click(screen.getByText(HintsEditor.$trs.hintsLabel)); +}; + const getHintCards = () => { return screen.getAllByTestId('hint'); }; @@ -31,29 +35,35 @@ const clickToolbarAction = async ({ action, hintIdx, user }) => { }; describe('HintsEditor', () => { - it('smoke test', () => { + it('smoke test', async () => { + const user = userEvent.setup(); renderComponent(); + await openHintsSection(user); expect( screen.getByRole('button', { name: HintsEditor.$trs.newHintBtnLabel }), ).toBeInTheDocument(); }); - it('shows an empty-state message when a question has no hints', () => { + it('shows an empty-state message when a question has no hints', async () => { + const user = userEvent.setup(); renderComponent({ hints: [], }); + await openHintsSection(user); expect(screen.getByText(HintsEditor.$trs.noHintsPlaceholder)).toBeInTheDocument(); }); - it('shows hints in the same order as the question', () => { + it('shows hints in the same order as the question', async () => { + const user = userEvent.setup(); renderComponent({ hints: [ { hint: 'First hint', order: 1 }, { hint: 'Second hint', order: 2 }, ], }); + await openHintsSection(user); const hintCards = getHintCards(); expect(within(hintCards[0]).getByText('First hint')).toBeInTheDocument(); @@ -69,6 +79,7 @@ describe('HintsEditor', () => { ], openHintIdx: 1, }); + await openHintsSection(user); const hintCards = getHintCards(); const hintTextField = within(hintCards[1]).getByRole('textbox'); @@ -92,6 +103,7 @@ describe('HintsEditor', () => { { hint: 'Third hint', order: 3 }, ], }); + await openHintsSection(user); await user.click(screen.getByRole('button', { name: HintsEditor.$trs.newHintBtnLabel })); @@ -114,6 +126,7 @@ describe('HintsEditor', () => { ], openHintIdx: 0, }); + await openHintsSection(user); const hintCards = getHintCards(); await user.click(hintCards[1]); @@ -131,6 +144,7 @@ describe('HintsEditor', () => { ], openHintIdx: 1, }); + await openHintsSection(user); await clickToolbarAction({ action: AssessmentItemToolbarActions.MOVE_ITEM_UP, @@ -156,6 +170,7 @@ describe('HintsEditor', () => { ], openHintIdx: 0, }); + await openHintsSection(user); await clickToolbarAction({ action: AssessmentItemToolbarActions.MOVE_ITEM_UP, @@ -176,6 +191,7 @@ describe('HintsEditor', () => { ], openHintIdx: 0, }); + await openHintsSection(user); await clickToolbarAction({ action: AssessmentItemToolbarActions.MOVE_ITEM_DOWN, @@ -201,6 +217,7 @@ describe('HintsEditor', () => { ], openHintIdx: 1, }); + await openHintsSection(user); await clickToolbarAction({ action: AssessmentItemToolbarActions.MOVE_ITEM_DOWN, @@ -221,6 +238,7 @@ describe('HintsEditor', () => { ], openHintIdx: 0, }); + await openHintsSection(user); await clickToolbarAction({ action: AssessmentItemToolbarActions.DELETE_ITEM, @@ -242,6 +260,7 @@ describe('HintsEditor', () => { ], openHintIdx: 1, }); + await openHintsSection(user); await clickToolbarAction({ action: AssessmentItemToolbarActions.DELETE_ITEM, diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/HintsEditor/HintsEditor.vue b/contentcuration/contentcuration/frontend/channelEdit/components/HintsEditor/HintsEditor.vue index 05ad7ebf85..5a7add10d5 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/HintsEditor/HintsEditor.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/HintsEditor/HintsEditor.vue @@ -1,39 +1,127 @@ @@ -159,6 +202,7 @@ }, data() { return { + sectionOpen: false, toolbarIconActions: [ AssessmentItemToolbarActions.MOVE_ITEM_UP, AssessmentItemToolbarActions.MOVE_ITEM_DOWN, @@ -173,6 +217,23 @@ const { windowBreakpoint } = useKResponsiveWindow(); return windowBreakpoint.value ?? 0; }, + buttonAppearanceOverrides() { + return { + backgroundColor: this.$themePalette.grey.v_50, + color: `${this.$themePalette.grey.v_700} !important`, + fontSize: '14px', + fontWeight: '600', + textTransform: 'none', + ':hover': { + backgroundColor: this.$themePalette.grey.v_100, + }, + }; + }, + hintPlaceholderStyle() { + return { + color: this.$themePalette.grey.v_600, + }; + }, }, methods: { emitOpen(hintIdx) { @@ -187,6 +248,14 @@ isHintOpen(hintIdx) { return hintIdx === this.openHintIdx; }, + isHintEmpty(hint) { + return !hint.hint || !hint.hint.trim(); + }, + hintDisplayText(hint, hintIdx) { + return this.isHintEmpty(hint) + ? this.$tr('hintPlaceholder', { index: hintIdx + 1 }) + : hint.hint; + }, isHintFirst(hintIdx) { return hintIdx === 0; }, @@ -316,9 +385,10 @@ }, }, $trs: { - hintsLabel: 'Hints', + hintsLabel: 'Hints (optional)', noHintsPlaceholder: 'Question has no hints', - newHintBtnLabel: 'New hint', + newHintBtnLabel: 'Add hint', + hintPlaceholder: 'Enter hint {index}...', }, }; @@ -327,6 +397,33 @@