4 Commits

Author SHA1 Message Date
543dbe6ffe Merge pull request #64 from lordmathis/fix/file-rename
Fix move file on frontend
2025-10-22 21:55:52 +02:00
d0842c515f Change move file endpoint from PUT to POST and add integration tests for file moving and renaming 2025-10-22 21:50:37 +02:00
01d9a984fc Merge pull request #63 from lordmathis/dependabot/npm_and_yarn/app/npm_and_yarn-7372c7abf2
Bump vite from 6.3.6 to 6.4.1 in /app in the npm_and_yarn group across 1 directory
2025-10-21 10:21:46 +02:00
dependabot[bot]
a3975c9acd Bump vite in /app in the npm_and_yarn group across 1 directory
Bumps the npm_and_yarn group with 1 update in the /app directory: [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite).


Updates `vite` from 6.3.6 to 6.4.1
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/create-vite@6.4.1/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 6.4.1
  dependency-type: direct:development
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-21 05:07:05 +00:00
4 changed files with 54 additions and 6 deletions

8
app/package-lock.json generated
View File

@@ -55,7 +55,7 @@
"postcss-simple-vars": "^7.0.1",
"sass": "^1.80.4",
"typescript": "^5.8.2",
"vite": "^6.3.6",
"vite": "^6.4.1",
"vite-plugin-compression2": "^1.3.0",
"vitest": "^3.1.4"
}
@@ -9696,9 +9696,9 @@
}
},
"node_modules/vite": {
"version": "6.3.6",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.6.tgz",
"integrity": "sha512-0msEVHJEScQbhkbVTb/4iHZdJ6SXp/AvxL2sjwYQFfBqleHtnCqv1J3sa9zbWz/6kW1m9Tfzn92vW+kZ1WV6QA==",
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.4.1.tgz",
"integrity": "sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g==",
"dev": true,
"license": "MIT",
"dependencies": {

View File

@@ -75,7 +75,7 @@
"postcss-simple-vars": "^7.0.1",
"sass": "^1.80.4",
"typescript": "^5.8.2",
"vite": "^6.3.6",
"vite": "^6.4.1",
"vite-plugin-compression2": "^1.3.0",
"vitest": "^3.1.4"
},

View File

@@ -134,7 +134,7 @@ func setupRouter(o Options) *chi.Mux {
r.Get("/lookup", handler.LookupFileByName())
r.Post("/upload", handler.UploadFile())
r.Put("/move", handler.MoveFile())
r.Post("/move", handler.MoveFile())
r.Post("/", handler.SaveFile())
r.Get("/content", handler.GetFileContent())

View File

@@ -156,6 +156,54 @@ func testFileHandlers(t *testing.T, dbConfig DatabaseConfig) {
assert.Equal(t, http.StatusNotFound, rr.Code)
})
t.Run("move file", func(t *testing.T) {
srcPath := "original.md"
destPath := "moved.md"
content := "This file will be moved"
// Create file
rr := h.makeRequestRaw(t, http.MethodPost, baseURL+"?file_path="+url.QueryEscape(srcPath), strings.NewReader(content), h.RegularTestUser)
require.Equal(t, http.StatusOK, rr.Code)
// Move file
moveURL := baseURL + "/move?src_path=" + url.QueryEscape(srcPath) + "&dest_path=" + url.QueryEscape(destPath)
rr = h.makeRequest(t, http.MethodPost, moveURL, nil, h.RegularTestUser)
require.Equal(t, http.StatusOK, rr.Code)
// Verify source is gone
rr = h.makeRequest(t, http.MethodGet, baseURL+"/content?file_path="+url.QueryEscape(srcPath), nil, h.RegularTestUser)
assert.Equal(t, http.StatusNotFound, rr.Code)
// Verify destination exists with correct content
rr = h.makeRequest(t, http.MethodGet, baseURL+"/content?file_path="+url.QueryEscape(destPath), nil, h.RegularTestUser)
require.Equal(t, http.StatusOK, rr.Code)
assert.Equal(t, content, rr.Body.String())
})
t.Run("rename file in directory", func(t *testing.T) {
srcPath := "folder/old-name.md"
destPath := "folder/new-name.md"
content := "This file will be renamed"
// Create file
rr := h.makeRequestRaw(t, http.MethodPost, baseURL+"?file_path="+url.QueryEscape(srcPath), strings.NewReader(content), h.RegularTestUser)
require.Equal(t, http.StatusOK, rr.Code)
// Rename file (move within same directory)
moveURL := baseURL + "/move?src_path=" + url.QueryEscape(srcPath) + "&dest_path=" + url.QueryEscape(destPath)
rr = h.makeRequest(t, http.MethodPost, moveURL, nil, h.RegularTestUser)
require.Equal(t, http.StatusOK, rr.Code)
// Verify source is gone
rr = h.makeRequest(t, http.MethodGet, baseURL+"/content?file_path="+url.QueryEscape(srcPath), nil, h.RegularTestUser)
assert.Equal(t, http.StatusNotFound, rr.Code)
// Verify destination exists with correct content
rr = h.makeRequest(t, http.MethodGet, baseURL+"/content?file_path="+url.QueryEscape(destPath), nil, h.RegularTestUser)
require.Equal(t, http.StatusOK, rr.Code)
assert.Equal(t, content, rr.Body.String())
})
t.Run("last opened file", func(t *testing.T) {
// Initially should be empty
rr := h.makeRequest(t, http.MethodGet, baseURL+"/last", nil, h.RegularTestUser)