Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fidelity typo in preference api #662

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});
});
});