Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

FieldDescription
IDUnique identifier for the test case (e.g., tc-001).
CategoryLogical grouping of the test case (e.g., Pax Qty, Phone Number).
Test CaseClear and concise title of the test scenario.
ActionActions being tested: Create, Update, Delete.
VendorsVendors involved in the test (e.g., GYG, OpenRice, RWG-E2E).
InventoryInventory source (e.g., HungryHub, TableCheck, Weeloy).
Pricing Typee.g., Per Person, Per Pack.
Payment Typee.g., Pay Now, Post Paid, Pre Paid.

🧪 Example Test Case (from tc-001)

FieldValue
IDtc-001
CategoryPax Qty
Test CaseReservation with 1 adult (Per Person & Prepaid)
Createtrue
Updatefalse
Deletefalse
VendorsGYG, OpenRice, Sparklove, Linktivity, Royal Orchid
InventoryHungryHub, TableCheck, Sevenroom, Weeloy
Pricing TypePer Person
Payment TypePay Now

🔖 ID & Naming Format

  • Prefix with tc- for general test cases:
    • ✅ Example: tc-001, tc-002, ...
  • 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 TypeExample Values
VendorsGYG, OpenRice, RWG-E2E, Linktivity, Royal Orchid etc ...
InventoriesHungryHub, TableCheck, Sevenroom, Weeloy
Pricing TypesPer Person, Per Pack
Payment TypesPay Now, Post Paid, Pre Paid
CategoriesBased 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 ~/constant for vendors, inventory, pricing, and payment types.
  • For customer, use getCustomerByType("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);