Skip to content

fix(site): Fix template version editor rename #6251

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 13 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix file tree remove
  • Loading branch information
BrunoQuaresma committed Feb 23, 2023
commit 2bbc919bcc44c77cf53174ddfe2a3c810f3f76d6
20 changes: 19 additions & 1 deletion site/src/util/filetree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test("getFileContent() return the file content from the file tree", () => {
)
})

test("removeFile() removes a file from the file tree", () => {
test("removeFile() removes a file from a folder", () => {
let fileTree: FileTree = {
"main.tf": "terraform content",
images: {
Expand All @@ -48,6 +48,24 @@ test("removeFile() removes a file from the file tree", () => {
expect(expectedFileTree).toEqual(fileTree)
})

test("removeFile() removes a file from root", () => {
let fileTree: FileTree = {
"main.tf": "terraform content",
images: {
"java.Dockerfile": "java dockerfile",
"python.Dockerfile": "python Dockerfile",
},
}
fileTree = removeFile("main.tf", fileTree)
const expectedFileTree = {
images: {
"java.Dockerfile": "java dockerfile",
"python.Dockerfile": "python Dockerfile",
},
}
expect(expectedFileTree).toEqual(fileTree)
})

test("moveFile() moves a file from in file tree", () => {
let fileTree: FileTree = {
"main.tf": "terraform content",
Expand Down
2 changes: 1 addition & 1 deletion site/src/util/filetree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const existsFile = (path: string, fileTree: FileTree) => {

export const removeFile = (path: string, fileTree: FileTree) => {
const updatedFileTree = { ...fileTree }
unset(fileTree, path.split("/"))
unset(updatedFileTree, path.split("/"))
return updatedFileTree
}

Expand Down