feat: enhance lesson plan handling with new parser and color-coded room assignments
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { test, before, after } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { setTimeout as sleep } from "node:timers/promises";
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
import { startApi } from "./support/nextcloud.js";
|
||||
|
||||
// The university is asked politely: every request names the service and its owner, and while
|
||||
@@ -62,3 +63,17 @@ test("Источник: пока университет не отвечает,
|
||||
assert.equal(catalog.failingSince, null);
|
||||
assert.ok(!(await (await fetch(api.base + "/api/catalog")).json()).stale);
|
||||
});
|
||||
|
||||
test("Источник: новый парсер перечитывает сохранённый документ, не обращаясь к университету", async () => {
|
||||
const { files } = await (await fetch(api.base + "/api/catalog")).json();
|
||||
const file = files.find((f) => f.name === "23-ЛГ_23-БА.docx");
|
||||
assert.equal((await fetch(api.base + "/api/schedule/" + file.id)).status, 200);
|
||||
// The cache as an older parser left it.
|
||||
const cache = `${process.env.PSU_DATA_DIR}/parsed/${file.id}.json`;
|
||||
writeFileSync(cache, JSON.stringify({ ...JSON.parse(readFileSync(cache, "utf8")), schemaVersion: 1 }));
|
||||
const requests = api.stats.requests;
|
||||
const schedule = await (await fetch(api.base + "/api/schedule/" + file.id)).json();
|
||||
assert.equal(api.stats.requests, requests);
|
||||
assert.notEqual(schedule.schemaVersion, 1);
|
||||
assert.ok(schedule.lessons.length > 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user