ken_nogi/NodeSrv/apps/org-master-sync/test/fetch-lineworks.test.js
Kenichiro NOGI ce58cb4be4 初回コミット: dev配下(NodeSrv/Pleasanter等)をGitea管理下に統合
GitHub(nextgroup2706/ken_nogi)は今後使わず自社Gitea運用に切替え。
NodeSrvは旧リポジトリの履歴を破棄しファイルのみ統合(Dokploy用サービスアカウントは
別途mygit-admin/NodeSrv.gitに履歴あり)。notepmエクスポート(12GB)とPleasanter
インストーラzip(208MB)はサイズが大きいため.gitignoreで除外。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-04 15:37:06 +09:00

26 lines
1.2 KiB
JavaScript

const { test } = require("node:test");
const assert = require("node:assert");
const { buildSnapshot } = require("../src/commands/fetch-lineworks");
test("buildSnapshot fetches all five resource types and stamps fetchedAt", async () => {
const calls = [];
const deps = {
fetchAccessToken: async () => "tok",
fetchUsers: async () => { calls.push("users"); return [{ userId: "u1" }]; },
fetchOrgUnits: async () => { calls.push("orgUnits"); return [{ orgUnitId: "o1" }]; },
fetchPositions: async () => { calls.push("positions"); return [{ positionId: "p1" }]; },
fetchLevels: async () => { calls.push("levels"); return [{ levelId: "l1" }]; },
fetchUserTypes: async () => { calls.push("userTypes"); return [{ userTypeId: "t1" }]; },
now: () => new Date("2026-08-08T01:00:00Z"),
};
const snapshot = await buildSnapshot({
clientId: "cid", clientSecret: "sec", serviceAccount: "svc", privateKey: "pk", scope: "directory.read",
}, deps);
assert.deepStrictEqual(calls.sort(), ["levels", "orgUnits", "positions", "userTypes", "users"]);
assert.strictEqual(snapshot.fetchedAt, "2026-08-08T01:00:00.000Z");
assert.strictEqual(snapshot.users.length, 1);
assert.strictEqual(snapshot.orgUnits[0].orgUnitId, "o1");
});