-
Notifications
You must be signed in to change notification settings - Fork 75
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: tag sections, subsections, and the whole course (FC-0053) #879
Merged
xitij2000
merged 13 commits into
openedx:master
from
open-craft:rpenido/fal-3678-tag-sections-subsections-and-the-whole-course
Mar 28, 2024
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d1bad89
feat: tag sections, subsections, and the whole course
rpenido e6bc92d
docs: add comments to useContentTagsCount
rpenido e39955a
fix: get course name in content tags drawer
rpenido f0001a4
feat: add description to messages
rpenido 1f14240
fix: change api url to get course display name
rpenido d57d5ad
Merge branch 'master' into rpenido/fal-3678-tag-sections-subsections-…
rpenido a9fd664
refactor: merge useContentTaxonomyTagsCount and useContentTagsCount
rpenido 888a67c
Merge branch 'master' into rpenido/fal-3678-tag-sections-subsections-…
rpenido 7ae7f0b
style: fix eslint after merge
rpenido 3f96df9
fix: typings
rpenido 7f58c5a
revert: reverting removed code
rpenido 643cc1e
fix: remove unused code
rpenido dd7fdc2
refactor: change onClick function assignment
rpenido File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 21 additions & 18 deletions
39
src/content-tags-drawer/tags-sidebar-controls/TagsSidebarHeader.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,39 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import TagsSidebarHeader from './TagsSidebarHeader'; | ||
import { useContentTaxonomyTagsCount } from '../data/apiHooks'; | ||
|
||
jest.mock('../data/apiHooks', () => ({ | ||
useContentTaxonomyTagsCount: jest.fn(() => ({ | ||
isSuccess: false, | ||
data: 17, | ||
})), | ||
const mockGetTagsCount = jest.fn(); | ||
|
||
jest.mock('../../generic/data/api', () => ({ | ||
...jest.requireActual('../../generic/data/api'), | ||
getTagsCount: () => mockGetTagsCount(), | ||
})); | ||
|
||
jest.mock('react-router-dom', () => ({ | ||
...jest.requireActual('react-router-dom'), | ||
useParams: () => ({ blockId: '123' }), | ||
})); | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
const RootWrapper = () => ( | ||
<IntlProvider locale="en" messages={{}}> | ||
<TagsSidebarHeader /> | ||
<QueryClientProvider client={queryClient}> | ||
<TagsSidebarHeader /> | ||
</QueryClientProvider> | ||
</IntlProvider> | ||
); | ||
|
||
describe('<TagsSidebarHeader>', () => { | ||
it('should not render count on loading', () => { | ||
it('should render count only after query is complete', async () => { | ||
let resolvePromise; | ||
mockGetTagsCount.mockReturnValueOnce(new Promise((resolve) => { resolvePromise = resolve; })); | ||
render(<RootWrapper />); | ||
expect(screen.getByRole('heading', { name: /unit tags/i })).toBeInTheDocument(); | ||
expect(screen.queryByText('17')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render count after query is complete', () => { | ||
useContentTaxonomyTagsCount.mockReturnValue({ | ||
isSuccess: true, | ||
data: 17, | ||
}); | ||
render(<RootWrapper />); | ||
expect(screen.getByRole('heading', { name: /unit tags/i })).toBeInTheDocument(); | ||
expect(screen.getByText('17')).toBeInTheDocument(); | ||
resolvePromise({ 123: 17 }); | ||
expect(await screen.findByText('17')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is left behind by mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Sorry for that @xitij2000!
Fixed: 643cc1e