base-data-manager/test/facebook.ts

73 lines
2.5 KiB
TypeScript

import test from "node:test";
import nodePath from "node:path";
import { strict as assert } from "node:assert";
import { finished } from "node:stream/promises";
import { Readable, Writable } from "node:stream";
import { TaskTargetPipelineHelper, TaskTarget, verify, getTSVManifest, getTaskManifest, run } from "../data-export/task.ts";
import { parallel } from "../data-export/parallel.ts";
import "../data-export/facebook.ts";
const THIS_FILE = import.meta.dirname;
const FACEBOOK_V1_DIR = nodePath.join(THIS_FILE, 'fixtures/facebook-json-2021-05-01');
const FACEBOOK_V1_ZIPPED = nodePath.join(THIS_FILE, 'fixtures/facebook-json-2021-05-01.zip');
const FACEBOOK_V2_DIR = nodePath.join(THIS_FILE, 'fixtures/facebook-json-2025-11-29');
test("facebook: Can load the 2021 export", async (t) => {
const targets = TaskTargetPipelineHelper.pipeline([
new TaskTarget(FACEBOOK_V1_DIR)
])
.facebook();
const finalTargets = await verify(targets);
const result = await parallel(finalTargets, true);
for (const [id, r] of result.entries()) {
assert.ok(!r.stderr, `Task ${id} should have no stderr output`);
assert.ok(r.ok, `Task ${id} should be okay`);
}
const allCSV = Array.from(result.entries())
.sort() // Keep stable ordering for snapshots
.map(([id, r]) => r.stdout);
t.assert.snapshot(allCSV);
});
test("facebook: Can load the 2021 export zipped", async (t) => {
const targets = await TaskTargetPipelineHelper.pipeline([
new TaskTarget(FACEBOOK_V1_ZIPPED)
])
.unzip();
const targets2 = targets
.facebook();
const finalTargets = await verify(targets2);
const result = await parallel(finalTargets, true);
for (const [id, r] of result.entries()) {
assert.ok(!r.stderr, `Task ${id} should have no stderr output`);
assert.ok(r.ok, `Task ${id} should be okay`);
}
const allCSV = Array.from(result.entries())
.sort() // Keep stable ordering for snapshots
.map(([id, r]) => r.stdout);
t.assert.snapshot(allCSV);
});
test("facebook: Can load the 2025 export", async (t) => {
const targets = TaskTargetPipelineHelper.pipeline([
new TaskTarget(FACEBOOK_V2_DIR)
])
.facebook_v2();
const finalTargets = await verify(targets);
const result = await parallel(finalTargets, true);
for (const [id, r] of result.entries()) {
assert.ok(!r.stderr, `Task ${id} should have no stderr output`);
assert.ok(r.ok, `Task ${id} should be okay`);
}
const allCSV = Array.from(result.entries())
.sort() // Keep stable ordering for snapshots
.map(([id, r]) => r.stdout);
t.assert.snapshot(allCSV);
});