Testy e2e: resetDb czysci seed, test-all w Justfile; db.json 56 rezerwacji na 2 tygodnie
This commit is contained in:
24
Justfile
24
Justfile
@@ -43,6 +43,30 @@ test:
|
||||
e2e:
|
||||
node test_rms.mjs
|
||||
|
||||
# Uruchom WSZYSTKIE testy (jednostkowe + e2e) — startuje serwery, testuje, zamyka
|
||||
test-all:
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
echo ">>> Uruchamianie json-server na porcie {{API_PORT}}..."
|
||||
npx json-server --watch db.json --host 0.0.0.0 --port {{API_PORT}} >/tmp/jss.log 2>&1 &
|
||||
JSS_PID=$!
|
||||
echo ">>> Uruchamianie Vite dev server na porcie {{DEV_PORT}}..."
|
||||
npm run dev >/tmp/vite.log 2>&1 &
|
||||
VITE_PID=$!
|
||||
trap "kill $JSS_PID $VITE_PID 2>/dev/null; wait $JSS_PID $VITE_PID 2>/dev/null; true" EXIT
|
||||
echo ">>> Oczekiwanie na gotowość serwerów..."
|
||||
sleep 5
|
||||
echo ""
|
||||
echo "========================================="
|
||||
echo " Vitest — testy jednostkowe"
|
||||
echo "========================================="
|
||||
npm run test -- --run
|
||||
echo ""
|
||||
echo "========================================="
|
||||
echo " Playwright — testy e2e"
|
||||
echo "========================================="
|
||||
node test_rms.mjs
|
||||
|
||||
# Uruchom Storybook
|
||||
storybook:
|
||||
npm run storybook
|
||||
|
||||
54
README.md
54
README.md
@@ -241,7 +241,57 @@ type Mutation {
|
||||
|
||||
## Wyniki testów
|
||||
|
||||
### Vitest — testy jednostkowe
|
||||
|
||||
```
|
||||
Vitest (jednostkowe): 25 passed, 0 failed
|
||||
Playwright (e2e): 32 passed, 0 failed, 2 warnings
|
||||
src/tests/StatusBadge.test.jsx 6 tests
|
||||
src/tests/ProtectedRoute.test.jsx 4 tests
|
||||
src/components/StatusBadge.test.jsx 6 tests
|
||||
src/tests/BookingForm.test.jsx 5 tests
|
||||
src/tests/LoginPage.test.jsx 4 tests
|
||||
|
||||
Test Files 5 passed (5)
|
||||
Tests 25 passed (25)
|
||||
Duration 1.22s
|
||||
```
|
||||
|
||||
### Playwright — testy e2e
|
||||
|
||||
```
|
||||
PASS Login page loads (email field visible)
|
||||
PASS Wrong credentials → error message
|
||||
PASS Admin login → /admin
|
||||
PASS Admin table — 56 rows
|
||||
PASS Confirm button visible
|
||||
PASS Confirm click updates row to Confirmed
|
||||
PASS Delete confirmation modal opens
|
||||
PASS Calendar tab button visible
|
||||
PASS Calendar view renders month — June 2026
|
||||
PASS Calendar weekday headers render
|
||||
WARN No busy day cells visible in current month view
|
||||
PASS Calendar next-month navigation — July 2026
|
||||
PASS Admin logout → /login
|
||||
PASS Client login → /dashboard
|
||||
PASS AvailabilitySearch section renders
|
||||
PASS Date syncs to URL
|
||||
PASS Service syncs to URL
|
||||
PASS Time slot grid renders (09:00 visible)
|
||||
PASS Slot click (09:00) jumps wizard to step 3
|
||||
PASS Wizard renders at step 1 after reload
|
||||
PASS Service cards render
|
||||
PASS Wizard step 2 (Date & Time)
|
||||
PASS Wizard step 3 (Requirements)
|
||||
PASS Wizard step 4 (Summary)
|
||||
PASS Confirm & Pay button in step 4
|
||||
PASS Payment modal opens
|
||||
PASS Deposit amount displayed — $25.00
|
||||
PASS Full booking flow — Booking Confirmed shown
|
||||
WARN Receipt block not visible
|
||||
PASS My Reservations sidebar renders
|
||||
PASS My Reservations lists items
|
||||
PASS Cancel from My Reservations updates status
|
||||
PASS Dark mode toggle works
|
||||
PASS Client blocked from /admin → redirected to /dashboard
|
||||
|
||||
32 passed · 2 warnings · 0 failed
|
||||
```
|
||||
|
||||
413
db.json
413
db.json
@@ -66,7 +66,7 @@
|
||||
"serviceId": "s1",
|
||||
"date": "2026-06-25",
|
||||
"time": "09:00",
|
||||
"status": "pending"
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r2",
|
||||
@@ -107,6 +107,417 @@
|
||||
"date": "2026-07-03",
|
||||
"time": "16:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r7",
|
||||
"userId": "u2",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-06-22",
|
||||
"time": "09:00",
|
||||
"status": "cancelled"
|
||||
},
|
||||
{
|
||||
"id": "r8",
|
||||
"userId": "u3",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-06-22",
|
||||
"time": "10:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r9",
|
||||
"userId": "u4",
|
||||
"serviceId": "s2",
|
||||
"date": "2026-06-22",
|
||||
"time": "11:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r10",
|
||||
"userId": "u2",
|
||||
"serviceId": "s4",
|
||||
"date": "2026-06-22",
|
||||
"time": "14:00",
|
||||
"status": "cancelled"
|
||||
},
|
||||
{
|
||||
"id": "r11",
|
||||
"userId": "u3",
|
||||
"serviceId": "s3",
|
||||
"date": "2026-06-22",
|
||||
"time": "15:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r12",
|
||||
"userId": "u4",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-06-23",
|
||||
"time": "09:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r13",
|
||||
"userId": "u2",
|
||||
"serviceId": "s2",
|
||||
"date": "2026-06-23",
|
||||
"time": "10:00",
|
||||
"status": "cancelled"
|
||||
},
|
||||
{
|
||||
"id": "r14",
|
||||
"userId": "u3",
|
||||
"serviceId": "s4",
|
||||
"date": "2026-06-23",
|
||||
"time": "13:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r15",
|
||||
"userId": "u4",
|
||||
"serviceId": "s4",
|
||||
"date": "2026-06-23",
|
||||
"time": "13:30",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r16",
|
||||
"userId": "u2",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-06-23",
|
||||
"time": "16:00",
|
||||
"status": "cancelled"
|
||||
},
|
||||
{
|
||||
"id": "r17",
|
||||
"userId": "u3",
|
||||
"serviceId": "s2",
|
||||
"date": "2026-06-24",
|
||||
"time": "09:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r18",
|
||||
"userId": "u4",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-06-24",
|
||||
"time": "10:30",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r19",
|
||||
"userId": "u2",
|
||||
"serviceId": "s3",
|
||||
"date": "2026-06-24",
|
||||
"time": "13:00",
|
||||
"status": "cancelled"
|
||||
},
|
||||
{
|
||||
"id": "r20",
|
||||
"userId": "u3",
|
||||
"serviceId": "s4",
|
||||
"date": "2026-06-24",
|
||||
"time": "15:30",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r21",
|
||||
"userId": "u4",
|
||||
"serviceId": "s4",
|
||||
"date": "2026-06-25",
|
||||
"time": "10:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r22",
|
||||
"userId": "u2",
|
||||
"serviceId": "s2",
|
||||
"date": "2026-06-25",
|
||||
"time": "11:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r23",
|
||||
"userId": "u3",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-06-25",
|
||||
"time": "14:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r24",
|
||||
"userId": "u4",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-06-26",
|
||||
"time": "09:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r25",
|
||||
"userId": "u2",
|
||||
"serviceId": "s3",
|
||||
"date": "2026-06-26",
|
||||
"time": "13:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r26",
|
||||
"userId": "u3",
|
||||
"serviceId": "s4",
|
||||
"date": "2026-06-26",
|
||||
"time": "16:00",
|
||||
"status": "pending"
|
||||
},
|
||||
{
|
||||
"id": "r27",
|
||||
"userId": "u2",
|
||||
"serviceId": "s4",
|
||||
"date": "2026-06-27",
|
||||
"time": "09:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r28",
|
||||
"userId": "u3",
|
||||
"serviceId": "s2",
|
||||
"date": "2026-06-27",
|
||||
"time": "10:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r29",
|
||||
"userId": "u4",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-06-28",
|
||||
"time": "09:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r30",
|
||||
"userId": "u2",
|
||||
"serviceId": "s2",
|
||||
"date": "2026-06-28",
|
||||
"time": "11:00",
|
||||
"status": "pending"
|
||||
},
|
||||
{
|
||||
"id": "r31",
|
||||
"userId": "u3",
|
||||
"serviceId": "s3",
|
||||
"date": "2026-06-28",
|
||||
"time": "14:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r32",
|
||||
"userId": "u4",
|
||||
"serviceId": "s4",
|
||||
"date": "2026-06-29",
|
||||
"time": "09:30",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r33",
|
||||
"userId": "u2",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-06-29",
|
||||
"time": "10:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r34",
|
||||
"userId": "u3",
|
||||
"serviceId": "s2",
|
||||
"date": "2026-06-29",
|
||||
"time": "14:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r35",
|
||||
"userId": "u4",
|
||||
"serviceId": "s3",
|
||||
"date": "2026-06-29",
|
||||
"time": "15:30",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r36",
|
||||
"userId": "u2",
|
||||
"serviceId": "s4",
|
||||
"date": "2026-06-30",
|
||||
"time": "09:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r37",
|
||||
"userId": "u3",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-06-30",
|
||||
"time": "10:00",
|
||||
"status": "pending"
|
||||
},
|
||||
{
|
||||
"id": "r38",
|
||||
"userId": "u4",
|
||||
"serviceId": "s2",
|
||||
"date": "2026-06-30",
|
||||
"time": "13:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r39",
|
||||
"userId": "u2",
|
||||
"serviceId": "s3",
|
||||
"date": "2026-06-30",
|
||||
"time": "15:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r40",
|
||||
"userId": "u4",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-07-01",
|
||||
"time": "09:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r41",
|
||||
"userId": "u2",
|
||||
"serviceId": "s2",
|
||||
"date": "2026-07-01",
|
||||
"time": "10:30",
|
||||
"status": "pending"
|
||||
},
|
||||
{
|
||||
"id": "r42",
|
||||
"userId": "u3",
|
||||
"serviceId": "s4",
|
||||
"date": "2026-07-01",
|
||||
"time": "15:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r43",
|
||||
"userId": "u4",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-07-02",
|
||||
"time": "09:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r44",
|
||||
"userId": "u2",
|
||||
"serviceId": "s3",
|
||||
"date": "2026-07-02",
|
||||
"time": "11:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r45",
|
||||
"userId": "u3",
|
||||
"serviceId": "s2",
|
||||
"date": "2026-07-02",
|
||||
"time": "14:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r46",
|
||||
"userId": "u4",
|
||||
"serviceId": "s4",
|
||||
"date": "2026-07-02",
|
||||
"time": "16:30",
|
||||
"status": "pending"
|
||||
},
|
||||
{
|
||||
"id": "r47",
|
||||
"userId": "u2",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-07-03",
|
||||
"time": "09:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r48",
|
||||
"userId": "u3",
|
||||
"serviceId": "s4",
|
||||
"date": "2026-07-03",
|
||||
"time": "10:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r49",
|
||||
"userId": "u4",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-07-03",
|
||||
"time": "11:30",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r50",
|
||||
"userId": "u2",
|
||||
"serviceId": "s2",
|
||||
"date": "2026-07-04",
|
||||
"time": "10:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r51",
|
||||
"userId": "u3",
|
||||
"serviceId": "s3",
|
||||
"date": "2026-07-04",
|
||||
"time": "13:00",
|
||||
"status": "pending"
|
||||
},
|
||||
{
|
||||
"id": "r52",
|
||||
"userId": "u4",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-07-04",
|
||||
"time": "15:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r53",
|
||||
"userId": "u2",
|
||||
"serviceId": "s4",
|
||||
"date": "2026-07-05",
|
||||
"time": "09:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r54",
|
||||
"userId": "u3",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-07-05",
|
||||
"time": "10:30",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r55",
|
||||
"userId": "u4",
|
||||
"serviceId": "s2",
|
||||
"date": "2026-07-05",
|
||||
"time": "14:00",
|
||||
"status": "confirmed"
|
||||
},
|
||||
{
|
||||
"id": "r56",
|
||||
"userId": "u2",
|
||||
"serviceId": "s3",
|
||||
"date": "2026-07-05",
|
||||
"time": "16:00",
|
||||
"status": "pending"
|
||||
},
|
||||
{
|
||||
"userId": "u2",
|
||||
"serviceId": "s1",
|
||||
"date": "2026-09-01",
|
||||
"time": "14:30",
|
||||
"specialRequirements": null,
|
||||
"status": "pending",
|
||||
"depositPaid": 25,
|
||||
"transactionId": "TXN-5708T6YZ",
|
||||
"id": "I_Q1QJ91gZ8"
|
||||
}
|
||||
],
|
||||
"$schema": "./node_modules/json-server/schema.json"
|
||||
|
||||
10
test_rms.mjs
10
test_rms.mjs
@@ -29,6 +29,16 @@ async function resetDb() {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
// Delete any reservations created by previous test runs (not part of seed r1–r56).
|
||||
const seedIds = new Set(Array.from({ length: 56 }, (_, i) => `r${i + 1}`));
|
||||
const all = await fetch(`${api}/reservations`).then((r) => r.json()).catch(() => []);
|
||||
await Promise.all(
|
||||
all
|
||||
.filter((r) => !seedIds.has(r.id))
|
||||
.map((r) => fetch(`${api}/reservations/${r.id}`, { method: 'DELETE' }))
|
||||
);
|
||||
|
||||
// Ensure r1 and r2 are pending so admin-confirm test always finds a button.
|
||||
await patch('r1', { status: 'pending' });
|
||||
await patch('r2', { status: 'pending' });
|
||||
|
||||
Reference in New Issue
Block a user