feat(home): ชั้นกรองที่ 1 — ประเภทโรงหนัง (ท้องถิ่น / อินดี้ / กลุ่มคนฉายหนัง)
- แถบกรองสองชั้นในแถวเดียว: ทั้งหมด → 3 ประเภท │ ยอดนิยม → หมวดภาพยนตร์เดิม
- เก็บประเภทที่ฟิลด์เดี่ยว cinema.venue_type (ค่าเดียว) + hasVenue()/filterCinemas({ venue })
- ย้าย "กลุ่มคนฉายหนัง" จาก categories ขึ้นชั้น 1 (ไม่ให้ปุ่มซ้ำ) · tag ยังอยู่และยังค้นหาเจอ
- เลือกได้ทีละชั้น: กดประเภทล้างหมวด / กดหมวดล้างประเภท / ทั้งหมดล้างทั้งคู่
- ปิด popularity path เมื่อกรองด้วยประเภท (กันจัดอันดับข้ามประเภท)
- หลังบ้าน: ช่อง "ประเภทโรงหนัง" ในหมวดข้อมูลหลัก + sanitize เฉพาะค่าใน VENUE_TYPES
- i18n: messages.venues (TH/EN) · override ได้ผ่าน site.terms
- scripts/set-venue-types.mjs จัดประเภท 29 โรง (15 ท้องถิ่น / 11 อินดี้ / 3 กลุ่มคนฉายหนัง) พร้อมสำรอง content.json
- tests: hasVenue + filterCinemas (165 ผ่าน) · sw v2.0.5 · DESIGN/AGENTS/README/admin-guide/api อัปเดต
This commit is contained in:
1 parent
2e794cd365
commit
1932098a1d
15 files changed
+362
-26
No files matched your search
+73
-2
@@ -1,10 +1,13 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
findCinemaBySlug,
|
||||
listOtherCinemas,
|
||||
CINEMAS,
|
||||
findCinemaBySlug,
|
||||
hasVenue,
|
||||
listOtherCinemas,
|
||||
type Cinema,
|
||||
} from "./cinemas";
|
||||
import { filterCinemas } from "./search";
|
||||
|
||||
describe("findCinemaBySlug", () => {
|
||||
it("คืน undefined เมื่อไม่ได้ส่ง slug", () => {
|
||||
@@ -27,3 +30,71 @@ describe("listOtherCinemas", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("hasVenue / filterCinemas (ชั้นกรองประเภทโรงหนัง)", () => {
|
||||
const base = {
|
||||
slug: "x",
|
||||
name: "X",
|
||||
tags: ["อาร์ตเฮาส์"],
|
||||
location_label: "",
|
||||
coordinates: null,
|
||||
description: "",
|
||||
map_url: null,
|
||||
address_lines: [],
|
||||
transport: [],
|
||||
contacts: [],
|
||||
payments: [],
|
||||
photos: [],
|
||||
} as Cinema;
|
||||
|
||||
const local: Cinema = {
|
||||
...base,
|
||||
slug: "local",
|
||||
venue_type: "โรงภาพยนตร์ท้องถิ่น",
|
||||
};
|
||||
const indie: Cinema = { ...base, slug: "indie", venue_type: "โรงภาพยนตร์อินดี้" };
|
||||
const group: Cinema = { ...base, slug: "group", venue_type: "กลุ่มคนฉายหนัง" };
|
||||
const unset: Cinema = { ...base, slug: "unset" };
|
||||
|
||||
it("hasVenue: null = ไม่กรอง", () => {
|
||||
expect(hasVenue(local, null)).toBe(true);
|
||||
expect(hasVenue(unset, null)).toBe(true);
|
||||
});
|
||||
|
||||
it("hasVenue: ตรงประเภทเท่านั้น", () => {
|
||||
expect(hasVenue(local, "โรงภาพยนตร์ท้องถิ่น")).toBe(true);
|
||||
expect(hasVenue(local, "โรงภาพยนตร์อินดี้")).toBe(false);
|
||||
expect(hasVenue(unset, "โรงภาพยนตร์อินดี้")).toBe(false);
|
||||
});
|
||||
|
||||
it("filterCinemas กรองตามประเภทได้", () => {
|
||||
const all = [local, indie, group, unset];
|
||||
expect(
|
||||
filterCinemas(all, {
|
||||
category: "ทั้งหมด",
|
||||
query: "",
|
||||
venue: "โรงภาพยนตร์อินดี้",
|
||||
}),
|
||||
).toEqual([indie]);
|
||||
expect(
|
||||
filterCinemas(all, {
|
||||
category: "ทั้งหมด",
|
||||
query: "",
|
||||
venue: "กลุ่มคนฉายหนัง",
|
||||
}),
|
||||
).toEqual([group]);
|
||||
expect(filterCinemas(all, { category: "ทั้งหมด", query: "" })).toHaveLength(
|
||||
4,
|
||||
);
|
||||
});
|
||||
|
||||
it("กรองประเภท + หมวดซ้อนกันได้ (AND)", () => {
|
||||
expect(
|
||||
filterCinemas([local, indie], {
|
||||
category: "อาร์ตเฮาส์",
|
||||
query: "",
|
||||
venue: "โรงภาพยนตร์ท้องถิ่น",
|
||||
}),
|
||||
).toEqual([local]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user