Skip to content

Commit

Permalink
refactor: Discard changes commented on Library Info sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChV committed Aug 1, 2024
1 parent 8d156e3 commit 8b27caa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
26 changes: 0 additions & 26 deletions src/library-authoring/library-info/LibraryInfo.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,30 +163,4 @@ describe('<LibraryInfo />', () => {

await waitFor(() => expect(axiosMock.history.post[0].url).toEqual(url));
});

it('should discard changes', async () => {
const url = getCommitLibraryChangesUrl(libraryData.id);
axiosMock.onDelete(url).reply(200);

render(<RootWrapper data={libraryData} />);
const discardButton = screen.getByRole('button', { name: /discard changes/i });
fireEvent.click(discardButton);

expect(await screen.findByText('Library changes reverted successfully')).toBeInTheDocument();

await waitFor(() => expect(axiosMock.history.delete[0].url).toEqual(url));
});

it('should show error on discard changes', async () => {
const url = getCommitLibraryChangesUrl(libraryData.id);
axiosMock.onDelete(url).reply(500);

render(<RootWrapper data={libraryData} />);
const discardButton = screen.getByRole('button', { name: /discard changes/i });
fireEvent.click(discardButton);

expect(await screen.findByText('There was an error reverting changes in the library.')).toBeInTheDocument();

await waitFor(() => expect(axiosMock.history.delete[0].url).toEqual(url));
});
});
14 changes: 9 additions & 5 deletions src/library-authoring/library-info/LibraryPublishStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,15 @@ const LibraryPublishStatus = ({ library } : LibraryPublishStatusProps) => {
<Button disabled={isPublished} onClick={commit}>
{intl.formatMessage(messages.publishButtonLabel)}
</Button>
<div className="d-flex justify-content-end">
<Button disabled={isPublished} variant="link" onClick={revert}>
{intl.formatMessage(messages.discardChangesButtonLabel)}
</Button>
</div>
{ /*
* TODO, the discard changes breaks the library.
* Discomment this when discard changes is fixed.
<div className="d-flex justify-content-end">
<Button disabled={isPublished} variant="link" onClick={revert}>
{intl.formatMessage(messages.discardChangesButtonLabel)}
</Button>
</div>
*/ }
</Stack>
</Container>
</Stack>
Expand Down

0 comments on commit 8b27caa

Please sign in to comment.