chore(publish): replace source tree with static export at repo root
Publish the prerendered static export (index.html, 404.html, cinema/,
c/, about/, for-cinemas/, for-film-lovers/, assets/, images/, og/,
sitemap.xml, robots.txt) as the site root and remove the React Router
+ Nitro source tree from this branch. Source remains available in
history at 0548772.
Note: public/sw.js here reports VERSION v2.0.5 while the removed source
tree (v2.1.0) was newer, and .gitignore was not carried over.
This commit is contained in:
1 parent
05487728a7
commit
e6c4ebff48
394 files changed
+3977
-37891
No files matched your search
@@ -1,79 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { dailyOrder, dayKey, keepsSamePositions } from "@/lib/daily-order";
|
||||
|
||||
/**
|
||||
* เงื่อนไขที่ผู้ใช้กำหนด: โรงหนังทุกโรงต้องไม่ได้ตำแหน่งการ์ดเดิมติดกัน 2 วัน
|
||||
*/
|
||||
|
||||
function slugs(count: number): string[] {
|
||||
return Array.from({ length: count }, (_, index) => `cinema-${index + 1}`);
|
||||
}
|
||||
|
||||
function nextDay(key: string, plus = 1): string {
|
||||
const date = new Date(`${key}T00:00:00Z`);
|
||||
date.setUTCDate(date.getUTCDate() + plus);
|
||||
return dayKey(date);
|
||||
}
|
||||
|
||||
describe("dailyOrder", () => {
|
||||
it("วันเดียวกันให้ลำดับเดิมเสมอ (SSR กับ client ตรงกัน)", () => {
|
||||
const list = slugs(27);
|
||||
const a = dailyOrder(list, (slug) => slug, "2026-11-01");
|
||||
const b = dailyOrder(list, (slug) => slug, "2026-11-01");
|
||||
expect(a).toEqual(b);
|
||||
});
|
||||
|
||||
it("มีครบทุกรายการ ไม่ซ้ำ ไม่หาย", () => {
|
||||
const list = slugs(27);
|
||||
const order = dailyOrder(list, (slug) => slug, "2026-11-01");
|
||||
expect(order).toHaveLength(27);
|
||||
expect(new Set(order)).toEqual(new Set(list));
|
||||
});
|
||||
|
||||
it("วันติดกัน: ไม่มีรายการใดอยู่ตำแหน่งเดิม (n = 2..40, 10 วัน)", () => {
|
||||
for (let count = 2; count <= 40; count += 1) {
|
||||
const list = slugs(count);
|
||||
let previous = dailyOrder(list, (slug) => slug, "2026-11-01");
|
||||
for (let day = 1; day <= 10; day += 1) {
|
||||
const key = nextDay("2026-11-01", day);
|
||||
const current = dailyOrder(list, (slug) => slug, key);
|
||||
const stuck = keepsSamePositions(previous, current, (slug) => slug);
|
||||
expect({ count, key, stuck }).toEqual({ count, key, stuck: [] });
|
||||
previous = current;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("ลำดับเปลี่ยนจริงข้ามวัน (ไม่ใช่อาร์เรย์เดิม)", () => {
|
||||
const list = slugs(10);
|
||||
const day1 = dailyOrder(list, (slug) => slug, "2026-11-01");
|
||||
const day2 = dailyOrder(list, (slug) => slug, "2026-11-02");
|
||||
expect(day1).not.toEqual(day2);
|
||||
});
|
||||
|
||||
it("ไม่ตรงกับลำดับที่กรอกเข้ามา (มีการสลับจริง ไม่ใช่เรียงเดิม)", () => {
|
||||
const list = slugs(12);
|
||||
const order = dailyOrder(list, (slug) => slug, "2026-11-01");
|
||||
expect(order).not.toEqual(list);
|
||||
});
|
||||
|
||||
it("รายการเดียว/ว่าง ไม่พัง", () => {
|
||||
expect(dailyOrder(["only"], (slug) => slug, "2026-11-01")).toEqual(["only"]);
|
||||
expect(dailyOrder([], (slug) => slug, "2026-11-01")).toEqual([]);
|
||||
});
|
||||
|
||||
it("แอดมินสลับลำดับฐาน → ผลลัพธ์เปลี่ยนตาม (seed มาจากลำดับที่กรอก)", () => {
|
||||
const a = dailyOrder(slugs(8), (slug) => slug, "2026-11-01");
|
||||
const reversed = [...slugs(8)].reverse();
|
||||
const b = dailyOrder(reversed, (slug) => slug, "2026-11-01");
|
||||
expect(a).not.toEqual(b);
|
||||
});
|
||||
});
|
||||
|
||||
describe("dayKey", () => {
|
||||
it("คืนรูปแบบ YYYY-MM-DD แบบ UTC", () => {
|
||||
expect(dayKey(new Date("2026-11-01T23:30:00Z"))).toBe("2026-11-01");
|
||||
expect(dayKey(new Date("2026-11-02T00:30:00Z"))).toBe("2026-11-02");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user