Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8935e21

Browse files
committed
fix: set content type when uploading edited template
1 parent 0987281 commit 8935e21

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

site/src/pages/TemplateVersionEditorPage/TemplateVersionEditorPage.test.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,26 @@ test("Patch request is not send when there are no changes", async () => {
226226
expect(patchTemplateVersion).toBeCalledTimes(0);
227227
});
228228

229+
test("The file is uploaded with the correct content type", async () => {
230+
const user = userEvent.setup();
231+
renderTemplateEditorPage();
232+
const topbar = await screen.findByTestId("topbar");
233+
234+
const newTemplateVersion = {
235+
...MockTemplateVersion,
236+
id: "new-version-id",
237+
name: "new-version",
238+
};
239+
240+
await typeOnEditor("new content", user);
241+
await buildTemplateVersion(newTemplateVersion, user, topbar);
242+
243+
expect(API.uploadFile).toHaveBeenCalledWith(expect.objectContaining({
244+
name: "template.tar",
245+
type: "application/x-tar"
246+
}));
247+
});
248+
229249
describe.each([
230250
{
231251
testName: "Do not ask when template version has no errors",

site/src/pages/TemplateVersionEditorPage/TemplateVersionEditorPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ const generateVersionFiles = async (
329329
tar.addFolder(fullPath, baseFileInfo);
330330
});
331331
const blob = (await tar.write()) as Blob;
332-
return new File([blob], "template.tar");
332+
return new File([blob], "template.tar", { type: "application/x-tar" });
333333
};
334334

335335
const publishVersion = async (options: {

0 commit comments

Comments
 (0)