Skip to content

Commit

Permalink
fix: filter overwritten by sort (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki authored Nov 20, 2023
1 parent a62c53e commit 9b053de
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
12 changes: 10 additions & 2 deletions src/files-and-videos/files-page/FilesPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ describe('FilesAndUploads', () => {

const sortNameAscendingButton = screen.getByText(messages.sortByNameAscending.defaultMessage);
fireEvent.click(sortNameAscendingButton);
fireEvent.click(screen.getByText(messages.applySortButton.defaultMessage));

await waitFor(() => {
fireEvent.click(screen.getByText(messages.applySortButton.defaultMessage));
});

expect(screen.queryByText(messages.sortModalTitleLabel.defaultMessage)).toBeNull();
});

Expand All @@ -317,7 +321,11 @@ describe('FilesAndUploads', () => {

const sortBySizeDescendingButton = screen.getByText(messages.sortBySizeDescending.defaultMessage);
fireEvent.click(sortBySizeDescendingButton);
fireEvent.click(screen.getByText(messages.applySortButton.defaultMessage));

await waitFor(() => {
fireEvent.click(screen.getByText(messages.applySortButton.defaultMessage));
});

expect(screen.queryByText(messages.sortModalTitleLabel.defaultMessage)).toBeNull();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ const SortAndFilterModal = ({
remove(e.target.value);
}
};

const handleApply = () => {
closeSort();
handleSort(sortBy);
const handleApply = async () => {
await handleSort(sortBy);
processFilters(filterBy, columns, setAllFilters);
closeSort();
};

const handleClearAll = () => {
Expand Down
7 changes: 6 additions & 1 deletion src/files-and-videos/videos-page/VideosPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,14 @@ const VideosPage = ({
const processingStatusColumn = {
id: 'status',
Header: '',
accessor: 'status',
Cell: ({ row }) => StatusColumn({ row }),
Filter: CheckboxFilter,
filterChoices: [{ name: intl.formatMessage(messages.processingCheckboxLabel), value: 'Processing' }],
filterChoices: [
{ name: intl.formatMessage(messages.processingCheckboxLabel), value: 'Processing' },

{ name: intl.formatMessage(messages.failedCheckboxLabel), value: 'Failed' },
],
};
const videoThumbnailColumn = {
id: 'courseVideoImageUrl',
Expand Down
20 changes: 16 additions & 4 deletions src/files-and-videos/videos-page/VideosPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,21 @@ describe('FilesAndUploads', () => {
it('should be enabled and sort files by name', async () => {
const sortNameAscendingButton = screen.getByText(messages.sortByNameAscending.defaultMessage);
fireEvent.click(sortNameAscendingButton);
fireEvent.click(screen.getByText(messages.applySortButton.defaultMessage));

await waitFor(() => {
fireEvent.click(screen.getByText(messages.applySortButton.defaultMessage));
});

expect(screen.queryByText(messages.sortModalTitleLabel.defaultMessage)).toBeNull();
});

it('sort button should be enabled and sort files by file size', async () => {
const sortBySizeDescendingButton = screen.getByText(messages.sortBySizeDescending.defaultMessage);
fireEvent.click(sortBySizeDescendingButton);
fireEvent.click(screen.getByText(messages.applySortButton.defaultMessage));

await waitFor(() => {
fireEvent.click(screen.getByText(messages.applySortButton.defaultMessage));
});

expect(screen.queryByText(messages.sortModalTitleLabel.defaultMessage)).toBeNull();
});
Expand All @@ -374,7 +380,10 @@ describe('FilesAndUploads', () => {
fireEvent.click(transcribedCheckboxFilter);
fireEvent.click(notTranscribedCheckboxFilter);
fireEvent.click(transcribedCheckboxFilter);
fireEvent.click(screen.getByText(messages.applySortButton.defaultMessage));

await waitFor(() => {
fireEvent.click(screen.getByText(messages.applySortButton.defaultMessage));
});

const galleryCards = screen.getAllByTestId('grid-card', { exact: false });

Expand Down Expand Up @@ -406,7 +415,10 @@ describe('FilesAndUploads', () => {
it('should remove Transcribed filter chip', async () => {
const transcribedCheckboxFilter = screen.getByText(videoMessages.transcribedCheckboxLabel.defaultMessage);
fireEvent.click(transcribedCheckboxFilter);
fireEvent.click(screen.getByText(messages.applySortButton.defaultMessage));

await waitFor(() => {
fireEvent.click(screen.getByText(messages.applySortButton.defaultMessage));
});

const imageFilterChip = screen.getByTestId('icon-after');
fireEvent.click(imageFilterChip);
Expand Down
4 changes: 4 additions & 0 deletions src/files-and-videos/videos-page/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const messages = defineMessages({
id: 'course-authoring.files-and-videos.sort-and-filter.modal.filter.processingCheckbox.label',
defaultMessage: 'Processing',
},
failedCheckboxLabel: {
id: 'course-authoring.files-and-videos.sort-and-filter.modal.filter.failedCheckbox.label',
defaultMessage: 'Failed',
},
});

export default messages;

0 comments on commit 9b053de

Please sign in to comment.