mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
Put Check Now and Last checked on the same row, below automatic checks and the update source. The last-checked timestamp uses secondary text and follows the button as the window narrows. The release notes preference sits below the manual check.
112 lines
5.8 KiB
TypeScript
112 lines
5.8 KiB
TypeScript
import { expect, stubDesktop, test } from "./fixtures";
|
|
|
|
for (const windowKind of ["project", "welcome", "lightEdit"]) {
|
|
test(`manual update answers stay visible in ${windowKind} with saved Notifications layout and logging off`, async ({
|
|
workbench: page,
|
|
}) => {
|
|
await stubDesktop(page);
|
|
await page.evaluate(async (kind) => {
|
|
const projectPath = "/src/platform/project.ts";
|
|
const layoutPath = "/src/workbench/toolwindows/store.ts";
|
|
const updatesPath = "/src/features/app/updates.tsx";
|
|
const { useProject } = await import(/* @vite-ignore */ projectPath);
|
|
const { useToolWindowLayout } = await import(/* @vite-ignore */ layoutPath);
|
|
const { checkForUpdates } = await import(/* @vite-ignore */ updatesPath);
|
|
const settings = useProject.getState().settings;
|
|
useProject.setState({
|
|
...(kind === "project" ? {} : { project: null, lightEdit: kind === "lightEdit" }),
|
|
settings: {
|
|
...settings,
|
|
notifications: { balloons: false, groups: { updates: { display: "none", log: false } } },
|
|
},
|
|
});
|
|
useToolWindowLayout.setState({
|
|
visible: { ...useToolWindowLayout.getState().visible, right: "notifications" },
|
|
maximized: null,
|
|
});
|
|
window.__ipc.handlers.app_check_update = () => ({
|
|
enabled: true,
|
|
update: { version: "99.0.0", currentVersion: "0.1.40", notes: null, date: null },
|
|
});
|
|
window.__ipc.handlers.app_update_announcement = () => true;
|
|
await checkForUpdates();
|
|
}, windowKind);
|
|
await expect(page.getByRole("status").filter({ hasText: "OpenIDEA 99.0.0 is available" })).toBeVisible();
|
|
await expect(page.getByRole("button", { name: "Install and Restart", exact: true })).toBeVisible();
|
|
});
|
|
}
|
|
|
|
test("Updates shows check status and keeps manual checks available when automatic checks are off", async ({
|
|
workbench: page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 1120, height: 680 });
|
|
await page.evaluate(async () => {
|
|
const ipcPath = "/src/platform/ipc.ts";
|
|
const actionsPath = "/src/platform/actions.ts";
|
|
const { commands } = await import(/* @vite-ignore */ ipcPath);
|
|
const { registerAction, executeAction } = await import(/* @vite-ignore */ actionsPath);
|
|
Object.assign(commands, {
|
|
appBuildInfo: async () => ({ version: "0.1.39", updates: true }),
|
|
appUpdateStatus: async () => ({ status: "ok", data: { lastChecked: null, checking: false } }),
|
|
});
|
|
registerAction({
|
|
id: "app.checkForUpdates",
|
|
title: "Check for Updates…",
|
|
run: () => document.body.setAttribute("data-update-checked", "true"),
|
|
});
|
|
await executeAction("file.settings", "general");
|
|
});
|
|
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
|
await expect(dialog).toBeVisible();
|
|
await dialog.getByRole("textbox", { name: "Search settings" }).fill("update");
|
|
await dialog.getByRole("treeitem", { name: "Updates", exact: true }).click();
|
|
await expect(dialog.getByText("0.1.39", { exact: true })).toBeVisible();
|
|
await expect(dialog.getByText("Never", { exact: true })).toBeVisible();
|
|
const automatic = dialog.getByRole("checkbox", { name: "Check for updates automatically" });
|
|
const source = dialog.getByRole("button", { name: "Update source", exact: true });
|
|
const check = dialog.getByRole("button", { name: "Check Now", exact: true });
|
|
const checked = dialog.getByText("Never", { exact: true });
|
|
const whatsNew = dialog.getByRole("checkbox", { name: "Show What's New after an update", exact: true });
|
|
for (const width of [1120, 580, 520]) {
|
|
await page.setViewportSize({ width, height: 680 });
|
|
const [automaticBox, sourceBox, checkBox, statusBox, whatsNewBox] = await Promise.all(
|
|
[automatic, source, check, checked, whatsNew].map((item) => item.boundingBox()),
|
|
);
|
|
if (!automaticBox || !sourceBox || !checkBox || !statusBox || !whatsNewBox)
|
|
throw new Error("Missing Updates controls");
|
|
expect(checkBox.y).toBeGreaterThan(sourceBox.y + sourceBox.height);
|
|
expect(sourceBox.y).toBeGreaterThan(automaticBox.y + automaticBox.height);
|
|
expect(whatsNewBox.y).toBeGreaterThan(checkBox.y + checkBox.height);
|
|
expect(statusBox.x).toBeGreaterThan(checkBox.x + checkBox.width);
|
|
expect(Math.abs(statusBox.y + statusBox.height / 2 - checkBox.y - checkBox.height / 2)).toBeLessThan(1.5);
|
|
await expect(check).toBeInViewport({ ratio: 1 });
|
|
}
|
|
await expect(automatic).toBeChecked();
|
|
await automatic.uncheck();
|
|
await expect(source).toBeEnabled();
|
|
await source.click();
|
|
await page.getByRole("option", { name: "CNB (China mirror)", exact: true }).click();
|
|
await dialog.getByRole("button", { name: "Apply", exact: true }).click();
|
|
await expect(automatic).not.toBeChecked();
|
|
await expect(source).toHaveText("CNB (China mirror)");
|
|
await check.click();
|
|
await expect(page.locator("body")).toHaveAttribute("data-update-checked", "true");
|
|
});
|
|
|
|
test("builds without update endpoints hide Updates from settings and search", async ({ workbench: page }) => {
|
|
await page.evaluate(async () => {
|
|
const ipcPath = "/src/platform/ipc.ts";
|
|
const actionsPath = "/src/platform/actions.ts";
|
|
const { commands } = await import(/* @vite-ignore */ ipcPath);
|
|
commands.appBuildInfo = async () => ({ version: "0.1.39", updates: false });
|
|
const { executeAction } = await import(/* @vite-ignore */ actionsPath);
|
|
await executeAction("file.settings", "general");
|
|
});
|
|
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
|
await expect(dialog).toBeVisible();
|
|
await expect(dialog.getByRole("treeitem", { name: "Updates", exact: true })).toHaveCount(0);
|
|
await expect(dialog.getByText("Update source", { exact: true })).toHaveCount(0);
|
|
await dialog.getByRole("textbox", { name: "Search settings" }).fill("update");
|
|
await expect(dialog.getByRole("treeitem", { name: "Updates", exact: true })).toHaveCount(0);
|
|
});
|