Skip to content

Commit ef24d28

Browse files
akolsonclaude
andcommitted
refactor(tests): use component reference instead of name string in findAllComponents
Replace { name: 'RichTextEditor' } with the imported TipTapEditor reference so that a component rename causes a clear import error rather than a silent test failure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f79c508 commit ef24d28

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

contentcuration/contentcuration/frontend/channelEdit/components/AnswersEditor/AnswersEditor.spec.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { shallowMount, mount } from '@vue/test-utils';
33
import { AssessmentItemToolbarActions } from '../../constants';
44
import AnswersEditor from './AnswersEditor';
55
import { AssessmentItemTypes } from 'shared/constants';
6+
import TipTapEditor from 'shared/views/TipTapEditor/TipTapEditor/TipTapEditor.vue';
67

78
jest.mock('shared/views/TipTapEditor/TipTapEditor/TipTapEditor.vue');
89

@@ -260,12 +261,12 @@ describe('AnswersEditor', () => {
260261
});
261262

262263
it('passes autofocus=true to the open answer editor', () => {
263-
const editors = wrapper.findAllComponents({ name: 'RichTextEditor' });
264+
const editors = wrapper.findAllComponents(TipTapEditor);
264265
expect(editors.at(1).props('autofocus')).toBe(true);
265266
});
266267

267268
it('passes autofocus=false to closed answer editors', () => {
268-
const editors = wrapper.findAllComponents({ name: 'RichTextEditor' });
269+
const editors = wrapper.findAllComponents(TipTapEditor);
269270
expect(editors.at(0).props('autofocus')).toBe(false);
270271
});
271272
});
@@ -339,7 +340,7 @@ describe('AnswersEditor', () => {
339340
},
340341
});
341342

342-
const editors = wrapper.findAllComponents({ name: 'RichTextEditor' });
343+
const editors = wrapper.findAllComponents(TipTapEditor);
343344
editors.at(1).vm.$emit('update', 'European butter');
344345

345346
await wrapper.vm.$nextTick();

contentcuration/contentcuration/frontend/channelEdit/components/HintsEditor/HintsEditor.spec.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { shallowMount, mount } from '@vue/test-utils';
33
import { AssessmentItemToolbarActions } from '../../constants';
44

55
import HintsEditor from './HintsEditor';
6+
import TipTapEditor from 'shared/views/TipTapEditor/TipTapEditor/TipTapEditor.vue';
67

78
jest.mock('shared/views/TipTapEditor/TipTapEditor/TipTapEditor.vue');
89

@@ -65,7 +66,7 @@ describe('HintsEditor', () => {
6566
});
6667

6768
// Find all instances of your new RichTextEditor component
68-
const editors = wrapper.findAllComponents({ name: 'RichTextEditor' });
69+
const editors = wrapper.findAllComponents(TipTapEditor);
6970
expect(editors.length).toBe(2);
7071

7172
// Instead of checking the raw HTML, we check the `value` prop passed to each editor.
@@ -85,7 +86,7 @@ describe('HintsEditor', () => {
8586
},
8687
});
8788

88-
const editors = wrapper.findAllComponents({ name: 'RichTextEditor' });
89+
const editors = wrapper.findAllComponents(TipTapEditor);
8990
editors.at(1).vm.$emit('update', 'Updated hint');
9091
});
9192

@@ -145,12 +146,12 @@ describe('HintsEditor', () => {
145146
});
146147

147148
it('passes autofocus=true to the open hint editor', () => {
148-
const editors = wrapper.findAllComponents({ name: 'RichTextEditor' });
149+
const editors = wrapper.findAllComponents(TipTapEditor);
149150
expect(editors.at(0).props('autofocus')).toBe(true);
150151
});
151152

152153
it('passes autofocus=false to closed hint editors', () => {
153-
const editors = wrapper.findAllComponents({ name: 'RichTextEditor' });
154+
const editors = wrapper.findAllComponents(TipTapEditor);
154155
expect(editors.at(1).props('autofocus')).toBe(false);
155156
});
156157
});

0 commit comments

Comments
 (0)