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(preview): empty error message #385

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions src/extension/app/plugins/preview/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,20 @@ export function createPreviewPlugin(appStore) {
const neitherGdocOrGSheet = !isGoogleDocMime && !isGoogleSheetMime;

if (neitherGdocOrGSheet) {
const isMsDocMime = contentType === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
const isMsWordMime = contentType === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
const isMsExcelSheet = contentType === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
let errorKey = 'error_preview_not_gdoc_generic'; // show generic message by default

// istanbul ignore else
if (isMsDocMime) {
errorKey = 'error_preview_not_gdoc_ms_word';
if (isMsWordMime) {
errorKey = 'error_preview_no_docx';
} else if (isMsExcelSheet) {
errorKey = 'error_preview_not_gsheet_ms_excel';
errorKey = 'error_preview_no_xlsx';
}

appStore.showToast({
message: appStore.i18n(errorKey),
variant: 'negative',
variant: 'warning',
});

return;
Expand Down
14 changes: 7 additions & 7 deletions test/app/plugins/preview/preview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe('Preview plugin', () => {
edit: {
status: 200,
sourceLocation: 'gdrive:driveid',
contentType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
contentType: 'application/vnd.openxmlformats-officedocument.fooml.document',
},
},
);
Expand All @@ -217,8 +217,8 @@ describe('Preview plugin', () => {
await sidekickTest.clickToastClose();
expect(closeToastSpy.calledOnce);
expect(toastSpy.calledOnceWith({
message: 'This is a Microsoft Excel document. Please convert it to Google Sheets: File > Save as Google Sheets',
variant: 'negative',
message: 'Preview generation failed. Must be Google document or spreadsheet.',
variant: 'warning',
}));
});

Expand Down Expand Up @@ -253,8 +253,8 @@ describe('Preview plugin', () => {

await waitUntil(() => toastSpy.calledOnce);
expect(toastSpy.calledOnceWith({
message: 'This is a Microsoft Excel document. Please convert it to Google Sheets: File > Save as Google Sheets',
variant: 'negative',
message: 'This is a Microsoft Word document. Please convert it to Google Docs first.',
variant: 'warning',
}));
});

Expand Down Expand Up @@ -289,8 +289,8 @@ describe('Preview plugin', () => {

await waitUntil(() => toastSpy.calledOnce);
expect(toastSpy.calledOnceWith({
message: 'This is a Microsoft Excel document. Please convert it to Google Sheets: File > Save as Google Sheets',
variant: 'negative',
message: 'This is a Microsoft Excel document. Please convert it to Google Sheets first.',
variant: 'warning',
}));
});
});
Expand Down