Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 8 additions & 2 deletions src/app/overlays/ElectronMigrateDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ export function ElectronMigrateDialog() {
<Button type="button" variant="outline" onClick={handleLater}>
{t("electronMigrate.later")}
</Button>
<Button type="button" onClick={() => void handleDownload()} disabled={opening}>
{opening ? t("electronMigrate.opening") : t("electronMigrate.download")}
<Button
type="button"
onClick={() => void handleDownload()}
disabled={opening}
>
{opening
? t("electronMigrate.opening")
: t("electronMigrate.download")}
</Button>
</DialogFooter>
</DialogContent>
Expand Down
3 changes: 2 additions & 1 deletion src/lib/electronMigrate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const ELECTRON_DOWNLOAD_URL =
"https://github.com/Ninthless/StackFerry/releases/latest";

export const ELECTRON_MIGRATE_DISMISSED_KEY = "stackferry:electronMigrate:dismissed";
export const ELECTRON_MIGRATE_DISMISSED_KEY =
"stackferry:electronMigrate:dismissed";
13 changes: 10 additions & 3 deletions tests/components/ElectronMigrateDialog.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { ElectronMigrateDialog } from "@/app/overlays/ElectronMigrateDialog";
import { ELECTRON_DOWNLOAD_URL, ELECTRON_MIGRATE_DISMISSED_KEY } from "@/lib/electronMigrate";
import {
ELECTRON_DOWNLOAD_URL,
ELECTRON_MIGRATE_DISMISSED_KEY,
} from "@/lib/electronMigrate";

const openExternal = vi.fn().mockResolvedValue(undefined);

Expand All @@ -19,7 +22,9 @@ describe("ElectronMigrateDialog", () => {

it("opens the Electron GitHub Latest download", async () => {
render(<ElectronMigrateDialog />);
fireEvent.click(screen.getByRole("button", { name: "electronMigrate.download" }));
fireEvent.click(
screen.getByRole("button", { name: "electronMigrate.download" }),
);
await waitFor(() => {
expect(openExternal).toHaveBeenCalledWith(ELECTRON_DOWNLOAD_URL);
});
Expand All @@ -36,7 +41,9 @@ describe("ElectronMigrateDialog", () => {

it("persists postpone so the next launch stays quiet", () => {
render(<ElectronMigrateDialog />);
fireEvent.click(screen.getByRole("button", { name: "electronMigrate.later" }));
fireEvent.click(
screen.getByRole("button", { name: "electronMigrate.later" }),
);
expect(localStorage.getItem(ELECTRON_MIGRATE_DISMISSED_KEY)).toBe("1");
});
});
Loading