-
Notifications
You must be signed in to change notification settings - Fork 894
chore(site): remove template version editor xservice #10490
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
Changes from 17 commits
c290855
93df525
b3c712c
10d6b4e
7eb5c91
c024a1d
e7713fe
f782c7d
8bf23af
5502077
20d6100
9d1ca61
c73f976
86735c9
86d7a6d
e748fe8
71e8920
8a7fae6
2769cfe
4893156
32934ed
209e364
66ea796
353f325
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { screen, waitFor, within } from "@testing-library/react"; | |
import userEvent from "@testing-library/user-event"; | ||
import * as api from "api/api"; | ||
import { | ||
MockTemplate, | ||
MockTemplateVersion, | ||
MockWorkspaceBuildLogs, | ||
} from "testHelpers/entities"; | ||
|
@@ -17,26 +18,37 @@ jest.mock("components/TemplateResourcesTable/TemplateResourcesTable", () => { | |
}; | ||
}); | ||
|
||
test("Use custom name, message and set it as active when publishing", async () => { | ||
const user = userEvent.setup(); | ||
const renderTemplateEditorPage = () => { | ||
renderWithAuth(<TemplateVersionEditorPage />, { | ||
route: `/templates/${MockTemplate.name}/versions/${MockTemplateVersion.name}/edit`, | ||
path: "/templates/:template/versions/:version/edit", | ||
extraRoutes: [ | ||
{ | ||
path: "/templates/:templateId", | ||
element: <div />, | ||
}, | ||
], | ||
}); | ||
}; | ||
|
||
test("Use custom name, message and set it as active when publishing", async () => { | ||
const user = userEvent.setup(); | ||
renderTemplateEditorPage(); | ||
const topbar = await screen.findByTestId("topbar"); | ||
|
||
// Build Template | ||
jest.spyOn(api, "uploadFile").mockResolvedValueOnce({ hash: "hash" }); | ||
const newTemplateVersion = { | ||
...MockTemplateVersion, | ||
id: "new-version-id", | ||
name: "new-version", | ||
}; | ||
jest | ||
.spyOn(api, "createTemplateVersion") | ||
.mockResolvedValueOnce(MockTemplateVersion); | ||
.mockResolvedValue(newTemplateVersion); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just double-checking for my own understanding: is there any real difference between the mock function returning the base There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, because we are going to use this version to optimistically update the UI. |
||
jest | ||
.spyOn(api, "getTemplateVersion") | ||
.mockResolvedValue({ ...MockTemplateVersion, id: "new-version-id" }); | ||
.spyOn(api, "getTemplateVersionByName") | ||
.mockResolvedValue(newTemplateVersion); | ||
jest | ||
.spyOn(api, "watchBuildLogsByTemplateVersionId") | ||
.mockImplementation((_, options) => { | ||
|
@@ -52,7 +64,7 @@ test("Use custom name, message and set it as active when publishing", async () = | |
// Publish | ||
const patchTemplateVersion = jest | ||
.spyOn(api, "patchTemplateVersion") | ||
.mockResolvedValue(MockTemplateVersion); | ||
.mockResolvedValue(newTemplateVersion); | ||
const updateActiveTemplateVersion = jest | ||
.spyOn(api, "updateActiveTemplateVersion") | ||
.mockResolvedValue({ message: "" }); | ||
|
@@ -84,24 +96,22 @@ test("Use custom name, message and set it as active when publishing", async () = | |
|
||
test("Do not mark as active if promote is not checked", async () => { | ||
const user = userEvent.setup(); | ||
renderWithAuth(<TemplateVersionEditorPage />, { | ||
extraRoutes: [ | ||
{ | ||
path: "/templates/:templateId", | ||
element: <div />, | ||
}, | ||
], | ||
}); | ||
renderTemplateEditorPage(); | ||
const topbar = await screen.findByTestId("topbar"); | ||
|
||
// Build Template | ||
jest.spyOn(api, "uploadFile").mockResolvedValueOnce({ hash: "hash" }); | ||
const newTemplateVersion = { | ||
...MockTemplateVersion, | ||
id: "new-version-id", | ||
name: "new-version", | ||
}; | ||
jest | ||
.spyOn(api, "createTemplateVersion") | ||
.mockResolvedValueOnce(MockTemplateVersion); | ||
.mockResolvedValue(newTemplateVersion); | ||
jest | ||
.spyOn(api, "getTemplateVersion") | ||
.mockResolvedValue({ ...MockTemplateVersion, id: "new-version-id" }); | ||
.spyOn(api, "getTemplateVersionByName") | ||
.mockResolvedValue(newTemplateVersion); | ||
jest | ||
.spyOn(api, "watchBuildLogsByTemplateVersionId") | ||
.mockImplementation((_, options) => { | ||
|
@@ -117,7 +127,7 @@ test("Do not mark as active if promote is not checked", async () => { | |
// Publish | ||
const patchTemplateVersion = jest | ||
.spyOn(api, "patchTemplateVersion") | ||
.mockResolvedValue(MockTemplateVersion); | ||
.mockResolvedValue(newTemplateVersion); | ||
const updateActiveTemplateVersion = jest | ||
.spyOn(api, "updateActiveTemplateVersion") | ||
.mockResolvedValue({ message: "" }); | ||
|
@@ -146,30 +156,27 @@ test("Do not mark as active if promote is not checked", async () => { | |
}); | ||
|
||
test("Patch request is not send when there are no changes", async () => { | ||
const MockTemplateVersionWithEmptyMessage = { | ||
const newTemplateVersion = { | ||
...MockTemplateVersion, | ||
id: "new-version-id", | ||
name: "new-version", | ||
}; | ||
const MockTemplateVersionWithEmptyMessage = { | ||
...newTemplateVersion, | ||
message: "", | ||
}; | ||
const user = userEvent.setup(); | ||
renderWithAuth(<TemplateVersionEditorPage />, { | ||
extraRoutes: [ | ||
{ | ||
path: "/templates/:templateId", | ||
element: <div />, | ||
}, | ||
], | ||
}); | ||
renderTemplateEditorPage(); | ||
const topbar = await screen.findByTestId("topbar"); | ||
|
||
// Build Template | ||
jest.spyOn(api, "uploadFile").mockResolvedValueOnce({ hash: "hash" }); | ||
jest | ||
.spyOn(api, "createTemplateVersion") | ||
.mockResolvedValueOnce(MockTemplateVersionWithEmptyMessage); | ||
jest.spyOn(api, "getTemplateVersion").mockResolvedValue({ | ||
...MockTemplateVersionWithEmptyMessage, | ||
id: "new-version-id", | ||
}); | ||
.mockResolvedValue(MockTemplateVersionWithEmptyMessage); | ||
jest | ||
.spyOn(api, "getTemplateVersionByName") | ||
.mockResolvedValue(MockTemplateVersionWithEmptyMessage); | ||
jest | ||
.spyOn(api, "watchBuildLogsByTemplateVersionId") | ||
.mockImplementation((_, options) => { | ||
|
Uh oh!
There was an error while loading. Please reload this page.