Test writing conventions
📄 Source: Google Sheet - Master V1
📁 Location: All tests must be written as individual .spec.ts files inside the src/tests directory.
⚠️ Disclaimer
Before creating a test case in code, make sure the test case is properly defined in the Master V1 Excel sheet.
This includes:
- Filling in the
id,category,test_case, and related metadata - Ensuring vendor and inventory flags are accurate
This helps maintain traceability and alignment between code and documentation.
📘 Test Case Structure & Naming Convention
| Field | Description |
|---|---|
| ID | Unique identifier for the test case (e.g., tc-001). |
| Category | Logical grouping of the test case (e.g., Pax Qty, Phone Number). |
| Test Case | Clear and concise title of the test scenario. |
| Action | Actions being tested: Create, Update, Delete. |
| Vendors | Vendors involved in the test (e.g., GYG, OpenRice, RWG-E2E). |
| Inventory | Inventory source (e.g., HungryHub, TableCheck, Weeloy). |
| Pricing Type | e.g., Per Person, Per Pack. |
| Payment Type | e.g., Pay Now, Post Paid, Pre Paid. |
🧪 Example Test Case (from tc-001)
| Field | Value |
|---|---|
| ID | tc-001 |
| Category | Pax Qty |
| Test Case | Reservation with 1 adult (Per Person & Prepaid) |
| Create | ✅ true |
| Update | ❌ false |
| Delete | ❌ false |
| Vendors | GYG, OpenRice, Sparklove, Linktivity, Royal Orchid |
| Inventory | HungryHub, TableCheck, Sevenroom, Weeloy |
| Pricing Type | Per Person |
| Payment Type | Pay Now |
🔖 ID & Naming Format
- Prefix with
tc-for general test cases:- ✅ Example:
tc-001,tc-002, ...
- ✅ Example:
- Test case titles should start with a verb and reflect what is being validated, such as:
- “Reservation with 1 adult Per Person and Prepaid”
- “Reservation with invalid phone number”
- “Cancel reservation with 2 kids on Per Pack plan”
🧾 Master Data Fields
| Data Type | Example Values |
|---|---|
| Vendors | GYG, OpenRice, RWG-E2E, Linktivity, Royal Orchid etc ... |
| Inventories | HungryHub, TableCheck, Sevenroom, Weeloy |
| Pricing Types | Per Person, Per Pack |
| Payment Types | Pay Now, Post Paid, Pre Paid |
| Categories | Based on the theme |
🔖 Naming Rules
- Files must be named after the test case ID (e.g.,
tc-001.ts,tc-014.ts). - Use kebab-case if including suffixes, like
tc-001-prepaid.ts. - Folder structure remains flat inside
src/tests.
✅ Tips
- Use constants from
~/constantfor vendors, inventory, pricing, and payment types. - For
customer, usegetCustomerByType("random")or define your type-specific logic. - Avoid hardcoding IDs that may change dynamically unless explicitly required.
📘 Test Case File Structure
Each file should follow this naming format and structure:
✅ File Name
src/tests/tc-001.ts
import { runVendorTests } from "~/services/testRunner";
import { PricingType } from "../types";
import type { ReservationData } from "~/types/Reservation";
import { getCustomerByType } from "~/helper/getCustomer";
import {
INV_SRC_HUNGRYHUB,
INV_SRC_SEVENROOM,
INV_SRC_TABLECHECK,
INV_SRC_WEELOY,
VENDOR_GYG,
VENDOR_OPENRICE,
VENDOR_SPARKLOVE,
VENDOR_LINKTIVITY,
VENDOR_ROYALORCHIDPLUS,
PRICING_PER_PERSON,
PAYMENT_PAY_NOW,
} from "~/constant";
const reservationData: ReservationData = {
id: "tc-001",
category: "pax-qty",
testCase: "Reservation with 1 adult Per Person and Prepaid",
action: {
create: true,
update: false,
delete: false,
},
inventory: {
[INV_SRC_HUNGRYHUB]: true,
[INV_SRC_SEVENROOM]: true,
[INV_SRC_TABLECHECK]: true,
[INV_SRC_WEELOY]: true,
},
pricingType: PRICING_PER_PERSON,
paymentType: PAYMENT_PREPAID,
countries: {
th: true,
sg: false,
},
vendor: {
[VENDOR_GYG]: true,
[VENDOR_OPENRICE]: true,
[VENDOR_SPARKLOVE]: true,
[VENDOR_LINKTIVITY]: true,
[VENDOR_ROYALORCHIDPLUS]: true,
},
adult: 1,
kids: 0,
customer: getCustomerByType("random"),
};
// Execute testawait runVendorTests(reservationData);