From 4e7ae082c5491d5a99082bbb2fd923fef359150d Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 26 Jan 2026 12:44:52 -0500 Subject: [PATCH] feat: modify template to accept basename instead of full filename --- .../src/components/Bugs/PublicationForm.vue | 4 +-- server/frontend/src/helpers.js | 26 ++++++++----------- server/frontend/tests/helpers.test.js | 8 +++--- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/server/frontend/src/components/Bugs/PublicationForm.vue b/server/frontend/src/components/Bugs/PublicationForm.vue index 4997d77d..588ac7da 100644 --- a/server/frontend/src/components/Bugs/PublicationForm.vue +++ b/server/frontend/src/components/Bugs/PublicationForm.vue @@ -516,9 +516,7 @@
- + 1 - ? templateParts.slice(0, -1).join(".") - : templateParts[0]; + if (templateBasename) { + basename = templateBasename; } else { basename = hasExtension ? originalParts.slice(0, -1).join(".") @@ -254,10 +250,10 @@ export function parseFilename(testcasePath, templateFilename = null) { } /** - * Build a filename from basename and extension - * @param {string} basename - The base filename without extension - * @param {string|null} extension - Optional file extension (without dot) - * @returns {string} Complete filename with extension if provided + * Build a filename from basename and extension. + * @param {string} basename - The file basename. + * @param {string|null} extension - Optional file extension. + * @returns {string} */ export function buildFilename(basename, extension) { return extension ? `${basename}.${extension}` : basename; diff --git a/server/frontend/tests/helpers.test.js b/server/frontend/tests/helpers.test.js index 3a455117..89b10524 100644 --- a/server/frontend/tests/helpers.test.js +++ b/server/frontend/tests/helpers.test.js @@ -5,13 +5,13 @@ describe("parseFilename", () => { [ "testcase with file extension", "tests/test.txt", - "testcase.zip", + "testcase", { basename: "testcase", extension: "txt" }, ], [ "testcase without an extension", "tests/original", - "template_name.html", + "template_name", { basename: "template_name", extension: null }, ], [ @@ -38,8 +38,8 @@ describe("parseFilename", () => { null, { basename: "test.min", extension: "js" }, ], - ])("%s", (_description, testcasePath, templateFilename, expected) => { - const result = parseFilename(testcasePath, templateFilename); + ])("%s", (_description, testcasePath, templateBasename, expected) => { + const result = parseFilename(testcasePath, templateBasename); expect(result).toEqual(expected); }); });