From 74f79bd702e1e6738d1e1df06964bbc5ea162793 Mon Sep 17 00:00:00 2001 From: Mark Cafaro Date: Tue, 24 Jun 2025 10:39:08 -0400 Subject: [PATCH 1/2] Add download alert --- public/index.html | 17 +++++++++++++++++ public/scripts/main.js | 25 +++++++++++++++++++++++++ public/style.css | 9 +++++++++ tests/main.test.js | 29 ++++++++++++++++++++++++++++- 4 files changed, 79 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 141a352..aa6b2d9 100644 --- a/public/index.html +++ b/public/index.html @@ -21,6 +21,23 @@ your browser. +
{ new bootstrap.Tooltip(el); diff --git a/public/style.css b/public/style.css index 1bcbdf4..62f324d 100644 --- a/public/style.css +++ b/public/style.css @@ -118,3 +118,12 @@ p.lead.text-muted { .bi-question-circle { color: #0076a8; } + +#download-alert { + text-align: center; + position: fixed; + top: 5px; + left: 2%; + width: 96%; + z-index: 2000; +} diff --git a/tests/main.test.js b/tests/main.test.js index 20fc708..31e8fc1 100644 --- a/tests/main.test.js +++ b/tests/main.test.js @@ -17,7 +17,8 @@ beforeEach(async () => { - + +
`; await import("../public/scripts/main.js"); @@ -98,3 +99,29 @@ test("advanced options are passed to generateWorkflow", async () => { jsyaml: window.jsyaml, }); }); + +test("download link triggers file download", () => { + const repoInput = document.getElementById("repo"); + repoInput.value = "owner/repo"; + + window.jsyaml = { dump: () => "yaml-content" }; + + const mockCreateObjectURL = jest.fn(() => "blob:url"); + const mockRevokeObjectURL = jest.fn(); + global.URL.createObjectURL = mockCreateObjectURL; + global.URL.revokeObjectURL = mockRevokeObjectURL; + + const a = document.createElement("a"); + document.body.appendChild(a); + jest.spyOn(document, "createElement").mockImplementation((tag) => { + if (tag === "a") return a; + return document.createElement(tag); + }); + const clickSpy = jest.spyOn(a, "click"); + + document.getElementById("download-alert-link").click(); + + expect(mockCreateObjectURL).toHaveBeenCalled(); + expect(clickSpy).toHaveBeenCalled(); + expect(mockRevokeObjectURL).toHaveBeenCalled(); +}); From dcea854243e0f5add716d72d130b621c5884f430 Mon Sep 17 00:00:00 2001 From: Mark Cafaro Date: Tue, 24 Jun 2025 16:26:38 -0400 Subject: [PATCH 2/2] Update alert text per feedback --- public/index.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/index.html b/public/index.html index aa6b2d9..0aaf4c2 100644 --- a/public/index.html +++ b/public/index.html @@ -27,11 +27,12 @@ role="alert" tabindex="-1"> Having trouble? - If the automatic workflow file creation does not work, manually download + If the generated workflow does not automatically appear in your workflow + editor, manually download matlab.yml - and add it to your repository's + and save it to the .github/workflows - folder instead. + folder of your repository.