From a223245036089b31ae4e1493eb74faf44fbc7164 Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Thu, 30 Mar 2023 11:18:37 +0000 Subject: [PATCH 1/2] fix(site): Only patch version name if name is changed --- .../templateVersionEditor/templateVersionEditorXService.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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, From abab525659f50a303f0107d5f6e7e4bbd9afee1a Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Thu, 30 Mar 2023 11:29:43 +0000 Subject: [PATCH 2/2] Fix test --- .../TemplateVersionEditorPage.test.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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) }) 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