diff --git a/site/src/pages/TemplateVersionPage/TemplateVersionEditorPage/TemplateVersionEditorPage.test.tsx b/site/src/pages/TemplateVersionPage/TemplateVersionEditorPage/TemplateVersionEditorPage.test.tsx index 0f8e97c64f847..af3df2297ad0c 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 45f9ee9d2dd68..1a709f4ce8153 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, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy