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

Skip to content

fix: set content type when uploading edited template #15440

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

Merged
merged 1 commit into from
Nov 8, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,28 @@ test("Patch request is not send when there are no changes", async () => {
expect(patchTemplateVersion).toBeCalledTimes(0);
});

test("The file is uploaded with the correct content type", async () => {
const user = userEvent.setup();
renderTemplateEditorPage();
const topbar = await screen.findByTestId("topbar");

const newTemplateVersion = {
...MockTemplateVersion,
id: "new-version-id",
name: "new-version",
};

await typeOnEditor("new content", user);
await buildTemplateVersion(newTemplateVersion, user, topbar);

expect(API.uploadFile).toHaveBeenCalledWith(
expect.objectContaining({
name: "template.tar",
type: "application/x-tar",
}),
);
});

describe.each([
{
testName: "Do not ask when template version has no errors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ const generateVersionFiles = async (
tar.addFolder(fullPath, baseFileInfo);
});
const blob = (await tar.write()) as Blob;
return new File([blob], "template.tar");
return new File([blob], "template.tar", { type: "application/x-tar" });
};

const publishVersion = async (options: {
Expand Down
Loading