chore(frontend): introduce prettier + eslint and prune unused code
- Add Prettier 3 with prettier-plugin-organize-imports (sorts/removes unused imports) - Add ESLint 10 flat config with typescript-eslint + eslint-plugin-vue + eslint-config-prettier - Add root scripts: format, format:check, lint, lint:fix - Reformat 257 files across admin-web, ops-web, desktop-client, packages - Remove unused locals/exports flagged by --noUnusedLocals/--noUnusedParameters - Fix duplicate localTabLabel key, surrogate-pair regex u-flag, NBSP literal in regex - Skip server/ (Go) and apps/browser-extension/ (deprecated per ADR) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import {
|
||||
enqueuePublishTask,
|
||||
@@ -7,47 +7,51 @@ import {
|
||||
notePublishTaskActivated,
|
||||
notePublishTaskCompleted,
|
||||
selectNextPublishTask,
|
||||
} from "./publish-scheduler";
|
||||
} from './publish-scheduler'
|
||||
|
||||
describe("publish scheduler", () => {
|
||||
describe('publish scheduler', () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date("2026-04-24T00:00:00.000Z"));
|
||||
initPublishScheduler();
|
||||
});
|
||||
vi.useFakeTimers()
|
||||
vi.setSystemTime(new Date('2026-04-24T00:00:00.000Z'))
|
||||
initPublishScheduler()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
initPublishScheduler();
|
||||
});
|
||||
vi.useRealTimers()
|
||||
initPublishScheduler()
|
||||
})
|
||||
|
||||
it("skips same-platform queued tasks while selecting an allowed platform", () => {
|
||||
enqueuePublishTask({ taskId: "toutiao-active", platform: "toutiao", routing: "rabbitmq-primary" });
|
||||
notePublishTaskActivated("toutiao-active", "toutiao");
|
||||
enqueuePublishTask({ taskId: "toutiao-next", platform: "toutiao", routing: "rabbitmq-primary" });
|
||||
enqueuePublishTask({ taskId: "zhihu-next", platform: "zhihu", routing: "rabbitmq-primary" });
|
||||
it('skips same-platform queued tasks while selecting an allowed platform', () => {
|
||||
enqueuePublishTask({
|
||||
taskId: 'toutiao-active',
|
||||
platform: 'toutiao',
|
||||
routing: 'rabbitmq-primary',
|
||||
})
|
||||
notePublishTaskActivated('toutiao-active', 'toutiao')
|
||||
enqueuePublishTask({ taskId: 'toutiao-next', platform: 'toutiao', routing: 'rabbitmq-primary' })
|
||||
enqueuePublishTask({ taskId: 'zhihu-next', platform: 'zhihu', routing: 'rabbitmq-primary' })
|
||||
|
||||
const selected = selectNextPublishTask({
|
||||
maxConcurrency: 2,
|
||||
activeCount: 1,
|
||||
});
|
||||
})
|
||||
|
||||
expect(selected?.taskId).toBe("zhihu-next");
|
||||
expect(getPublishSchedulerSnapshot().leasingCount).toBe(1);
|
||||
});
|
||||
expect(selected?.taskId).toBe('zhihu-next')
|
||||
expect(getPublishSchedulerSnapshot().leasingCount).toBe(1)
|
||||
})
|
||||
|
||||
it("holds same-platform tasks during completion cooldown", () => {
|
||||
enqueuePublishTask({ taskId: "first", platform: "toutiao", routing: "rabbitmq-primary" });
|
||||
expect(selectNextPublishTask({ maxConcurrency: 2, activeCount: 0 })?.taskId).toBe("first");
|
||||
notePublishTaskActivated("first", "toutiao");
|
||||
notePublishTaskCompleted("first", "toutiao");
|
||||
it('holds same-platform tasks during completion cooldown', () => {
|
||||
enqueuePublishTask({ taskId: 'first', platform: 'toutiao', routing: 'rabbitmq-primary' })
|
||||
expect(selectNextPublishTask({ maxConcurrency: 2, activeCount: 0 })?.taskId).toBe('first')
|
||||
notePublishTaskActivated('first', 'toutiao')
|
||||
notePublishTaskCompleted('first', 'toutiao')
|
||||
|
||||
enqueuePublishTask({ taskId: "second", platform: "toutiao", routing: "rabbitmq-primary" });
|
||||
enqueuePublishTask({ taskId: 'second', platform: 'toutiao', routing: 'rabbitmq-primary' })
|
||||
|
||||
expect(selectNextPublishTask({ maxConcurrency: 2, activeCount: 0 })).toBeNull();
|
||||
expect(selectNextPublishTask({ maxConcurrency: 2, activeCount: 0 })).toBeNull()
|
||||
|
||||
vi.advanceTimersByTime(6_001);
|
||||
vi.advanceTimersByTime(6_001)
|
||||
|
||||
expect(selectNextPublishTask({ maxConcurrency: 2, activeCount: 0 })?.taskId).toBe("second");
|
||||
});
|
||||
});
|
||||
expect(selectNextPublishTask({ maxConcurrency: 2, activeCount: 0 })?.taskId).toBe('second')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user