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,183 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { CINEMAS, DEFAULT_CATEGORY, type Cinema } from "./cinemas";
|
||||
import {
|
||||
buildSearchIndex,
|
||||
FIELD_WEIGHTS,
|
||||
filterCinemas,
|
||||
foldSearchText,
|
||||
normalizeSearchText,
|
||||
scoreCinema,
|
||||
searchTokens,
|
||||
} from "./search";
|
||||
|
||||
describe("normalizeSearchText", () => {
|
||||
it("ตัดช่องว่างหัวท้าย ลดตัวพิมพ์ และแปลงตัวคั่นเป็นช่องว่าง", () => {
|
||||
expect(normalizeSearchText(" HOUSE · สามย่าน ")).toBe("house สามย่าน");
|
||||
expect(normalizeSearchText("DOC CLUB & FRIENDS")).toBe("doc club friends");
|
||||
});
|
||||
|
||||
it("ตัดอักขระล่องหนที่ติดมากับการคัดลอก", () => {
|
||||
expect(normalizeSearchText("เฮ้า\u200Bส์")).toBe("เฮ้าส์");
|
||||
});
|
||||
});
|
||||
|
||||
describe("foldSearchText", () => {
|
||||
it("ตัดวรรณยุกต์ภาษาอังกฤษ (Française → francaise)", () => {
|
||||
expect(foldSearchText("Française")).toBe("francaise");
|
||||
});
|
||||
|
||||
it("ตัดวรรณยุกต์ไทย (เฮ้าส์ → เฮาส)", () => {
|
||||
expect(foldSearchText("เฮ้าส์")).toBe("เฮาส");
|
||||
});
|
||||
});
|
||||
|
||||
describe("searchTokens", () => {
|
||||
it("แยกหลายคำ และคืนอาร์เรย์ว่างเมื่อไม่มีคำค้น", () => {
|
||||
expect(searchTokens(" สามย่าน house ")).toEqual(["สามย่าน", "house"]);
|
||||
expect(searchTokens(" ")).toEqual([]);
|
||||
expect(searchTokens("·")).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("filterCinemas", () => {
|
||||
it("คืนทุกโรงหนังเมื่อเลือกหมวดทั้งหมดและไม่พิมพ์ค้นหา", () => {
|
||||
const result = filterCinemas(CINEMAS, {
|
||||
category: DEFAULT_CATEGORY,
|
||||
query: "",
|
||||
});
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("กรองตามหมวดหมู่จาก tags", () => {
|
||||
const result = filterCinemas(CINEMAS, {
|
||||
category: "อาร์ตเฮาส์",
|
||||
query: "",
|
||||
});
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
expect(result.every((cinema) => cinema.tags.includes("อาร์ตเฮาส์"))).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("ค้นหาแบบไม่สนตัวพิมพ์และตัดช่องว่างหัวท้าย", () => {
|
||||
const result = filterCinemas(CINEMAS, {
|
||||
category: DEFAULT_CATEGORY,
|
||||
query: " house ",
|
||||
});
|
||||
expect(result.map((cinema) => cinema.slug)).toContain(
|
||||
"house-cinema-samyan",
|
||||
);
|
||||
});
|
||||
|
||||
it("คืนอาร์เรย์ว่างเมื่อไม่พบคำค้น", () => {
|
||||
expect(
|
||||
filterCinemas(CINEMAS, {
|
||||
category: DEFAULT_CATEGORY,
|
||||
query: "ไม่มีโรงนี้แน่นอน",
|
||||
}),
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
// ── ค้นด้วยข้อความที่แสดงบนการ์ดจริง ────────────────────────────────
|
||||
it("ค้นด้วยชื่อไทยที่แสดงบนการ์ด (name_th) ได้", () => {
|
||||
const result = filterCinemas(CINEMAS, {
|
||||
category: DEFAULT_CATEGORY,
|
||||
query: "เซ็นจูรี่มูฟวี่พลาซ่า",
|
||||
});
|
||||
expect(result.map((cinema) => cinema.slug)).toContain(
|
||||
"century-the-movie-plaza",
|
||||
);
|
||||
});
|
||||
|
||||
it("ค้นด้วยชื่อไทยที่พิมพ์ไม่ครบ (คำนำหน้า) ได้", () => {
|
||||
const result = filterCinemas(CINEMAS, {
|
||||
category: DEFAULT_CATEGORY,
|
||||
query: "เซ็นจูรี่",
|
||||
});
|
||||
expect(result.length).toBeGreaterThan(1);
|
||||
expect(
|
||||
result.every((cinema) => (cinema.name_th ?? "").includes("เซ็นจูรี่")),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("ค้นชื่ออังกฤษแบบไม่ใส่วรรณยุกต์ก็เจอ", () => {
|
||||
expect(
|
||||
filterCinemas(CINEMAS, {
|
||||
category: DEFAULT_CATEGORY,
|
||||
query: "francaise",
|
||||
}).map((cinema) => cinema.slug),
|
||||
).toContain("alliance-francaise-de-bangkok");
|
||||
});
|
||||
|
||||
it("ค้นด้วยชื่อหมวดที่แสดงบนการ์ดได้ (ทั้งคีย์ไทยและป้ายภาษาอังกฤษ)", () => {
|
||||
const th = filterCinemas(CINEMAS, {
|
||||
category: DEFAULT_CATEGORY,
|
||||
query: "อาร์ตเฮาส์",
|
||||
});
|
||||
expect(th.map((cinema) => cinema.slug)).toContain("house-cinema-samyan");
|
||||
|
||||
const en = filterCinemas(CINEMAS, {
|
||||
category: DEFAULT_CATEGORY,
|
||||
query: "arthouse",
|
||||
tagLabels: { อาร์ตเฮาส์: "Arthouse" },
|
||||
});
|
||||
expect(en.map((cinema) => cinema.slug)).toContain("house-cinema-samyan");
|
||||
});
|
||||
|
||||
it("ค้นหลายคำสลับลำดับได้ (ทุกคำต้องเจอ)", () => {
|
||||
const result = filterCinemas(CINEMAS, {
|
||||
category: DEFAULT_CATEGORY,
|
||||
query: "samyan HOUSE",
|
||||
});
|
||||
expect(result.map((cinema) => cinema.slug)).toEqual([
|
||||
"house-cinema-samyan",
|
||||
]);
|
||||
});
|
||||
|
||||
it("ค้นข้อความที่คัดลอกมาจากการ์ดทั้งบรรทัด (มีตัวคั่น ·) ได้", () => {
|
||||
const result = filterCinemas(CINEMAS, {
|
||||
category: DEFAULT_CATEGORY,
|
||||
query: "HOUSE สามย่าน · อาร์ตเฮาส์",
|
||||
});
|
||||
expect(result.map((cinema) => cinema.slug)).toContain(
|
||||
"house-cinema-samyan",
|
||||
);
|
||||
});
|
||||
|
||||
it("เรียงผลลัพธ์ที่ตรงที่สุดก่อน", () => {
|
||||
const result = filterCinemas(CINEMAS, {
|
||||
category: DEFAULT_CATEGORY,
|
||||
query: "cineplex",
|
||||
});
|
||||
expect(result[0]?.slug).toBe("thana-cineplex");
|
||||
});
|
||||
});
|
||||
|
||||
describe("scoreCinema", () => {
|
||||
const house = CINEMAS.find(
|
||||
(cinema) => cinema.slug === "house-cinema-samyan",
|
||||
) as Cinema;
|
||||
|
||||
it("คืน 0 เมื่อไม่มีคำค้น หรือคำค้นไม่ตรงเลย", () => {
|
||||
expect(scoreCinema(house, [])).toBe(0);
|
||||
expect(scoreCinema(house, searchTokens("zzzz"))).toBe(0);
|
||||
});
|
||||
|
||||
it("ชื่อที่ตรงทั้งคำได้คะแนนสูงกว่าการเจอในรายละเอียด", () => {
|
||||
const byName = scoreCinema(house, searchTokens("house"));
|
||||
const byTag = scoreCinema(house, searchTokens("อาร์ตเฮาส์"));
|
||||
expect(byName).toBeGreaterThan(byTag);
|
||||
expect(byName).toBeGreaterThanOrEqual(FIELD_WEIGHTS.names);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildSearchIndex", () => {
|
||||
it("เตรียมฟิลด์ชื่อ/สถานที่/หมวดไว้เทียบ และไม่เก็บค่าว่าง", () => {
|
||||
const index = buildSearchIndex(CINEMAS[0], { อาร์ตเฮาส์: "Arthouse" });
|
||||
expect(index.length).toBeGreaterThan(0);
|
||||
expect(index.every((field) => field.exact !== "")).toBe(true);
|
||||
expect(index.some((field) => field.exact.includes("arthouse"))).toBe(true);
|
||||
expect(index.some((field) => field.group === "names")).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user