feat: History log in content library components [FC-0123]#2948
feat: History log in content library components [FC-0123]#2948ChrisChV wants to merge 8 commits intoopenedx:masterfrom
Conversation
|
Thanks for the pull request, @ChrisChV! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2948 +/- ##
==========================================
- Coverage 95.51% 95.51% -0.01%
==========================================
Files 1329 1333 +4
Lines 30557 30691 +134
Branches 6930 6959 +29
==========================================
+ Hits 29186 29313 +127
- Misses 1303 1322 +19
+ Partials 68 56 -12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…all library or container
| import { ComponentAdvancedInfo } from './ComponentAdvancedInfo'; | ||
| import { ComponentUsage } from './ComponentUsage'; | ||
| import messages from './messages'; | ||
| import { HistoryComponentLog } from '../generic/history-log/HistoryLog'; |
There was a problem hiding this comment.
nit
| import { HistoryComponentLog } from '../generic/history-log/HistoryLog'; | |
| import { HistoryComponentLog } from '@src/generic/history-log/HistoryLog'; |
| /** | ||
| * Returns the draft history of a library block. | ||
| */ | ||
| export const useLibraryBlockDraftHistory = (usageKey: string | undefined) => ( |
There was a problem hiding this comment.
nit
| export const useLibraryBlockDraftHistory = (usageKey: string | undefined) => ( | |
| export const useLibraryBlockDraftHistory = (usageKey?: string) => ( |
| /** | ||
| * Returns the publish history of a library block. | ||
| */ | ||
| export const useLibraryBlockPublishHistory = (usageKey: string | undefined) => ( |
There was a problem hiding this comment.
nit
| export const useLibraryBlockPublishHistory = (usageKey: string | undefined) => ( | |
| export const useLibraryBlockPublishHistory = (usageKey?: string) => ( |
| usageKey: string | undefined, | ||
| publishGroupId: string | undefined, |
There was a problem hiding this comment.
nit
| usageKey: string | undefined, | |
| publishGroupId: string | undefined, | |
| usageKey?: string, | |
| publishGroupId?: string, |
| /** | ||
| * Returns the creation entry for a library block. | ||
| */ | ||
| export const useLibraryBlockCreationEntry = (usageKey: string | undefined) => ( |
There was a problem hiding this comment.
nit
| export const useLibraryBlockCreationEntry = (usageKey: string | undefined) => ( | |
| export const useLibraryBlockCreationEntry = (usageKey?: string) => ( |
| mockLibraryBlockPublishHistory, | ||
| mockLibraryBlockPublishHistoryEntries, | ||
| mockLibraryBlockCreationEntry, | ||
| } from '../../data/api.mocks'; |
There was a problem hiding this comment.
| } from '../../data/api.mocks'; | |
| } from '@src/data/api.mocks'; |
| /** | ||
| * Finds the innermost element whose full textContent (normalized whitespace) matches the given regex. | ||
| * Useful when text is split across child elements (e.g. by an icon). | ||
| * Requiring that no direct child also matches ensures we get the deepest matching element. | ||
| */ | ||
| const findByTextContent = (pattern: RegExp) => screen.findByText((_, el) => { | ||
| if (!el) return false; | ||
| const normalizedText = (el.textContent ?? '').replace(/\s+/g, ' ').trim(); | ||
| if (!pattern.test(normalizedText)) return false; | ||
| return !Array.from(el.children).some( | ||
| (child) => pattern.test((child.textContent ?? '').replace(/\s+/g, ' ').trim()), | ||
| ); | ||
| }); |
There was a problem hiding this comment.
We have a similar matchInnerText function on testUtils.tsx.
Can you check if it fits your case here or, if not, move this function to testUtils.tsx so we can reuse it?
| renderComponent(mockLibraryBlockCreationEntry.usageKey); | ||
| const trigger = await findByTextContent(/Test Component is a draft/i); | ||
| expect(trigger).toBeInTheDocument(); | ||
| fireEvent.click(trigger); |
There was a problem hiding this comment.
Can you check if userEvent works here? I think we are using it in the new tests and moving away from fireEvent.
Description
Supporting information
history logapi functions [FC-0123] openedx-core#501Testing instructions
history logapi functions [FC-0123] openedx-core#501Detailstab of the sidebar.To test with more contributors
Other information
Best Practices Checklist
We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:
.ts,.tsx).propTypesanddefaultPropsin any new or modified code.src/testUtils.tsx(specificallyinitializeMocks)apiHooks.tsin this repo for examples.messages.tsfiles have adescriptionfor translators to use.../in import paths. To import from parent folders, use@src, e.g.import { initializeMocks } from '@src/testUtils';instead offrom '../../../../testUtils'