enh
This commit is contained in:
parent
0721bd7019
commit
3347b0f6f1
7 changed files with 411 additions and 5 deletions
|
|
@ -98,7 +98,11 @@
|
|||
"Shell(NODE_ENV=test bunx jest --config tests/jest.config.js tests/home-page/navigation.test.tsx 2 >& 1)",
|
||||
"Shell(NODE_ENV=test bunx jest --config tests/jest.config.js tests/home-page/navigation.test.tsx -t routes to the slot view 2 >& 1)",
|
||||
"Shell(node inspect.cjs)",
|
||||
"Shell(node -e \" const s=require('/Users/mohammedshafiuddin/WebDev/freshyo/apps/user-ui/tests/mocks/mock-slots-response.json'); for (const id of [2,40,23]) { const idx = s.slots.findIndex(sl=>sl.products.some(p=>p.id===id)); const sl = s.slots[idx]; console.log('product', id, '-> slot index', idx, 'slotId', sl && sl.id, 'delivery', sl && sl.deliveryTime); } console.log('slot order:', s.slots.map(sl=>sl.id).join(',')); \")"
|
||||
"Shell(node -e \" const s=require('/Users/mohammedshafiuddin/WebDev/freshyo/apps/user-ui/tests/mocks/mock-slots-response.json'); for (const id of [2,40,23]) { const idx = s.slots.findIndex(sl=>sl.products.some(p=>p.id===id)); const sl = s.slots[idx]; console.log('product', id, '-> slot index', idx, 'slotId', sl && sl.id, 'delivery', sl && sl.deliveryTime); } console.log('slot order:', s.slots.map(sl=>sl.id).join(',')); \")",
|
||||
"Shell(cmd:*)",
|
||||
"Shell(which maestro || ls -la ~/.maestro 2>/dev/null | head -20; echo \"---\"; ls ~/.commandcode/mcp.json 2>/dev/null; echo \"--- project mcp\"; cat .mcp.json 2>/dev/null; echo \"--- other agent configs\"; grep -ril \"maestro\" ~/.claude.json ~/.cursor/mcp.json ~/.config/opencode/opencode.json ~/Library/Application\\ Support/Claude/claude_desktop_config.json 2>/dev/null)",
|
||||
"Shell(~/.maestro/bin/maestro:*)",
|
||||
"Shell(xcrun:*)"
|
||||
],
|
||||
"deny": [],
|
||||
"defaultMode": "default"
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@ er-ui/app/(drawer)/(tabs)/home/index.tsx, I want similar here") and expects the
|
|||
- Dislikes long lists of CLI flags for supplying run-time/test values and asks for a "better way" ("isn't there a better way to supply the values"). Expects values supplied declaratively: non-secret defaults committed in a config file (e.g. Maestro `config.yaml` `env:` block), secrets in a gitignored `.env`-style file, and a thin wrapper/runner script wired to a single package-manager entry point (`bun run e2e`) so one short command runs everything — with extra flags still passable through. Secrets should never be passed inline on the command line or committed. Confidence: 0.7
|
||||
- When he doubts the current approach ("isn't there a better way"), expects the agent to actually research the tool's documented capabilities (check `--help`, official docs) before proposing alternatives, rather than answering from memory. Confidence: 0.6
|
||||
- For mobile app E2E testing, wants Android ONLY and never iOS — stated explicitly: "I want to test only on android. Never on ios." The test runner/harness should be wired so it can never target an iOS simulator (e.g., pin the Android package id and always pass `--platform android`), rather than auto-detecting the platform from booted devices. Confidence: 0.9
|
||||
- The Android-only rule applies to the automated E2E suite, not to ad-hoc/interactive driving of a running app: when he just wants the app operated and inspected, he is happy to use whatever device is already booted, iOS included — "I have maestro mcp installed. I want you to use maestro to control my ios simulator." Expects the agent to check what tooling/MCP servers are actually available in the session, use the installed Maestro setup (MCP or CLI) rather than declaring it unavailable, and tell him how to register the MCP server so it loads in future sessions. Confidence: 0.45
|
||||
- For React Native / Expo mobile E2E automation, prefers **Maestro** (not Detox/Appium), with its flow configs in a folder at the repo ROOT named `e2e/` — "I want test end to end test automation with maestro. have a folder at the root named e2e" — mirroring his `tests/`-at-root convention for Playwright. Expects the tool's own YAML workspace layout inside it (`config.yaml`, `flows/`, reusable `subflows/`), not per-app test dirs. Confidence: 0.85
|
||||
- Wants E2E flows to take the shortest realistic user path and skip unnecessary intermediate screens — e.g., add to the cart directly from the home product card's cart icon instead of opening the product-detail screen first ("don't open any product detail. Just click on the cart icon of any product, then go to the cart page and then place order"). Confidence: 0.5
|
||||
- When he pastes a runtime error/log (e.g., a tRPC/D1 `Failed query: select ... from "key_val_store"` 500), he asks for an explanation first — "what does this error mean. Why am I seeing it" — expecting the agent to investigate and explain the root cause (local D1 state, migrations/config) before changing any code, not to jump straight to a fix. Confidence: 0.5
|
||||
|
|
@ -154,6 +155,7 @@ er-ui/app/(drawer)/(tabs)/home/index.tsx, I want similar here") and expects the
|
|||
- Prefers API payloads that are FLAT and fully resolved server-side: when a value can come from stacked scopes (bound → region → global), the backend must merge them into one flat JSON object so the client reads the final value directly, with no nested blocks and no client-side merge/precedence logic — "every bound should have all it's bound data, it's region's data and global data. It should be a flat json". Confidence: 0.7
|
||||
- When redesigning a data model, prefers a clean slate over patching the existing shape — instructs the agent to ignore the current implementation ("forget the current pattern") and re-specify storage from scratch, splitting what was one catch-all table into tables by natural scope instead of preserving legacy structure. Confidence: 0.6
|
||||
- When he changes a shared backend contract (response shape / query input), expects every consumer to be updated to the new shape in the same change and names the affected apps explicitly ("@apps/user-ui should be accomodated to expect this flat json and use this flat json") — a contract change is not done while any client still reads the old shape. Confidence: 0.65
|
||||
- Wants MCP servers configured at PROJECT scope (repo-root `.mcp.json`) rather than user/global scope — on being told a server would have to be added globally, he corrected with "I want mcp server in this project." So when registering MCP tooling (e.g. maestro), prefer `--scope project` so the config is scoped to and shareable with the repo. Confidence: 0.6
|
||||
e changes. Confidence: 0.95
|
||||
er-ui/app/(drawer)/(tabs)/home/index.tsx, I want similar here") and expects the agent to mirror that pattern exactly, including details like item counts and container styling. Confidence: 0.9
|
||||
als) rather than introducing new brand palettes; approval of a redesign's layout/composition does not imply approval of color or theme changes. Confidence: 0.95
|
||||
|
|
|
|||
12
.mcp.json
Normal file
12
.mcp.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"mcpServers": {
|
||||
"maestro": {
|
||||
"transport": "stdio",
|
||||
"enabled": true,
|
||||
"command": "/Users/mohammedshafiuddin/.maestro/bin/maestro",
|
||||
"args": [
|
||||
"mcp"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,43 @@
|
|||
import React from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import type { SlotSnippetInput } from '@packages/shared'
|
||||
import { View, Text, TouchableOpacity, Alert } from 'react-native';
|
||||
import { View, Text, TouchableOpacity, Alert, Keyboard } from 'react-native';
|
||||
import { Formik, FieldArray } from 'formik';
|
||||
import DateTimePickerMod from 'common-ui/src/components/date-time-picker';
|
||||
import { tw, MyTextInput } from 'common-ui';
|
||||
import { tw, MyTextInput, BottomDialog } from 'common-ui';
|
||||
import { trpc } from '../src/trpc-client';
|
||||
import ProductsSelector from '../components/ProductsSelector';
|
||||
|
||||
// Snippet form row — single source in @packages/shared (complete payload)
|
||||
type VendorSnippet = SlotSnippetInput
|
||||
|
||||
// __DEV__ test hook: parse a YYYY-MM-DD + HH:MM wall-clock as IST (UTC+5:30).
|
||||
// Returns null for bad shapes, out-of-range fields, or impossible dates.
|
||||
const IST_OFFSET_MS = (5 * 60 + 30) * 60 * 1000
|
||||
|
||||
function parseIstDateTime(dateStr: string, timeStr: string): Date | null {
|
||||
const dateMatch = /^(\d{4})-(\d{2})-(\d{2})$/.exec(dateStr.trim())
|
||||
const timeMatch = /^([01]\d|2[0-3]):([0-5]\d)$/.exec(timeStr.trim())
|
||||
if (!dateMatch || !timeMatch) return null
|
||||
const year = Number(dateMatch[1])
|
||||
const month = Number(dateMatch[2])
|
||||
const day = Number(dateMatch[3])
|
||||
const hour = Number(timeMatch[1])
|
||||
const minute = Number(timeMatch[2])
|
||||
const utcMs = Date.UTC(year, month - 1, day, hour, minute) - IST_OFFSET_MS
|
||||
// Round-trip through the offset: impossible dates (e.g. Feb 30) shift.
|
||||
const check = new Date(utcMs + IST_OFFSET_MS)
|
||||
if (
|
||||
check.getUTCFullYear() !== year ||
|
||||
check.getUTCMonth() !== month - 1 ||
|
||||
check.getUTCDate() !== day ||
|
||||
check.getUTCHours() !== hour ||
|
||||
check.getUTCMinutes() !== minute
|
||||
) {
|
||||
return null
|
||||
}
|
||||
return new Date(utcMs)
|
||||
}
|
||||
|
||||
interface SlotFormProps {
|
||||
onSlotAdded?: () => void;
|
||||
initialDeliveryTime?: Date | null;
|
||||
|
|
@ -58,6 +86,24 @@ export default function SlotForm({
|
|||
|
||||
const { data: groupsData } = trpc.admin.product.getGroups.useQuery();
|
||||
|
||||
// __DEV__-only hidden datetime entry (avoids the native date/time scrollers
|
||||
// in tests). Fields stay blank on every open — no prefill.
|
||||
const [devDialogOpen, setDevDialogOpen] = useState(false)
|
||||
const [devDeliveryDate, setDevDeliveryDate] = useState('')
|
||||
const [devDeliveryTime, setDevDeliveryTime] = useState('')
|
||||
const [devFreezeDate, setDevFreezeDate] = useState('')
|
||||
const [devFreezeTime, setDevFreezeTime] = useState('')
|
||||
const [devError, setDevError] = useState<string | null>(null)
|
||||
|
||||
const openDevDialog = () => {
|
||||
setDevDeliveryDate('')
|
||||
setDevDeliveryTime('')
|
||||
setDevFreezeDate('')
|
||||
setDevFreezeTime('')
|
||||
setDevError(null)
|
||||
setDevDialogOpen(true)
|
||||
}
|
||||
|
||||
const handleFormSubmit = (values: typeof initialValues) => {
|
||||
if (!values.deliveryTime || !values.freezeTime) {
|
||||
Alert.alert('Error', 'Please fill all fields');
|
||||
|
|
@ -231,6 +277,119 @@ export default function SlotForm({
|
|||
{isPending ? (isEditMode ? 'Updating...' : 'Creating...') : (isEditMode ? 'Update Slot' : 'Create Slot')}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
{__DEV__ && (
|
||||
<TouchableOpacity
|
||||
testID="test-set-current-datetime"
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="test-set-current-datetime"
|
||||
accessible={true}
|
||||
onPress={openDevDialog}
|
||||
// 1x1 transparent pixel instead of left:-1000: iOS drops
|
||||
// off-screen views from the accessibility tree, so Maestro could
|
||||
// never find the button by testID. No opacity:0 — a 1x1 fully
|
||||
// transparent pixel is invisible but stays in the tree.
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: 1,
|
||||
height: 1,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{__DEV__ && (
|
||||
<BottomDialog open={devDialogOpen} onClose={() => setDevDialogOpen(false)}>
|
||||
<View style={tw`p-6`}>
|
||||
<TouchableOpacity
|
||||
testID="dev-datetime-header"
|
||||
accessibilityRole="button"
|
||||
activeOpacity={1}
|
||||
onPress={() => Keyboard.dismiss()}
|
||||
>
|
||||
<Text style={tw`text-xl font-bold mb-1 text-center`}>Set Slot Datetimes</Text>
|
||||
<Text style={tw`text-gray-500 text-center mb-4 text-sm`}>
|
||||
Dates as YYYY-MM-DD, times as HH:MM (24h). Interpreted as IST.
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
<View style={tw`mb-4`}>
|
||||
<MyTextInput
|
||||
testID="dev-delivery-date"
|
||||
topLabel="Delivery Date (YYYY-MM-DD)"
|
||||
placeholder="YYYY-MM-DD"
|
||||
value={devDeliveryDate}
|
||||
onChangeText={setDevDeliveryDate}
|
||||
/>
|
||||
</View>
|
||||
<View style={tw`mb-4`}>
|
||||
<MyTextInput
|
||||
testID="dev-delivery-time"
|
||||
topLabel="Delivery Time (HH:MM)"
|
||||
placeholder="HH:MM"
|
||||
value={devDeliveryTime}
|
||||
onChangeText={setDevDeliveryTime}
|
||||
/>
|
||||
</View>
|
||||
<View style={tw`mb-4`}>
|
||||
<MyTextInput
|
||||
testID="dev-freeze-date"
|
||||
topLabel="Freeze Date (YYYY-MM-DD)"
|
||||
placeholder="YYYY-MM-DD"
|
||||
value={devFreezeDate}
|
||||
onChangeText={setDevFreezeDate}
|
||||
/>
|
||||
</View>
|
||||
<View style={tw`mb-4`}>
|
||||
<MyTextInput
|
||||
testID="dev-freeze-time"
|
||||
topLabel="Freeze Time (HH:MM)"
|
||||
placeholder="HH:MM"
|
||||
value={devFreezeTime}
|
||||
onChangeText={setDevFreezeTime}
|
||||
/>
|
||||
</View>
|
||||
|
||||
{devError && (
|
||||
<Text testID="dev-datetime-error" style={tw`text-red-500 mb-4 text-sm`}>
|
||||
{devError}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
<View style={tw`flex-row gap-3`}>
|
||||
<TouchableOpacity
|
||||
testID="dev-cancel-datetime"
|
||||
style={tw`flex-1 bg-gray-100 py-3.5 rounded-xl items-center`}
|
||||
onPress={() => setDevDialogOpen(false)}
|
||||
>
|
||||
<Text style={tw`text-gray-700 font-bold`}>Cancel</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
testID="dev-apply-datetime"
|
||||
style={tw`flex-1 bg-pink1 py-3.5 rounded-xl items-center`}
|
||||
onPress={() => {
|
||||
const delivery = parseIstDateTime(devDeliveryDate, devDeliveryTime)
|
||||
const freeze = parseIstDateTime(devFreezeDate, devFreezeTime)
|
||||
if (!delivery || !freeze) {
|
||||
setDevError('Use YYYY-MM-DD and HH:MM (24h, IST) for both.')
|
||||
return
|
||||
}
|
||||
if (freeze.getTime() > delivery.getTime()) {
|
||||
setDevError('Freeze time must be before or equal to delivery time.')
|
||||
return
|
||||
}
|
||||
setFieldValue('deliveryTime', delivery)
|
||||
setFieldValue('freezeTime', freeze)
|
||||
setDevDialogOpen(false)
|
||||
}}
|
||||
>
|
||||
<Text style={tw`text-white font-bold`}>Apply</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
</BottomDialog>
|
||||
)}
|
||||
</View>
|
||||
)}}
|
||||
</Formik>
|
||||
|
|
|
|||
|
|
@ -8501,3 +8501,97 @@ cover the three Home scenarios). user-ui typecheck clean.
|
|||
- HOME-119: returning to the top always reveals.
|
||||
Web-ui has no equivalent scroll-away address bar on the home route (its
|
||||
Topbar is already fixed), so no web counterpart change.
|
||||
- Timestamp: 2026-10-20 22:29:18
|
||||
0006 migration: add a default-address backfill phase.
|
||||
For every user with NO default address, take the 3 most recent
|
||||
non-cancelled orders (created_at desc, then id); the address used by the
|
||||
majority of those 3 becomes the default. Ties fall back to the most recent
|
||||
order's address, then the newest address id. Votes only count addresses
|
||||
that still exist. User-chosen defaults are never overridden.
|
||||
Files:
|
||||
* packages/db_helper_sqlite/drizzle/0006_regions_and_superadmins.sql
|
||||
+ new phase after the renames/indexes, before Phase 3 consts.
|
||||
* /private/var/folders/6t/3blzq7_j6p95xzry6t7c14hw0000gn/T/opencode/set-default-addresses.sql
|
||||
+ one-off delta for the already-migrated live DB (same block; the
|
||||
no-orders fallback and multi-default collapse are included but
|
||||
commented out).
|
||||
Verification: rebuild a DB from apps/backend/dumps/latest.sql and apply the
|
||||
modified 0006; run the delta on a copy of the current live DB. Not applied
|
||||
to the live DB.
|
||||
|
||||
================================================================================
|
||||
[2026-10-20 22:45:00 IST
|
||||
|
||||
================================================================================
|
||||
[2026-10-20 22:55:00 IST] DEV-2026-10-20-28 maestro flow for slot 2 hrs from now
|
||||
================================================================================
|
||||
New: tests/e2e/dev/add-slot-dev-datetime.yaml
|
||||
- Uses the hidden __DEV__ hook (test-set-current-datetime) with four text inputs.
|
||||
- Computes delivery = now + 2h and freeze = now + 1h in IST via Maestro evalScript,
|
||||
types them as YYYY-MM-DD / HH:MM, applies, then creates the slot.
|
||||
- Mirrors the existing add-empty-slot.yaml flow (login, Delivery Slots, create-slot).] DEV-2026-10-20-27 slot form hidden datetime test hook
|
||||
================================================================================
|
||||
apps/admin-ui/components/SlotForm.tsx (only file; add + edit slot screens share it)
|
||||
- __DEV__-only off-screen Pressable (testID test-set-current-datetime,
|
||||
absolute left -1000) opens a BottomDialog with four blank text inputs
|
||||
(delivery/freeze date YYYY-MM-DD + time HH:MM 24h).
|
||||
- Apply parses the wall-clock as IST (UTC+5:30), validates ranges/real dates
|
||||
and freeze <= delivery, then setFieldValue both Formik fields at once.
|
||||
- No admin-web change (DEV-only native test hook). No prefill.
|
||||
Run: admin-ui typecheck; Maestro verify via Expo Go on the booted simulator.
|
||||
- Diverged from the requested left:-1000 style: iOS drops off-screen views from
|
||||
the accessibility tree, so Maestro tapOn id:test-set-current-datetime could not
|
||||
find it. Now 1x1 fully-transparent at top-left: invisible, layout-neutral.
|
||||
- Final style verified on-device: 1x1 transparent TouchableOpacity at top-left
|
||||
(no opacity:0). No admin-web change. Disposable fixture devslothook + slot 2115
|
||||
removed after verification.
|
||||
Run: admin-ui typecheck clean. Maestro on booted sim 5A64695E (Expo Go :8082):
|
||||
- hidden test-set-current-datetime opens the dialog on add AND edit screens;
|
||||
blank fields both times (no prefill), Cancel closes without touching the form.
|
||||
- entered delivery 2026-10-25 08:00 + freeze 2026-10-25 07:00: pickers showed
|
||||
25/10/2026 8:00 AM / 7:00 AM; created Slot #2115; D1 stores
|
||||
2026-10-25T02:30:00.000Z / 2026-10-25T01:30:00.000Z (correct IST->UTC).
|
||||
- slot 2115 + staff devslothook deleted after verification.
|
||||
|
||||
[2026-10-20 23:14:13 IST] Update tests/e2e/dev/add-slot-dev-datetime.yaml: compute IST wall-clock
|
||||
(+5:30) for delivery=now+2h / freeze=now+1h; toISOString alone is UTC and would
|
||||
be interpreted as IST by the dialog (5.5h off).
|
||||
|
||||
[2026-10-20 23:16:25 IST] Slot DEV dialog: add id-addressable header that dismisses the keyboard
|
||||
(testID dev-datetime-header) so Maestro flows never need a percentage tap;
|
||||
update tests/e2e/dev/add-slot-dev-datetime.yaml to use it, and document the
|
||||
hidden hook + dialog in docs/maestro-mcp-agent-guidelines.md.
|
||||
- Verified with Maestro CLI (MCP server was unavailable): full ID-based Expo Go flow
|
||||
login -> delivery-slots-menu-item -> add-slot-fab -> test-set-current-datetime ->
|
||||
dev-* fields -> dev-datetime-header (dismiss keyboard between lower fields) ->
|
||||
apply -> create-slot-button. Slot 2116 created; D1 has delivery
|
||||
2026-10-20T19:48Z / freeze 2026-10-20T18:48Z = 01:18 / 00:18 IST (now+2h /
|
||||
now+1h at flow start). Cleaned up slot 2116 + staff devslothook. admin-ui tsc OK.
|
||||
|
||||
[2026-10-20 23:22:28 IST] Make tests/e2e/dev/add-slot-dev-datetime.yaml runnable in both Expo Go
|
||||
(EXPO_URL -> openLink) and a dev build (launchApp); drop hideKeyboard from the
|
||||
shared admin login subflow (guidelines say it fails on iOS; direct id tap works).
|
||||
|
||||
[2026-10-20 23:26:55 IST] Harden tests/e2e/subflows/login.yaml: dismiss the iOS Save Password sheet
|
||||
(optional Not Now) and extendedWaitUntil the dashboard instead of asserting immediately.
|
||||
- Final actual-YAML run (Maestro CLI, Expo Go :8082, sim 5A64695E): login via
|
||||
subflow -> delivery-slots-menu-item -> add-slot-fab -> test-set-current-datetime ->
|
||||
dev-* fields with dev-datetime-header keyboard dismissal -> apply ->
|
||||
create-slot-button -> success. Slot 2117 stored 2026-10-20T19:57Z /
|
||||
2026-10-20T18:57Z = 01:27 / 00:27 IST on 2026-10-21 (now+2h / now+1h).
|
||||
Deleted slot 2117 + staff devslothook; admin-ui tsc clean. MCP server dropped
|
||||
mid-run, so verification used the local Maestro CLI on the same simulator.
|
||||
|
||||
[2026-10-20 23:33:28 IST] tests/e2e/dev/add-slot-dev-datetime.yaml: make the login step race-proof -
|
||||
the app can show the dashboard for a moment and then drop to the login screen
|
||||
(an invalidated session), so the conditional login subflow is attempted twice
|
||||
around a wait for either screen, then the dashboard is required.
|
||||
- Re-ran tests/e2e/dev/add-slot-dev-datetime.yaml (same command as before): PASSED end to
|
||||
end. Slot #2118 created - UI shows DELIVERY 21 Oct 1:34 AM / FREEZE 21 Oct 12:34 AM;
|
||||
D1 delivery 2026-10-20T20:04Z / freeze 2026-10-20T19:04Z = 01:34 / 00:34 IST,
|
||||
i.e. now+2h / now+1h (flow ran at 23:34 IST on 2026-10-20).
|
||||
First attempt failed: the stored session had been invalidated (staff row was
|
||||
deleted after the previous run), so the app showed the dashboard for a moment
|
||||
and then dropped to the login screen, skipping the conditional login. Fixed by
|
||||
attempting the login subflow on both sides of a wait for either screen.
|
||||
Left in place for inspection: slot 2118 and staff devslothook (id 10).
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ fails with "Element not found". Tap the tab by **point** instead.
|
|||
`select-address-error`, `go-to-cart`, `add-to-cart-confirm`, `slot-<date>-<hh>-<mm>`.
|
||||
- Admin dashboard: `add-product-menu-item`, `delivery-slots-menu-item`, and the
|
||||
product/slot form ids used by `tests/e2e/*.yaml`.
|
||||
- Admin slot form (DEV-only): `test-set-current-datetime` plus the
|
||||
`dev-*` ids listed in §10.1.
|
||||
|
||||
### 3.4 `scrollUntilVisible` works
|
||||
Use it for long forms/screens (it needs an `id:` element):
|
||||
|
|
@ -435,6 +437,86 @@ row → "Add to Cart" → "Go to Cart".
|
|||
**Flash:** enable flash in the region (`superadmin.regions.updateRegionConstants`),
|
||||
then 1 Hr Delivery tab → product detail → "Get in 1 Hour" (separate flash cart).
|
||||
|
||||
### 10.1 Admin slot form: hidden datetime hook (DEV only)
|
||||
|
||||
The native iOS/Android date+time scrollers are unusable from Maestro. `SlotForm`
|
||||
(add **and** edit screens) therefore has a `__DEV__`-only hook that sets both
|
||||
datetimes from plain text inputs.
|
||||
|
||||
| ID | What it is |
|
||||
|---|---|
|
||||
| `test-set-current-datetime` | Invisible 1×1 button at the form's top-left corner. Opens the dialog. |
|
||||
| `dev-delivery-date` | Delivery date, `YYYY-MM-DD` |
|
||||
| `dev-delivery-time` | Delivery time, 24h `HH:MM` |
|
||||
| `dev-freeze-date` | Freeze date, `YYYY-MM-DD` |
|
||||
| `dev-freeze-time` | Freeze time, 24h `HH:MM` |
|
||||
| `dev-datetime-header` | Dialog title area; tapping it dismisses the keyboard |
|
||||
| `dev-datetime-error` | Inline validation message (bad format, or freeze > delivery) |
|
||||
| `dev-cancel-datetime` | Close without touching the form |
|
||||
| `dev-apply-datetime` | Apply both fields at once |
|
||||
|
||||
Important details:
|
||||
- **The button is 1×1 and transparent, not `left: -1000`.** iOS removes
|
||||
off-screen views from the accessibility tree, so Maestro cannot find an
|
||||
off-screen `testID`. Do not "fix" the style back to an off-screen position.
|
||||
- Both times are interpreted as **IST (UTC+5:30)** and sent as UTC. If you
|
||||
compute them in `evalScript`, remember `toISOString()` is UTC — add
|
||||
`5.5*60*60*1000` before slicing, or your slot lands 5.5 hours early.
|
||||
- The dialog opens **blank every time** (no prefill). Cancel leaves the form
|
||||
untouched.
|
||||
- After typing a field, tap `dev-datetime-header` before targeting the next
|
||||
field that may sit under the keyboard. On iOS the keyboard covers the lower
|
||||
fields and the Apply row, and a `tapOn` on a covered `testID` silently types
|
||||
into the still-focused field above. `hideKeyboard` is unreliable (§4.1); the
|
||||
header tap is ID-based.
|
||||
|
||||
Reusable flow: `tests/e2e/dev/add-slot-dev-datetime.yaml` (delivery = now + 2h,
|
||||
freeze = now + 1h). Run it against a dev build:
|
||||
|
||||
```bash
|
||||
STAFF_NAME=... STAFF_PASSWORD=... maestro test tests/e2e/dev/add-slot-dev-datetime.yaml
|
||||
```
|
||||
|
||||
Or against Expo Go (verified; pass env with `-e`, not shell env):
|
||||
|
||||
```bash
|
||||
maestro test \
|
||||
-e APP_ID=host.exp.Exponent \
|
||||
-e EXPO_URL=exp://127.0.0.1:8082 \
|
||||
-e STAFF_NAME=... -e STAFF_PASSWORD=... \
|
||||
tests/e2e/dev/add-slot-dev-datetime.yaml
|
||||
```
|
||||
|
||||
If Expo Go is already showing an old screen/dialog, terminate it first so the
|
||||
flow starts clean:
|
||||
|
||||
```bash
|
||||
xcrun simctl terminate <udid> host.exp.Exponent
|
||||
```
|
||||
|
||||
Key steps:
|
||||
```yaml
|
||||
- scrollUntilVisible: { element: { id: delivery-slots-menu-item }, direction: DOWN }
|
||||
- tapOn: { id: delivery-slots-menu-item }
|
||||
- tapOn: { id: add-slot-fab }
|
||||
- tapOn: { id: test-set-current-datetime }
|
||||
- tapOn: { id: dev-delivery-date }
|
||||
- inputText: '2026-10-25'
|
||||
- tapOn: { id: dev-datetime-header }
|
||||
- tapOn: { id: dev-delivery-time }
|
||||
- inputText: '08:00'
|
||||
- tapOn: { id: dev-datetime-header }
|
||||
- tapOn: { id: dev-freeze-date }
|
||||
- inputText: '2026-10-25'
|
||||
- tapOn: { id: dev-datetime-header }
|
||||
- tapOn: { id: dev-freeze-time }
|
||||
- inputText: '07:00'
|
||||
- tapOn: { id: dev-datetime-header } # dismiss the keyboard, no point taps
|
||||
- tapOn: { id: dev-apply-datetime }
|
||||
- scrollUntilVisible: { element: { id: create-slot-button }, direction: DOWN }
|
||||
- tapOn: { id: create-slot-button }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 11. Things that look like bugs but are NOT
|
||||
|
|
|
|||
|
|
@ -913,7 +913,60 @@ CREATE INDEX `idx_addresses_region` ON `addresses` (`region_id`);
|
|||
CREATE INDEX `idx_orders_region` ON `orders` (`region_id`);
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX `idx_complaints_region` ON `complaints` (`region_id`);
|
||||
|
||||
--> statement-breakpoint
|
||||
-- =====================================================================
|
||||
-- Default address backfill (from the user's recent orders).
|
||||
--
|
||||
-- Only users with NO default address are touched: a user-chosen default is
|
||||
-- never overridden. "Recent 3" = the 3 most recent non-cancelled orders
|
||||
-- (created_at desc, then id). The address used by the majority of those 3
|
||||
-- becomes the default; ties fall back to the most recent order's address,
|
||||
-- then the newest address id. Votes only count addresses that still exist
|
||||
-- (the orphan-order repair above already removed the dead ones).
|
||||
-- =====================================================================
|
||||
WITH `ranked_orders` AS (
|
||||
SELECT
|
||||
`o`.`id`,
|
||||
`o`.`user_id`,
|
||||
`o`.`address_id`,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY `o`.`user_id`
|
||||
ORDER BY datetime(`o`.`created_at`) DESC, `o`.`id` DESC
|
||||
) AS `rn`
|
||||
FROM `orders` `o`
|
||||
JOIN `order_status` `os` ON `os`.`order_id` = `o`.`id`
|
||||
WHERE `os`.`is_cancelled` = 0
|
||||
),
|
||||
`recent3` AS (
|
||||
SELECT `user_id`, `address_id`, `rn` FROM `ranked_orders` WHERE `rn` <= 3
|
||||
),
|
||||
`votes` AS (
|
||||
SELECT
|
||||
`r`.`user_id`,
|
||||
`r`.`address_id`,
|
||||
COUNT(*) AS `vote_count`,
|
||||
MIN(`r`.`rn`) AS `best_rank`
|
||||
FROM `recent3` `r`
|
||||
JOIN `addresses` `a` ON `a`.`id` = `r`.`address_id`
|
||||
GROUP BY `r`.`user_id`, `r`.`address_id`
|
||||
),
|
||||
`winner` AS (
|
||||
SELECT
|
||||
`user_id`,
|
||||
`address_id`,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY `user_id`
|
||||
ORDER BY `vote_count` DESC, `best_rank` ASC, `address_id` DESC
|
||||
) AS `pick`
|
||||
FROM `votes`
|
||||
),
|
||||
`no_default_users` AS (
|
||||
SELECT `user_id` FROM `addresses` GROUP BY `user_id` HAVING SUM(`is_default`) = 0
|
||||
)
|
||||
UPDATE `addresses`
|
||||
SET `is_default` = 1
|
||||
WHERE `id` IN (SELECT `address_id` FROM `winner` WHERE `pick` = 1)
|
||||
AND `user_id` IN (SELECT `user_id` FROM `no_default_users`);
|
||||
--> statement-breakpoint
|
||||
-- =====================================================================
|
||||
-- Phase 3 (from 0008 + 0009): the three const tables, seeded directly.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue