Skip to content
Open
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
5 changes: 3 additions & 2 deletions src/locales/de-DE/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@
"restore_all_confirm": "{{count}} ignorierte Updates werden sofort installiert. Das lässt sich nicht rückgängig machen.",
"restore_all_confirm_connect": "{{count}} davon fordern neue @connect-Berechtigungen an.",
"ignored_section": "Ignorierte Updates",
"group_site": "Updates für {{site}}",
"group_site_desc": "Skripte, die auf dieser Website ausgeführt wurden",
"group_other": "Weitere Updates",
"col_script": "Skript",
"col_version": "Version",
"col_change": "Änderungen",
"col_source": "Quelle",
"col_action": "Aktionen",
"enabled": "Aktiviert",
"disabled": "Deaktiviert",
Expand Down
5 changes: 3 additions & 2 deletions src/locales/en-US/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@
"restore_all_confirm": "{{count}} ignored updates will be installed right away. This cannot be undone.",
"restore_all_confirm_connect": "{{count}} of them request new @connect permissions.",
"ignored_section": "Ignored Updates",
"group_site": "Updates for {{site}}",
"group_site_desc": "Scripts that have run on this site",
"group_other": "Other updates",
"col_script": "Script",
"col_version": "Version",
"col_change": "Changes",
"col_source": "Source",
"col_action": "Actions",
"enabled": "Enabled",
"disabled": "Disabled",
Expand Down
5 changes: 3 additions & 2 deletions src/locales/ja-JP/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@
"restore_all_confirm": "無視した更新 {{count}} 件を今すぐインストールします。この操作は取り消せません。",
"restore_all_confirm_connect": "そのうち {{count}} 件が新しい @connect 権限を要求します。",
"ignored_section": "無視した更新",
"group_site": "{{site}} の更新",
"group_site_desc": "このサイトで実行されたスクリプト",
"group_other": "その他の更新",
"col_script": "スクリプト",
"col_version": "バージョン",
"col_change": "変更",
"col_source": "提供元",
"col_action": "操作",
"enabled": "有効",
"disabled": "無効",
Expand Down
5 changes: 3 additions & 2 deletions src/locales/ko-KR/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@
"restore_all_confirm": "무시한 업데이트 {{count}}개를 즉시 설치합니다. 되돌릴 수 없습니다.",
"restore_all_confirm_connect": "그중 {{count}}개가 새로운 @connect 권한을 요청합니다.",
"ignored_section": "무시된 업데이트",
"group_site": "{{site}} 관련 업데이트",
"group_site_desc": "이 사이트에서 실행된 스크립트",
"group_other": "기타 업데이트",
"col_script": "스크립트",
"col_version": "버전",
"col_change": "변경 사항",
"col_source": "출처",
"col_action": "작업",
"enabled": "활성화",
"disabled": "비활성화",
Expand Down
5 changes: 3 additions & 2 deletions src/locales/pt-BR/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@
"restore_all_confirm": "{{count}} atualizações ignoradas serão instaladas agora. Não é possível desfazer.",
"restore_all_confirm_connect": "{{count}} delas solicitam novas permissões @connect.",
"ignored_section": "Atualizações ignoradas",
"group_site": "Atualizações para {{site}}",
"group_site_desc": "Scripts executados neste site",
"group_other": "Outras atualizações",
"col_script": "Script",
"col_version": "Versão",
"col_change": "Alterações",
"col_source": "Origem",
"col_action": "Ações",
"enabled": "Ativado",
"disabled": "Desativado",
Expand Down
5 changes: 3 additions & 2 deletions src/locales/ru-RU/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@
"restore_all_confirm": "Игнорируемые обновления ({{count}}) будут установлены сразу. Отменить это нельзя.",
"restore_all_confirm_connect": "Из них {{count}} запрашивают новые разрешения @connect.",
"ignored_section": "Игнорируемые обновления",
"group_site": "Обновления для {{site}}",
"group_site_desc": "Скрипты, которые запускались на этом сайте",
"group_other": "Другие обновления",
"col_script": "Скрипт",
"col_version": "Версия",
"col_change": "Изменения",
"col_source": "Источник",
"col_action": "Действия",
"enabled": "Включено",
"disabled": "Выключено",
Expand Down
5 changes: 3 additions & 2 deletions src/locales/tr-TR/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@
"restore_all_confirm": "Yok sayılan {{count}} güncelleme hemen kurulacak. Bu işlem geri alınamaz.",
"restore_all_confirm_connect": "Bunlardan {{count}} tanesi yeni @connect izni istiyor.",
"ignored_section": "Yoksayılan Güncellemeler",
"group_site": "{{site}} için güncellemeler",
"group_site_desc": "Bu sitede çalışmış betikler",
"group_other": "Diğer güncellemeler",
"col_script": "Betik",
"col_version": "Sürüm",
"col_change": "Değişiklikler",
"col_source": "Kaynak",
"col_action": "İşlemler",
"enabled": "Etkin",
"disabled": "Devre Dışı",
Expand Down
5 changes: 3 additions & 2 deletions src/locales/vi-VN/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@
"restore_all_confirm": "{{count}} bản cập nhật đã bỏ qua sẽ được cài đặt ngay. Không thể hoàn tác.",
"restore_all_confirm_connect": "Trong đó {{count}} tập lệnh yêu cầu quyền @connect mới.",
"ignored_section": "Cập nhật đã bỏ qua",
"group_site": "Cập nhật cho {{site}}",
"group_site_desc": "Script đã chạy trên trang này",
"group_other": "Cập nhật khác",
"col_script": "Tập lệnh",
"col_version": "Phiên bản",
"col_change": "Thay đổi",
"col_source": "Nguồn",
"col_action": "Thao tác",
"enabled": "Đã bật",
"disabled": "Đã tắt",
Expand Down
5 changes: 3 additions & 2 deletions src/locales/zh-CN/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@
"restore_all_confirm": "将立即安装 {{count}} 个已忽略的更新,安装后无法撤销。",
"restore_all_confirm_connect": "其中 {{count}} 个脚本新增了 @connect 权限。",
"ignored_section": "已忽略的更新",
"group_site": "{{site}} 相关",
"group_site_desc": "在此网站运行过的脚本",
"group_other": "其他更新",
"col_script": "脚本",
"col_version": "版本",
"col_change": "变更",
"col_source": "来源",
"col_action": "操作",
"enabled": "已启用",
"disabled": "已停用",
Expand Down
5 changes: 3 additions & 2 deletions src/locales/zh-TW/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@
"restore_all_confirm": "將立即安裝 {{count}} 個已忽略的更新,安裝後無法撤銷。",
"restore_all_confirm_connect": "其中 {{count}} 個腳本新增了 @connect 權限。",
"ignored_section": "已忽略的更新",
"group_site": "{{site}} 相關",
"group_site_desc": "曾在此網站執行過的腳本",
"group_other": "其他更新",
"col_script": "腳本",
"col_version": "版本",
"col_change": "變更",
"col_source": "來源",
"col_action": "操作",
"enabled": "已啟用",
"disabled": "已停用",
Expand Down
99 changes: 99 additions & 0 deletions src/pages/batchupdate/components.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function mkItem(p: Partial<UpdateItem> = {}): UpdateItem {

function mkView(p: Partial<BatchUpdateViewProps> = {}): BatchUpdateViewProps {
return {
site: "",
updates: [],
ignored: [],
totalChecked: 0,
Expand All @@ -44,6 +45,7 @@ function mkView(p: Partial<BatchUpdateViewProps> = {}): BatchUpdateViewProps {
recordExpired: false,
onToggle: () => {},
onToggleAll: () => {},
onToggleGroup: () => {},
onUpdate: () => {},
onIgnore: () => {},
onRestore: () => {},
Expand Down Expand Up @@ -496,3 +498,100 @@ describe("批量更新 批量中断汇总", () => {
expect(screen.getByTestId("batch-open-scripts")).toBeTruthy();
});
});

describe("批量更新 当前站点分段", () => {
const siteUpdates = () => [
mkItem({ uuid: "s1", name: "本站脚本一", siteMatch: true }),
mkItem({ uuid: "s2", name: "本站脚本二", siteMatch: true }),
mkItem({ uuid: "o1", name: "其它脚本", siteMatch: false }),
];

it("桌面带 site 且有命中时分成「本站相关」与「其它更新」两段", () => {
renderDesktop({ site: "example.com", updates: siteUpdates() });

const siteGroup = screen.getByTestId("update-group-site");
expect(siteGroup).toHaveTextContent(t("install:updatepage.group_site", { site: "example.com" }));
expect(siteGroup).toHaveTextContent(t("install:updatepage.group_site_desc"));
expect(screen.getByTestId("update-group-other")).toHaveTextContent(t("install:updatepage.group_other"));
});

it("桌面组头复选框只切换本段,并以半选反映本段的部分选择", () => {
const onToggleGroup = vi.fn();
renderDesktop({ site: "example.com", updates: siteUpdates(), selected: new Set(["s1"]), onToggleGroup });

const siteToggle = within(screen.getByTestId("update-group-site")).getByRole("checkbox");
expect(siteToggle).toHaveAttribute("data-state", "indeterminate");
expect(within(screen.getByTestId("update-group-other")).getByRole("checkbox")).toHaveAttribute(
"data-state",
"unchecked"
);

fireEvent.click(siteToggle);
expect(onToggleGroup).toHaveBeenCalledWith(["s1", "s2"]);
});

it("桌面顶部复选框标明「全选」,部分选择时为半选", () => {
renderDesktop({ site: "example.com", updates: siteUpdates(), selected: new Set(["s1"]) });

const selectAll = screen.getByRole("checkbox", { name: t("script:select_all") });
expect(selectAll).toHaveAttribute("data-state", "indeterminate");
});

it("没有命中项或没有 site 时不分段", () => {
renderDesktop({ site: "example.com", updates: [mkItem({ uuid: "o1" })] });
expect(screen.queryByTestId("update-group-site")).toBeNull();
expect(screen.queryByTestId("update-group-other")).toBeNull();
cleanup();

renderDesktop({ site: "", updates: [mkItem({ uuid: "o1" })] });
expect(screen.queryByTestId("update-group-site")).toBeNull();
});

it("全部命中时只出现「本站相关」一段", () => {
renderDesktop({ site: "example.com", updates: [mkItem({ uuid: "s1", siteMatch: true })] });
expect(screen.getByTestId("update-group-site")).toBeInTheDocument();
expect(screen.queryByTestId("update-group-other")).toBeNull();
});

it("移动端同样分段,组头复选框只切换本段", () => {
const onToggleGroup = vi.fn();
renderMobile({ site: "example.com", updates: siteUpdates(), onToggleGroup });

expect(screen.getByTestId("update-group-site")).toHaveTextContent(
t("install:updatepage.group_site", { site: "example.com" })
);
fireEvent.click(within(screen.getByTestId("update-group-other")).getByRole("checkbox"));
expect(onToggleGroup).toHaveBeenCalledWith(["o1"]);
});
});

describe("批量更新 风险标签配色", () => {
it("重大改动用警示色而不是危险红,显著改动用中性色", () => {
renderDesktop({
updates: [
mkItem({ uuid: "m", risk: "major", similarity: 0.5 }),
mkItem({ uuid: "n", risk: "noticeable", similarity: 0.9 }),
],
});

const major = screen.getByText(t("install:updatepage.codechange_major"));
expect(major).toHaveClass("bg-warning-bg", "text-warning-fg");
expect(major.className).not.toMatch(/destructive/);
const noticeable = screen.getByText(t("install:updatepage.codechange_noticeable"));
expect(noticeable).toHaveClass("bg-muted", "text-fg-secondary");
expect(noticeable.className).not.toMatch(/primary/);
});
});

describe("批量更新 移动端批量进行中", () => {
it("批量进行中卡片复选框与组头复选框一并禁用,和桌面一致", () => {
renderMobile({
site: "example.com",
updates: [mkItem({ uuid: "s1", siteMatch: true }), mkItem({ uuid: "o1" })],
batchBusy: true,
batchProgress: { done: 0, total: 1, failed: 0, finished: false },
});

for (const box of screen.getAllByRole("checkbox")) expect(box).toBeDisabled();
});
});
Loading
Loading