Skip to content

Commit 20f6bab

Browse files
committed
test: add unit test for resetting XBlock publish state after saving changes
1 parent e9f9d44 commit 20f6bab

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/course-unit/CourseUnit.test.jsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,4 +2359,39 @@ describe('<CourseUnit />', () => {
23592359
).not.toBeInTheDocument();
23602360
});
23612361
});
2362+
2363+
it('resets XBlock publish state after saving XBlock changes', async () => {
2364+
store = initializeStore();
2365+
mockedUsedNavigate.mockClear();
2366+
2367+
axiosMock
2368+
.onGet(getCourseSectionVerticalApiUrl(blockId))
2369+
.reply(200, {
2370+
...courseSectionVerticalMock,
2371+
xblock_info: {
2372+
...courseSectionVerticalMock.xblock_info,
2373+
published: true, // Must have been published before
2374+
has_changes: true, // And now have changes
2375+
},
2376+
});
2377+
2378+
render(<RootWrapper />);
2379+
2380+
const xblocksIframe = await screen.findByTitle(xblockContainerIframeMessages.xblockIframeTitle.defaultMessage);
2381+
expect(xblocksIframe).toBeInTheDocument();
2382+
2383+
const courseUnitSidebar = await screen.findByTestId('course-unit-sidebar');
2384+
2385+
await waitFor(() => {
2386+
// Verify the publish button is present (indicates unpublished changes)
2387+
expect(within(courseUnitSidebar)
2388+
.getByRole('button', { name: sidebarMessages.actionButtonPublishTitle.defaultMessage })
2389+
).toBeInTheDocument();
2390+
2391+
// Verify discard changes button is present (confirms unpublished changes)
2392+
expect(within(courseUnitSidebar)
2393+
.getByRole('button', { name: sidebarMessages.actionButtonDiscardChangesTitle.defaultMessage })
2394+
).toBeInTheDocument();
2395+
});
2396+
});
23622397
});

0 commit comments

Comments
 (0)