mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-08-28 17:21:05 +00:00
e6b8be6821
OAuth flows through accounts.betterseqta.org with token exchange server-side. Sync runs in the content script to avoid MV3 service worker timeouts. Adds Svelte calendar sync UI on the timetable page, extension asset URL helper, and excludes calendar tokens from cloud sync. Co-authored-by: Cursor <cursoragent@cursor.com>
65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "@jest/globals";
|
|
import {
|
|
lessonToGoogleEvent,
|
|
mapLessonsToGoogleEvents,
|
|
seqtaLessonKey,
|
|
shouldSyncLesson,
|
|
} from "./eventMapper";
|
|
import type { SeqtaTimetableLesson } from "./types";
|
|
|
|
const ORIGIN = "https://school.seqta.com.au";
|
|
|
|
const baseLesson: SeqtaTimetableLesson = {
|
|
date: "2026-06-27",
|
|
from: "09:00:00",
|
|
until: "10:00:00",
|
|
description: "10 Mathematics",
|
|
staff: "Mr Smith",
|
|
room: "MA1",
|
|
code: "10MAT",
|
|
type: "class",
|
|
calendarid: 12345,
|
|
};
|
|
|
|
describe("shouldSyncLesson", () => {
|
|
it("accepts normal class rows", () => {
|
|
expect(shouldSyncLesson(baseLesson)).toBe(true);
|
|
});
|
|
|
|
it("rejects holidays and rows without times", () => {
|
|
expect(shouldSyncLesson({ ...baseLesson, type: "holiday" })).toBe(false);
|
|
expect(shouldSyncLesson({ ...baseLesson, from: "" })).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("seqtaLessonKey", () => {
|
|
it("prefers calendarid when present", () => {
|
|
expect(seqtaLessonKey(ORIGIN, baseLesson)).toBe(`${ORIGIN}:cal:12345`);
|
|
});
|
|
});
|
|
|
|
describe("lessonToGoogleEvent", () => {
|
|
it("maps SEQTA lesson fields to Google event input", () => {
|
|
const event = lessonToGoogleEvent(ORIGIN, baseLesson, "Australia/Perth");
|
|
expect(event).toMatchObject({
|
|
summary: "10 Mathematics",
|
|
location: "MA1",
|
|
startDateTime: "2026-06-27T09:00:00",
|
|
endDateTime: "2026-06-27T10:00:00",
|
|
timeZone: "Australia/Perth",
|
|
});
|
|
expect(event?.description).toContain("Mr Smith");
|
|
});
|
|
});
|
|
|
|
describe("mapLessonsToGoogleEvents", () => {
|
|
it("deduplicates by seqta key", () => {
|
|
const events = mapLessonsToGoogleEvents(
|
|
ORIGIN,
|
|
[baseLesson, { ...baseLesson }],
|
|
"Australia/Perth",
|
|
);
|
|
expect(events).toHaveLength(1);
|
|
});
|
|
});
|