Skip to content

Commit

Permalink
Fix some test warnings (openedx#1062)
Browse files Browse the repository at this point in the history
* fix: paragon's Hyperlink no longer accepts a 'content' attribute
* test: ensure all act() calls are async
* test: Removed "async" from "describe"
Returning a Promise from "describe" is not supported.
* fix: DiscussionsSettings tests
Previous commit revealed several issues with these tests
* Don't nest userAction.click in act() -- nested act() statements have indeterminent behaviour.
* Use getBy* instead of findBy* with userAction to avoid nested act() statements
* Use fireEvent.click when the onClick handlers need to be called
* Use queryBy* instead of getBy* when using .toBeInTheDocument or waitForElementToBeRemoved
  queryBy* return null when the element is not found.
* fix: typo in data-testid
Warning: React does not recognize the `data-testId` prop on a DOM
element. If you intentionally want it to appear in the DOM as a custom
attribute, spell it as lowercase `data-testid` instead.
* test: Use useLocation to test route changes
---------

Co-authored-by: Yusuf Musleh <yusuf@opencraft.com>
  • Loading branch information
pomegranited and yusuf-musleh committed Jun 13, 2024
1 parent e22cce9 commit f20e531
Show file tree
Hide file tree
Showing 22 changed files with 598 additions and 802 deletions.
294 changes: 119 additions & 175 deletions plugins/course-apps/proctoring/Settings.test.jsx

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/certificates/layout/header-buttons/HeaderButtons.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ describe('HeaderButtons Component', () => {
expect(previewLink).toHaveAttribute('href', expect.stringContaining(certificatesDataMock.courseModes[0]));

const dropdownButton = getByRole('button', { name: certificatesDataMock.courseModes[0] });
await userEvent.click(dropdownButton);
userEvent.click(dropdownButton);

const verifiedMode = await getByRole('button', { name: certificatesDataMock.courseModes[1] });
await userEvent.click(verifiedMode);
userEvent.click(verifiedMode);

await waitFor(() => {
expect(previewLink).toHaveAttribute('href', expect.stringContaining(certificatesDataMock.courseModes[1]));
Expand All @@ -78,7 +78,7 @@ describe('HeaderButtons Component', () => {
const { getByRole, queryByRole } = renderComponent();

const activationButton = getByRole('button', { name: messages.headingActionsActivate.defaultMessage });
await userEvent.click(activationButton);
userEvent.click(activationButton);

axiosMock.onPost(
getUpdateCertificateApiUrl(courseId, certificatesDataMock.certificates[0].id),
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('HeaderButtons Component', () => {
const { getByRole, queryByRole } = renderComponent();

const deactivateButton = getByRole('button', { name: messages.headingActionsDeactivate.defaultMessage });
await userEvent.click(deactivateButton);
userEvent.click(deactivateButton);

axiosMock.onPost(
getUpdateCertificateApiUrl(courseId, certificatesDataMock.certificates[0].id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,9 @@ const ChecklistItemComment = ({
<ul className="assignment-list">
{gradedAssignmentsOutsideDateRange.map(assignment => (
<li className="assignment-list-item" key={assignment.id}>
<Hyperlink
content={assignment.displayName}
destination={`${outlineUrl}#${assignment.id}`}
/>
<Hyperlink destination={`${outlineUrl}#${assignment.id}`}>
{assignment.displayName}
</Hyperlink>
</li>
))}
</ul>
Expand Down
Loading

0 comments on commit f20e531

Please sign in to comment.