Repository navigation
feat: [FC-0070] Manage Tags interoperation #1454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
487d38f
ca6cf11
09ced10
62af3bd
27c4533
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -54,6 +54,7 @@ import sidebarMessages from './sidebar/messages'; | |||||||||
| import { extractCourseUnitId } from './sidebar/utils'; | ||||||||||
| import CourseUnit from './CourseUnit'; | ||||||||||
|
|
||||||||||
| import tagsDrawerMessages from '../content-tags-drawer/messages'; | ||||||||||
| import { getClipboardUrl } from '../generic/data/api'; | ||||||||||
| import configureModalMessages from '../generic/configure-modal/messages'; | ||||||||||
| import { getContentTaxonomyTagsApiUrl, getContentTaxonomyTagsCountApiUrl } from '../content-tags-drawer/data/api'; | ||||||||||
|
|
@@ -105,6 +106,14 @@ jest.mock('@tanstack/react-query', () => ({ | |||||||||
| isSuccess: true, | ||||||||||
| }; | ||||||||||
| } | ||||||||||
| if (queryKey[0] === 'taxonomies') { | ||||||||||
| return { | ||||||||||
| data: { | ||||||||||
| results: [], | ||||||||||
| }, | ||||||||||
| isSuccess: true, | ||||||||||
| }; | ||||||||||
| } | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally instead of mocking So you can just write something like this at the top of your test file:
If you do want/need to keep it this way though, you should at least replace the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the option with mocks from Added
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah those mocks won't work if you mock out react-query entirely.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do you mind if we stop here?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's fine. No need to rewrite it, but in the future be aware of the existing mocks we have (as well as everything in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks a lot! |
||||||||||
| return { | ||||||||||
| data: {}, | ||||||||||
| isSuccess: true, | ||||||||||
|
|
@@ -261,6 +270,19 @@ describe('<CourseUnit />', () => { | |||||||||
| }); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| it('renders the xBlocks iframe and opens the tags drawer on postMessage event', async () => { | ||||||||||
| const { getByTitle, getByText } = render(<RootWrapper />); | ||||||||||
|
|
||||||||||
| await waitFor(() => { | ||||||||||
| const xblocksIframe = getByTitle(xblockContainerIframeMessages.xblockIframeTitle.defaultMessage); | ||||||||||
| expect(xblocksIframe).toBeInTheDocument(); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| simulatePostMessageEvent(messageTypes.openManageTags, { contentId: blockId }); | ||||||||||
|
|
||||||||||
| expect(getByText(tagsDrawerMessages.headerSubtitle.defaultMessage)).toBeInTheDocument(); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| it('closes the legacy edit modal when closeXBlockEditorModal message is received', async () => { | ||||||||||
| const { getByTitle, queryByTitle } = render(<RootWrapper />); | ||||||||||
|
|
||||||||||
|
|
@@ -750,6 +772,44 @@ describe('<CourseUnit />', () => { | |||||||||
| )).toBeInTheDocument(); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| it('handle creating Text xblock and saves scroll position in localStorage', async () => { | ||||||||||
| const { getByText, getByRole } = render(<RootWrapper />); | ||||||||||
| const xblockType = 'text'; | ||||||||||
|
|
||||||||||
| axiosMock | ||||||||||
| .onPost(postXBlockBaseApiUrl({ type: xblockType, category: 'html', parentLocator: blockId })) | ||||||||||
| .reply(200, courseCreateXblockMock); | ||||||||||
|
|
||||||||||
| window.scrollTo(0, 250); | ||||||||||
| Object.defineProperty(window, 'scrollY', { value: 250, configurable: true }); | ||||||||||
|
|
||||||||||
| await waitFor(() => { | ||||||||||
| const textButton = screen.getByRole('button', { name: /Text/i }); | ||||||||||
|
|
||||||||||
| expect(getByText(addComponentMessages.title.defaultMessage)).toBeInTheDocument(); | ||||||||||
|
|
||||||||||
| userEvent.click(textButton); | ||||||||||
|
|
||||||||||
| const addXBlockDialog = getByRole('dialog'); | ||||||||||
| expect(addXBlockDialog).toBeInTheDocument(); | ||||||||||
|
|
||||||||||
| expect(getByText( | ||||||||||
| addComponentMessages.modalContainerTitle.defaultMessage.replace('{componentTitle}', xblockType), | ||||||||||
| )).toBeInTheDocument(); | ||||||||||
|
|
||||||||||
| const textRadio = screen.getByRole('radio', { name: /Text/i }); | ||||||||||
| userEvent.click(textRadio); | ||||||||||
| expect(textRadio).toBeChecked(); | ||||||||||
|
|
||||||||||
| const selectBtn = getByRole('button', { name: addComponentMessages.modalBtnText.defaultMessage }); | ||||||||||
| expect(selectBtn).toBeInTheDocument(); | ||||||||||
|
|
||||||||||
| userEvent.click(selectBtn); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| expect(localStorage.getItem('createXBlockLastYPosition')).toBe('250'); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| it('correct addition of a new course unit after click on the "Add new unit" button', async () => { | ||||||||||
| const { getByRole, getAllByTestId } = render(<RootWrapper />); | ||||||||||
| let units = null; | ||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.