lightweight, client-only calendar web application. All data persists in the URL hash for instant sharing, No backend required. Optional AES-GCM password protection keeps shared links locked without a server
JavaScript
feat: add comprehensive E2E tests for event handling, notification permissions, and URL path imports
Supun Lakmal18118566d705
diff --git a/tests/e2e/browser-apis.chromium.e2e.spec.js b/tests/e2e/browser-apis.chromium.e2e.spec.jsindex 01b700e..f5ac8ee 100644--- a/tests/e2e/browser-apis.chromium.e2e.spec.js+++ b/tests/e2e/browser-apis.chromium.e2e.spec.js@@ -60,6 +60,103 @@ test("notification toggle requests permission and flips state", async ({ page })await expect.poll(() => page.evaluate(() => window.__notifyRequestCount)).toBe(1);});+test("notification toggle handles denied permission without requesting again", async ({ page }) => {+ await page.addInitScript(() => {+ window.__notifyRequestCount = 0;++ function MockNotification() {+ this.close = () => {};+ this.onclick = null;+ }++ MockNotification.permission = "denied";+ MockNotification.requestPermission = async () => {+ window.__notifyRequestCount += 1;+ return "denied";+ };++ window.Notification = MockNotification;+ });++ await page.goto("/");+ await waitForApp(page);+ await createEvent(page, { title: `NotifyDenied-${Date.now()}`, allDay: true });++ await clickSettingsControl(page, "#notify-toggle");+ await expect(page.locator("#notify-toggle")).toContainText(/Blocked/i);+ await expect.poll(() => page.evaluate(() => window.__notifyRequestCount)).toBe(0);+});++test("enabling notifications triggers an upcoming event notification when event is 30 minutes away", async ({ page }) => {+ await page.addInitScript(() => {+ window.__notifications = [];++ function MockNotification(title, options = {}) {+ window.__notifications.push({+ title: String(title || ""),+ body: String(options.body || ""),+ tag: String(options.tag || ""),+ });+ this.close = () => {};+ this.onclick = null;+ }++ MockNotification.permission = "granted";+ MockNotification.requestPermission = async () => "granted";+ window.Notification = MockNotification;+ });++ await page.goto("/");+ await waitForApp(page);++ const title = `NotifySoon-${Date.now()}`;+ const timing = await page.evaluate(() => {+ const formatDate = (d) => {+ const yyyy = d.getFullYear();+ const mm = String(d.getMonth() + 1).padStart(2, "0");+ const dd = String(d.getDate()).padStart(2, "0");+ return `${yyyy}-${mm}-${dd}`;+ };+ const formatTime = (d) => {+ const hh = String(d.getHours()).padStart(2, "0");+ const mm = String(d.getMinutes()).padStart(2, "0");+ return `${hh}:${mm}`;+ };++ const start = new Date(Date.now() + 30 * 60 * 1000);+ start.setSeconds(0, 0);+ const end = new Date(start.getTime() + 30 * 60 * 1000);++ return {+ startDate: formatDate(start),+ startTime: formatTime(start),+ endDate: formatDate(end),+ endTime: formatTime(end),+ };+ });++ await page.click("#add-event");+ await expect(page.locator("#event-modal")).toBeVisible();+ await page.fill("#event-title", title);+ await page.uncheck("#event-all-day");+ await page.fill("#event-date", timing.startDate);+ await page.fill("#event-time", timing.startTime);+ await page.fill("#event-end-date", timing.endDate);+ await page.fill("#event-end-time", timing.endTime);+ await page.click("#event-save");++ await expect(page.locator("#event-list .event-title", { hasText: title })).toBeVisible();++ await clickSettingsControl(page, "#notify-toggle");+ await expect(page.locator("#notify-toggle")).toContainText(/On/i);++ await expect.poll(() => page.evaluate(() => window.__notifications.length)).toBeGreaterThan(0);++ const firstNotification = await page.evaluate(() => window.__notifications[0] || null);+ expect(firstNotification).not.toBeNull();+ expect(firstNotification.title).toContain(title);+});+test("copy hash from JSON modal writes to clipboard", async ({ page }) => {await page.addInitScript(() => {window.__copiedText = "";diff --git a/tests/e2e/date-edge.e2e.spec.js b/tests/e2e/date-edge.e2e.spec.jsnew file mode 100644index 0000000..7b24b74--- /dev/null+++ b/tests/e2e/date-edge.e2e.spec.js@@ -0,0 +1,141 @@+const { test, expect } = require("@playwright/test");+const { waitForApp } = require("./helpers.cjs");++function formatDateKey(date) {+ const yyyy = date.getFullYear();+ const mm = String(date.getMonth() + 1).padStart(2, "0");+ const dd = String(date.getDate()).padStart(2, "0");+ return `${yyyy}-${mm}-${dd}`;+}++function findNextMonthEndPair(from = new Date()) {+ const cursor = new Date(from.getFullYear(), from.getMonth(), 1);+ for (let i = 0; i < 24; i += 1) {+ const year = cursor.getFullYear();+ const month = cursor.getMonth();+ const daysInMonth = new Date(year, month + 1, 0).getDate();+ const daysInNextMonth = new Date(year, month + 2, 0).getDate();+ if (daysInMonth === 31 && daysInNextMonth < 31) {+ return {+ baseKey: formatDateKey(new Date(year, month, 31)),+ targetKey: formatDateKey(new Date(year, month + 1, daysInNextMonth)),+ };+ }+ cursor.setMonth(month + 1, 1);+ }+ throw new Error("Could not find month-end fallback test window");+}++function findNextLeapYear(year) {+ let y = year;+ while (!(y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0))) {+ y += 1;+ }+ return y;+}++async function navigateFromCurrentMonth(page, targetKey) {+ const diff = await page.evaluate((key) => {+ const [year, month] = String(key).split("-").map(Number);+ const now = new Date();+ const nowTotal = now.getFullYear() * 12 + now.getMonth();+ const targetTotal = year * 12 + (month - 1);+ return targetTotal - nowTotal;+ }, targetKey);+ if (diff > 0) {+ for (let i = 0; i < diff; i += 1) {+ await page.click("#next-month");+ }+ } else if (diff < 0) {+ for (let i = 0; i < Math.abs(diff); i += 1) {+ await page.click("#prev-month");+ }+ }+}++test.beforeEach(async ({ page }) => {+ await page.goto("/");+ await waitForApp(page);+});++async function createRecurringAllDayEvent(page, { title, dateKey, recurrence }) {+ await page.click("#add-event");+ await expect(page.locator("#event-modal")).toBeVisible();+ await page.fill("#event-title", title);+ await page.fill("#event-date", dateKey);+ await page.check("#event-all-day");+ await page.selectOption("#event-recurrence", recurrence);+ await page.click("#event-save");+ await expect(page.locator("#event-modal")).toBeHidden();+}++test("cross-day timed event appears on both start and end dates", async ({ page }) => {+ const title = `CrossDay-${Date.now()}`;+ const dates = await page.evaluate(() => {+ const format = (d) => {+ const yyyy = d.getFullYear();+ const mm = String(d.getMonth() + 1).padStart(2, "0");+ const dd = String(d.getDate()).padStart(2, "0");+ return `${yyyy}-${mm}-${dd}`;+ };+ const today = new Date();+ const tomorrow = new Date(today.getTime());+ tomorrow.setDate(tomorrow.getDate() + 1);+ return { todayKey: format(today), tomorrowKey: format(tomorrow) };+ });++ await page.click("#add-event");+ await expect(page.locator("#event-modal")).toBeVisible();+ await page.fill("#event-title", title);+ await page.uncheck("#event-all-day");+ await page.fill("#event-date", dates.todayKey);+ await page.fill("#event-time", "23:30");+ await page.fill("#event-end-date", dates.tomorrowKey);+ await page.fill("#event-end-time", "01:15");+ await page.click("#event-save");+ await expect(page.locator("#event-modal")).toBeHidden();++ await expect(page.locator("#event-list .event-title", { hasText: title })).toBeVisible();++ await page.click(`.day-cell[data-date="${dates.tomorrowKey}"] .day-number`);+ await expect(page.locator("#event-list .event-title", { hasText: title })).toBeVisible();++ await page.locator("#event-list .event-item", { hasText: title }).first().click();+ await expect(page.locator("#event-date")).toHaveValue(dates.todayKey);+ await expect(page.locator("#event-end-date")).toHaveValue(dates.tomorrowKey);+ await expect(page.locator("#event-time")).toHaveValue("23:30");+ await expect(page.locator("#event-end-time")).toHaveValue("01:15");+ await page.click("#event-cancel");+});++test("monthly recurrence from day 31 falls back to next month end", async ({ page }) => {+ const title = `MonthEdge-${Date.now()}`;+ const { baseKey, targetKey } = findNextMonthEndPair(new Date());++ await createRecurringAllDayEvent(page, {+ title,+ dateKey: baseKey,+ recurrence: "m",+ });++ await navigateFromCurrentMonth(page, targetKey);+ await page.click(`.day-cell[data-date="${targetKey}"] .day-number`);+ await expect(page.locator("#event-list .event-title", { hasText: title })).toBeVisible();+});++test("yearly recurrence from leap day falls back to Feb 28 on non-leap year", async ({ page }) => {+ const title = `LeapEdge-${Date.now()}`;+ const leapYear = findNextLeapYear(new Date().getFullYear());+ const baseKey = `${leapYear}-02-29`;+ const targetKey = `${leapYear + 1}-02-28`;++ await createRecurringAllDayEvent(page, {+ title,+ dateKey: baseKey,+ recurrence: "y",+ });++ await navigateFromCurrentMonth(page, targetKey);+ await page.click(`.day-cell[data-date="${targetKey}"] .day-number`);+ await expect(page.locator("#event-list .event-title", { hasText: title })).toBeVisible();+});diff --git a/tests/e2e/hash-compat.e2e.spec.js b/tests/e2e/hash-compat.e2e.spec.jsnew file mode 100644index 0000000..3ec5a54--- /dev/null+++ b/tests/e2e/hash-compat.e2e.spec.js@@ -0,0 +1,21 @@+const { test, expect } = require("@playwright/test");+const { waitForApp } = require("./helpers.cjs");++test("legacy timezone arrays are migrated into mp.z when loading from hash", async ({ page }) => {+ await page.goto("/");++ const hash = await page.evaluate(() => {+ const payload = {+ mp: { z: ["Asia/Tokyo"] },+ tz: ["Europe/London"],+ s: { v: "month" },+ };+ return window.LZString.compressToEncodedURIComponent(JSON.stringify(payload));+ });++ await page.goto(`/#${hash}`);+ await waitForApp(page);++ await expect(page.locator("#tz-list")).toContainText(/Tokyo/i);+ await expect(page.locator("#tz-list")).toContainText(/London/i);+});diff --git a/tests/e2e/ics-import.e2e.spec.js b/tests/e2e/ics-import.e2e.spec.jsnew file mode 100644index 0000000..2777001--- /dev/null+++ b/tests/e2e/ics-import.e2e.spec.js@@ -0,0 +1,98 @@+const { test, expect } = require("@playwright/test");+const { getDateKeyOffset, waitForApp } = require("./helpers.cjs");++function toYmdCompact(date) {+ const yyyy = date.getFullYear();+ const mm = String(date.getMonth() + 1).padStart(2, "0");+ const dd = String(date.getDate()).padStart(2, "0");+ return `${yyyy}${mm}${dd}`;+}++test.beforeEach(async ({ page }) => {+ await page.goto("/");+ await waitForApp(page);+});++test("ics weekly RRULE imports and recurs 7 days later", async ({ page }) => {+ const title = `ICSWeekly-${Date.now()}`;+ const today = new Date();+ const tomorrow = new Date(today.getTime());+ tomorrow.setDate(tomorrow.getDate() + 1);++ const ics = [+ "BEGIN:VCALENDAR",+ "VERSION:2.0",+ "BEGIN:VEVENT",+ `SUMMARY:${title}`,+ `DTSTART;VALUE=DATE:${toYmdCompact(today)}`,+ `DTEND;VALUE=DATE:${toYmdCompact(tomorrow)}`,+ "RRULE:FREQ=WEEKLY",+ "END:VEVENT",+ "END:VCALENDAR",+ "",+ ].join("\n");++ await page.setInputFiles("#ics-input", {+ name: "weekly.ics",+ mimeType: "text/calendar",+ buffer: Buffer.from(ics),+ });++ await expect(page.locator("#event-list .event-title", { hasText: title })).toBeVisible();++ const weekLater = await getDateKeyOffset(page, 7);+ await page.click(`.day-cell[data-date="${weekLater}"] .day-number`);+ await expect(page.locator("#event-list .event-title", { hasText: title })).toBeVisible();+});++test("ics timed UTC event preserves start and end times", async ({ page }) => {+ const title = `ICSTimed-${Date.now()}`;+ const now = new Date();+ const ymd = toYmdCompact(now);++ const ics = [+ "BEGIN:VCALENDAR",+ "VERSION:2.0",+ "BEGIN:VEVENT",+ `SUMMARY:${title}`,+ `DTSTART:${ymd}T100000Z`,+ `DTEND:${ymd}T113000Z`,+ "END:VEVENT",+ "END:VCALENDAR",+ "",+ ].join("\n");++ await page.setInputFiles("#ics-input", {+ name: "timed.ics",+ mimeType: "text/calendar",+ buffer: Buffer.from(ics),+ });++ await expect(page.locator("#event-list .event-title", { hasText: title })).toBeVisible();++ await page.locator("#event-list .event-item", { hasText: title }).first().click();+ await expect(page.locator("#event-modal")).toBeVisible();+ await expect(page.locator("#event-all-day")).not.toBeChecked();+ await expect(page.locator("#event-time")).toHaveValue("10:00");+ await expect(page.locator("#event-end-time")).toHaveValue("11:30");+ await page.click("#event-cancel");+});++test("ics import with no valid events shows an error toast and keeps calendar unchanged", async ({ page }) => {+ const invalidIcs = [+ "BEGIN:VCALENDAR",+ "VERSION:2.0",+ "PRODID:-//No Events//EN",+ "END:VCALENDAR",+ "",+ ].join("\n");++ await page.setInputFiles("#ics-input", {+ name: "invalid.ics",+ mimeType: "text/calendar",+ buffer: Buffer.from(invalidIcs),+ });++ await expect(page.locator(".toast", { hasText: /No events found/i })).toBeVisible();+ await expect(page.locator("#event-list .event-title")).toHaveCount(0);+});diff --git a/tests/e2e/json-bridge.e2e.spec.js b/tests/e2e/json-bridge.e2e.spec.jsnew file mode 100644index 0000000..f60f291--- /dev/null+++ b/tests/e2e/json-bridge.e2e.spec.js@@ -0,0 +1,44 @@+const { test, expect } = require("@playwright/test");+const { waitForApp } = require("./helpers.cjs");++function buildPayload(title) {+ const startMin = Math.floor(Date.now() / 60000);+ return {+ t: `Bridge-${Date.now()}`,+ e: [[startMin, 0, title, 0]],+ s: { v: "month" },+ };+}++async function openBridgeAndWait(page, queryKey, payload) {+ const encoded = encodeURIComponent(JSON.stringify(payload));+ await page.goto(`/json.html?${queryKey}=${encoded}`);+ await page.waitForURL((url) => !url.pathname.endsWith("/json.html") && url.hash.length > 1);+ await waitForApp(page);+}++["json", "data", "state", "payload"].forEach((queryKey) => {+ test(`json bridge accepts ${queryKey} query key`, async ({ page }) => {+ const title = `BridgeEvent-${queryKey}-${Date.now()}`;+ const payload = buildPayload(title);++ await openBridgeAndWait(page, queryKey, payload);++ await expect(page.locator("#event-list .event-title", { hasText: title })).toBeVisible();+ await expect(page).toHaveURL(/#.+/);+ });+});++test("json bridge shows error for missing payload", async ({ page }) => {+ await page.goto("/json.html");++ await expect(page.locator("#status")).toContainText("Missing JSON payload.");+ await expect(page).toHaveURL(/\/json\.html$/);+});++test("json bridge shows error for invalid payload", async ({ page }) => {+ await page.goto("/json.html?json=%7Bnot-valid-json");++ await expect(page.locator("#status")).toContainText("Invalid JSON payload");+ await expect(page).toHaveURL(/\/json\.html\?json=/);+});diff --git a/tests/e2e/module-logic.chromium.e2e.spec.js b/tests/e2e/module-logic.chromium.e2e.spec.jsnew file mode 100644index 0000000..a5b6027--- /dev/null+++ b/tests/e2e/module-logic.chromium.e2e.spec.js@@ -0,0 +1,96 @@+const { test, expect } = require("@playwright/test");++test.beforeEach(async ({ page }) => {+ await page.goto("/");+});++test("urlPathEventParser handles documented patterns and fallback title", async ({ page }) => {+ const entries = await page.evaluate(async () => {+ const { parsePathToEventEntries } = await import("/modules/urlPathEventParser.js");+ return parsePathToEventEntries("/2025/12/25/10/00+90/Family-Brunch,2025/12/25/Christmas-Day,2025/12/25")+ .map((entry) => ({+ startMin: entry[0],+ duration: entry[1],+ title: entry[2],+ colorIndex: entry[3],+ }));+ });++ expect(entries).toHaveLength(3);+ expect(entries[0].duration).toBe(90);+ expect(entries[0].title).toBe("Family Brunch");+ expect(entries[0].colorIndex).toBe(0);+ expect(entries[1].duration).toBe(0);+ expect(entries[1].title).toBe("Christmas Day");+ expect(entries[2].title).toBe("New Event (URL)");+});++test("icsImporter maps RRULE frequency values to internal recurrence rules", async ({ page }) => {+ const rules = await page.evaluate(async () => {+ const { parseIcs } = await import("/modules/icsImporter.js");+ const ics = [+ "BEGIN:VCALENDAR",+ "VERSION:2.0",+ "BEGIN:VEVENT",+ "SUMMARY:Daily Event",+ "DTSTART;VALUE=DATE:20260101",+ "RRULE:FREQ=DAILY",+ "END:VEVENT",+ "BEGIN:VEVENT",+ "SUMMARY:Weekly Event",+ "DTSTART;VALUE=DATE:20260102",+ "RRULE:FREQ=WEEKLY",+ "END:VEVENT",+ "BEGIN:VEVENT",+ "SUMMARY:Monthly Event",+ "DTSTART;VALUE=DATE:20260103",+ "RRULE:FREQ=MONTHLY",+ "END:VEVENT",+ "BEGIN:VEVENT",+ "SUMMARY:Yearly Event",+ "DTSTART;VALUE=DATE:20260104",+ "RRULE:FREQ=YEARLY",+ "END:VEVENT",+ "BEGIN:VEVENT",+ "SUMMARY:Unsupported Event",+ "DTSTART;VALUE=DATE:20260105",+ "RRULE:FREQ=HOURLY",+ "END:VEVENT",+ "END:VCALENDAR",+ "",+ ].join("\n");++ return parseIcs(ics).map((event) => event.rule || "");+ });++ expect(rules).toEqual(["d", "w", "m", "y", ""]);+});++test("recurrenceEngine expands month-end and leap-day recurrences to valid dates", async ({ page }) => {+ const result = await page.evaluate(async () => {+ const { expandEvents } = await import("/modules/recurrenceEngine.js");+ const toMin = (iso) => Math.floor(new Date(iso).getTime() / 60000);++ const monthEdgeEvents = [[toMin("2025-01-31T00:00:00Z"), 0, "MonthEdge", 0, "m"]];+ const leapEdgeEvents = [[toMin("2024-02-29T00:00:00Z"), 0, "LeapEdge", 0, "y"]];++ const monthOccurrences = expandEvents(+ monthEdgeEvents,+ new Date("2025-02-01T00:00:00Z"),+ new Date("2025-02-28T23:59:59Z"),+ );+ const leapOccurrences = expandEvents(+ leapEdgeEvents,+ new Date("2025-02-01T00:00:00Z"),+ new Date("2025-02-28T23:59:59Z"),+ );++ return {+ monthStartIso: monthOccurrences[0] ? new Date(monthOccurrences[0].start).toISOString() : null,+ leapStartIso: leapOccurrences[0] ? new Date(leapOccurrences[0].start).toISOString() : null,+ };+ });++ expect(result.monthStartIso).toContain("2025-02-28T00:00:00.000Z");+ expect(result.leapStartIso).toContain("2025-02-28T00:00:00.000Z");+});diff --git a/tests/e2e/path-import.e2e.spec.js b/tests/e2e/path-import.e2e.spec.jsnew file mode 100644index 0000000..5f99a73--- /dev/null+++ b/tests/e2e/path-import.e2e.spec.js@@ -0,0 +1,78 @@+const { test, expect } = require("@playwright/test");+const { waitForApp } = require("./helpers.cjs");++test.beforeEach(async ({ page }) => {+ await page.goto("/");+ await waitForApp(page);+});++test("hash-path all-day pattern imports and rewrites dashes in title", async ({ page }) => {+ const today = await page.evaluate(() => {+ const d = new Date();+ return { y: d.getFullYear(), m: d.getMonth() + 1, day: d.getDate() };+ });++ const slugTitle = `All-Day-Path-${Date.now()}`;+ const expectedTitle = slugTitle.replace(/-/g, " ");++ await page.goto(`/#/${today.y}/${today.m}/${today.day}/${slugTitle}`);+ await waitForApp(page);++ await expect(page.locator("#event-list .event-title", { hasText: expectedTitle })).toBeVisible();+ await expect.poll(() => page.url()).not.toContain("#/");+});++test("hash-path timed pattern with +minutes sets the correct duration", async ({ page }) => {+ const today = await page.evaluate(() => {+ const d = new Date();+ return { y: d.getFullYear(), m: d.getMonth() + 1, day: d.getDate() };+ });++ const title = `PathDuration${Date.now()}`;+ await page.goto(`/#/${today.y}/${today.m}/${today.day}/10/00+90/${title}`);+ await waitForApp(page);++ await expect(page.locator("#event-list .event-title", { hasText: title })).toBeVisible();++ await page.locator("#event-list .event-item").first().click();+ await expect(page.locator("#event-modal")).toBeVisible();+ await expect(page.locator("#event-all-day")).not.toBeChecked();+ await expect(page.locator("#event-time")).toHaveValue("10:00");+ await expect(page.locator("#event-end-time")).toHaveValue("11:30");+ await page.click("#event-cancel");+});++test("hash-path supports multi-event links and imports once", async ({ page }) => {+ const today = await page.evaluate(() => {+ const d = new Date();+ return { y: d.getFullYear(), m: d.getMonth() + 1, day: d.getDate() };+ });++ const titleA = `PathMultiA${Date.now()}`;+ const titleB = `PathMultiB${Date.now() + 1}`;+ const path = `/#/${today.y}/${today.m}/${today.day}/${titleA},${today.y}/${today.m}/${today.day}/10/15/${titleB}`;++ await page.goto(path);+ await waitForApp(page);++ await expect(page.locator("#event-list .event-title", { hasText: titleA })).toBeVisible();+ await expect(page.locator("#event-list .event-title", { hasText: titleB })).toBeVisible();+ await expect.poll(() => page.url()).not.toContain("#/");++ await page.reload();+ await waitForApp(page);+ await expect(page.locator("#event-list .event-title", { hasText: titleA })).toHaveCount(1);+ await expect(page.locator("#event-list .event-title", { hasText: titleB })).toHaveCount(1);+});++test("hash-path falls back to default title when title is missing", async ({ page }) => {+ const today = await page.evaluate(() => {+ const d = new Date();+ return { y: d.getFullYear(), m: d.getMonth() + 1, day: d.getDate() };+ });++ await page.goto(`/#/${today.y}/${today.m}/${today.day}`);+ await waitForApp(page);++ await expect(page.locator("#event-list .event-title", { hasText: "New Event (URL)" })).toBeVisible();+});diff --git a/tests/e2e/regression.cross.e2e.spec.js b/tests/e2e/regression.cross.e2e.spec.jsnew file mode 100644index 0000000..79f13f9--- /dev/null+++ b/tests/e2e/regression.cross.e2e.spec.js@@ -0,0 +1,46 @@+const { test, expect } = require("@playwright/test");+const { createEvent, waitForApp, waitForPersist } = require("./helpers.cjs");++test.beforeEach(async ({ page }) => {+ await page.goto("/");+ await waitForApp(page);+});++test("read-only mode hides edit-heavy sections across browsers", async ({ page }) => {+ await page.click("#readonly-btn");+ await expect(page.locator("#readonly-btn")).toHaveAttribute("aria-pressed", "true");+ await expect(page.locator("#add-event")).toBeHidden();+ await expect(page.locator("#share-export-section")).toBeHidden();+ await expect(page.locator("#danger-zone-section")).toBeHidden();+});++test("json modal opens with persisted hash after creating an event", async ({ page }) => {+ const title = `CrossJson-${Date.now()}`;+ await createEvent(page, { title, allDay: true });+ await waitForPersist(page);++ await page.click("#view-json");+ await expect(page.locator("#json-modal")).toBeVisible();+ await expect(page.locator("#json-output")).toHaveValue(new RegExp(title));+ await expect(page.locator("#json-hash")).toHaveValue(/#/);+ await page.click("#json-close");+ await expect(page.locator("#json-modal")).toBeHidden();+});++test("hash-path all-day import rewrites hash and persists once across browsers", async ({ page }) => {+ const today = await page.evaluate(() => {+ const d = new Date();+ return { y: d.getFullYear(), m: d.getMonth() + 1, day: d.getDate() };+ });+ const title = `CrossPath${Date.now()}`;++ await page.goto(`/#/${today.y}/${today.m}/${today.day}/${title}`);+ await waitForApp(page);++ await expect(page.locator("#event-list .event-title", { hasText: title })).toBeVisible();+ await expect.poll(() => page.url()).not.toContain("#/");++ await page.reload();+ await waitForApp(page);+ await expect(page.locator("#event-list .event-title", { hasText: title })).toHaveCount(1);+});diff --git a/tests/e2e/security-negative.e2e.spec.js b/tests/e2e/security-negative.e2e.spec.jsnew file mode 100644index 0000000..0926957--- /dev/null+++ b/tests/e2e/security-negative.e2e.spec.js@@ -0,0 +1,51 @@+const { test, expect } = require("@playwright/test");+const { createEvent, waitForApp } = require("./helpers.cjs");++test.beforeEach(async ({ page }) => {+ await page.goto("/");+ await waitForApp(page, { requireEventList: false });+});++test("wrong password keeps encrypted calendar locked", async ({ page }) => {+ const title = `LockedWrongPw-${Date.now()}`;+ const password = "correct-password-123";++ await createEvent(page, { title, allDay: true });++ await page.click("#lock-btn");+ await expect(page.locator("#password-modal")).toBeVisible();+ await page.fill("#password-input", password);+ await page.fill("#password-confirm", password);+ await page.click("#password-submit");++ await expect.poll(() => page.url()).toContain("#ENC:");++ await page.reload();+ await waitForApp(page, { requireEventList: false });+ await expect(page.locator("#locked-overlay")).toBeVisible();+ await expect(page.locator("#password-modal")).toBeVisible();++ await page.fill("#password-input", "wrong-password");+ await page.click("#password-submit");++ await expect(page.locator("#locked-overlay")).toBeVisible();+ await expect(page.locator(".toast", { hasText: /Incorrect password/i })).toBeVisible();+ await expect(page.locator("#event-list .event-title", { hasText: title })).toHaveCount(0);+});++test("malformed encrypted hash stays locked and fails unlock gracefully", async ({ page }) => {+ await page.goto("/#ENC:not-a-valid-encrypted-payload");+ await waitForApp(page, { requireEventList: false });++ await expect(page.locator("#locked-overlay")).toBeVisible();+ if (!(await page.locator("#password-modal").isVisible())) {+ await page.click("#lock-btn");+ }+ await expect(page.locator("#password-modal")).toBeVisible();++ await page.fill("#password-input", "any-password");+ await page.click("#password-submit");++ await expect(page.locator("#locked-overlay")).toBeVisible();+ await expect(page.locator(".toast", { hasText: /Incorrect password/i })).toBeVisible();+});diff --git a/tests/e2e/url-length.e2e.spec.js b/tests/e2e/url-length.e2e.spec.jsnew file mode 100644index 0000000..d751916--- /dev/null+++ b/tests/e2e/url-length.e2e.spec.js@@ -0,0 +1,50 @@+const { test, expect } = require("@playwright/test");+const { waitForApp } = require("./helpers.cjs");++test("long hashes show URL warnings and QR over-limit warning", async ({ page }) => {+ await page.goto("/");+ await waitForApp(page);++ await page.evaluate(() => {+ const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";+ const rand = (len) => {+ let out = "";+ for (let i = 0; i < len; i += 1) {+ out += chars[Math.floor(Math.random() * chars.length)];+ }+ return out;+ };+ const startMin = Math.floor(Date.now() / 60000);+ const payload = {+ t: `LengthSeed-${Date.now()}`,+ e: Array.from({ length: 180 }, (_, index) => [+ startMin + index,+ 0,+ `Len${index}-${rand(44)}`,+ index % 5,+ ]),+ };+ const compressed = window.LZString.compressToEncodedURIComponent(JSON.stringify(payload));+ window.location.hash = compressed;+ });++ await expect.poll(async () => {+ const text = await page.locator("#url-length").innerText();+ return Number(text.trim()) || 0;+ }).toBeGreaterThan(2000);++ const urlLength = Number((await page.locator("#url-length").innerText()).trim());+ expect(urlLength).toBeGreaterThan(2000);++ await expect(page.locator("#url-warning")).not.toHaveText("");+ await expect(page.locator("#mobile-url-warning")).not.toHaveText("");++ await page.click("#share-qr");+ await expect(page.locator("#qr-modal")).toBeVisible();+ await expect(page.locator("#qr-warning")).toBeVisible();+ await expect(page.locator("#qr-warning")).toContainText(/Warning:/i);+ await expect(page.locator("#qrcode-container canvas")).toHaveCount(0);++ await page.click("#qr-close");+ await expect(page.locator("#qr-modal")).toBeHidden();+});