Skip to content

Commit

Permalink
fix: fidelity typo in preference api (openedx#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki authored and Ian2012 committed Nov 15, 2023
1 parent 5738873 commit 971dc01
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/files-and-videos/videos-page/data/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export async function setTranscriptPreferences(courseId, preferences) {
videoSourceLanguage,
} = preferences;
const postJson = {
cielo24_fideltiy: cielo24Fidelity?.toUpperCase(),
cielo24_fidelity: cielo24Fidelity?.toUpperCase(),
cielo24_turnaround: cielo24Turnaround,
global,
preferred_languages: preferredLanguages,
Expand Down
7 changes: 6 additions & 1 deletion src/files-and-videos/videos-page/data/thunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,12 @@ export function updateTranscriptPreference({ courseId, data }) {
dispatch(updateTranscriptPreferenceSuccess(preferences));
dispatch(updateEditStatus({ editType: 'transcript', status: RequestStatus.SUCCESSFUL }));
} catch (error) {
dispatch(updateErrors({ error: 'transcript', message: `Failed to update ${data.provider} transcripts settings.` }));
if (error.response?.data?.error) {
const message = error.response.data.error;
dispatch(updateErrors({ error: 'transcript', message }));
} else {
dispatch(updateErrors({ error: 'transcript', message: `Failed to update ${data.provider} transcripts settings.` }));
}
dispatch(updateEditStatus({ editType: 'transcript', status: RequestStatus.FAILED }));
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ describe('TranscriptSettings', () => {
expect(screen.getByText('Failed to update Cielo24 transcripts settings.')).toBeVisible();
});

it('should show error alert on 3PlayMedia preferences update', async () => {
it('should show error alert with default message on 3PlayMedia preferences update', async () => {
const threePlayButton = screen.getAllByLabelText('3PlayMedia radio')[0];
await act(async () => {
userEvent.click(threePlayButton);
Expand Down Expand Up @@ -573,6 +573,39 @@ describe('TranscriptSettings', () => {

expect(screen.getByText('Failed to update 3PlayMedia transcripts settings.')).toBeVisible();
});

it('should show error alert with default message on 3PlayMedia preferences update', async () => {
const threePlayButton = screen.getAllByLabelText('3PlayMedia radio')[0];
await act(async () => {
userEvent.click(threePlayButton);
});
const updateButton = screen.getByText(messages.updateSettingsLabel.defaultMessage);
const turnaround = screen.getByText(messages.threePlayMediaTurnaroundPlaceholder.defaultMessage);
const source = screen.getByText(messages.threePlayMediaSourceLanguagePlaceholder.defaultMessage);

await waitFor(() => {
userEvent.click(turnaround);
userEvent.click(screen.getByText('2 hours'));

userEvent.click(source);
userEvent.click(screen.getByText('Spanish'));

const language = screen.getByText(messages.threePlayMediaTranscriptLanguagePlaceholder.defaultMessage);
userEvent.click(language);
userEvent.click(screen.getAllByText('English')[1]);
});
expect(updateButton).not.toHaveAttribute('disabled');

axiosMock.onPost(`${getApiBaseUrl()}/transcript_preferences/${courseId}`).reply(404, { error: 'Invalid turnaround.' });
await waitFor(() => {
userEvent.click(updateButton);
});
const { transcriptStatus } = store.getState().videos;

expect(transcriptStatus).toEqual(RequestStatus.FAILED);

expect(screen.getByText('Invalid turnaround.')).toBeVisible();
});
});
});
});

0 comments on commit 971dc01

Please sign in to comment.