diff --git a/site/src/pages/TemplateVersionPage/TemplateVersionEditorPage/TemplateVersionEditorPage.test.tsx b/site/src/pages/TemplateVersionPage/TemplateVersionEditorPage/TemplateVersionEditorPage.test.tsx index 0f8e97c64f..af3df2297a 100644 --- a/site/src/pages/TemplateVersionPage/TemplateVersionEditorPage/TemplateVersionEditorPage.test.tsx +++ b/site/src/pages/TemplateVersionPage/TemplateVersionEditorPage/TemplateVersionEditorPage.test.tsx @@ -133,7 +133,7 @@ test("Do not mark as active if promote is not checked", async () => { expect(updateActiveTemplateVersion).toBeCalledTimes(0) }) -test("The default version name is used when a new one is not used", async () => { +test("Patch request is not send when the name is not updated", async () => { const user = userEvent.setup() renderWithAuth(, { extraRoutes: [ @@ -172,12 +172,12 @@ test("The default version name is used when a new one is not used", async () => }) await user.click(publishButton) const publishDialog = await screen.findByTestId("dialog") + // It is using the name from the template version + const nameField = within(publishDialog).getByLabelText("Version name") + expect(nameField).toHaveValue(MockTemplateVersion.name) + // Publish await user.click( within(publishDialog).getByRole("button", { name: "Publish" }), ) - await waitFor(() => { - expect(patchTemplateVersion).toBeCalledWith("new-version-id", { - name: MockTemplateVersion.name, - }) - }) + expect(patchTemplateVersion).toBeCalledTimes(0) }) diff --git a/site/src/xServices/templateVersionEditor/templateVersionEditorXService.ts b/site/src/xServices/templateVersionEditor/templateVersionEditorXService.ts index 45f9ee9d2d..1a709f4ce8 100644 --- a/site/src/xServices/templateVersionEditor/templateVersionEditorXService.ts +++ b/site/src/xServices/templateVersionEditor/templateVersionEditorXService.ts @@ -341,7 +341,10 @@ export const templateVersionEditorMachine = createMachine( throw new Error("Template is not set") } await Promise.all([ - API.patchTemplateVersion(version.id, { name }), + // Only do a patch if the name is different + name !== version.name + ? API.patchTemplateVersion(version.id, { name }) + : Promise.resolve(), isActiveVersion ? API.updateActiveTemplateVersion(templateId, { id: version.id,