test(app): Playwright animal and relation journeys on the sandbox
Ten journeys, FR and EN, desktop and 375 px, axe on every state. Seeds go through quoted SQL literals; db:sandbox e2e-shell passes its arguments to Playwright.
This commit is contained in:
1 parent
930499cd25
commit
3e968eeeab
3 files changed
+1084
-2
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* Setup rows of the shell suites, written as postgres in an account's
|
||||||
|
* workspace of the isolated stack: the subject of a test goes through the
|
||||||
|
* page, its surroundings through here. Values are fictitious literals; each
|
||||||
|
* one is quoted as an SQL literal, never pasted raw.
|
||||||
|
*/
|
||||||
|
import { sql } from '../../../../packages/supabase/tests/sandbox/stack'
|
||||||
|
import { workspaceOf, type SandboxAccount } from './sandbox'
|
||||||
|
|
||||||
|
/** A text as an SQL literal ('' doubles a quote), or null. */
|
||||||
|
export const literal = (value: string | null) =>
|
||||||
|
value === null ? 'null' : `'${value.replaceAll("'", "''")}'`
|
||||||
|
|
||||||
|
export interface ClientSeed {
|
||||||
|
kind?: 'person' | 'organization'
|
||||||
|
city?: string | null
|
||||||
|
phone?: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function seedClient(
|
||||||
|
account: SandboxAccount,
|
||||||
|
displayName: string,
|
||||||
|
seed: ClientSeed = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const ws = await workspaceOf(account)
|
||||||
|
return sql(`insert into public.clients (workspace_id, kind, display_name, city, phone, create_request_id, create_request_digest)
|
||||||
|
values (${literal(ws)}, ${literal(seed.kind ?? 'person')}, ${literal(displayName)}, ${literal(seed.city ?? null)},
|
||||||
|
${literal(seed.phone ?? null)}, gen_random_uuid(), '\\x00') returning id`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function seedAnimal(
|
||||||
|
account: SandboxAccount,
|
||||||
|
name: string,
|
||||||
|
speciesId = 'equine',
|
||||||
|
sex: 'male' | 'female' | 'unknown' = 'female',
|
||||||
|
): Promise<string> {
|
||||||
|
const ws = await workspaceOf(account)
|
||||||
|
return sql(`insert into public.animals (workspace_id, name, species_id, sex, create_request_id, create_request_digest)
|
||||||
|
values (${literal(ws)}, ${literal(name)}, ${literal(speciesId)}, ${literal(sex)}, gen_random_uuid(), '\\x00') returning id`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function seedRelation(
|
||||||
|
account: SandboxAccount,
|
||||||
|
animalId: string,
|
||||||
|
clientId: string,
|
||||||
|
role: 'owner' | 'keeper' | 'contact',
|
||||||
|
startedOn: string | null = null,
|
||||||
|
): Promise<string> {
|
||||||
|
const ws = await workspaceOf(account)
|
||||||
|
return sql(`insert into public.animal_client_relations
|
||||||
|
(workspace_id, animal_id, client_id, relation_role, started_on, create_request_id, create_request_digest)
|
||||||
|
values (${literal(ws)}, ${literal(animalId)}, ${literal(clientId)}, ${literal(role)}, ${literal(startedOn)},
|
||||||
|
gen_random_uuid(), '\\x00') returning id`)
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
# pnpm db:sandbox test-db the pgTAP files (`supabase test db`)
|
# pnpm db:sandbox test-db the pgTAP files (`supabase test db`)
|
||||||
# pnpm db:sandbox types [--check] generated types (write, or diff with the committed file)
|
# pnpm db:sandbox types [--check] generated types (write, or diff with the committed file)
|
||||||
# pnpm db:sandbox test packages/supabase/tests/sandbox (HTTP, concurrency)
|
# pnpm db:sandbox test packages/supabase/tests/sandbox (HTTP, concurrency)
|
||||||
# pnpm db:sandbox e2e-shell = pnpm e2e:shell: the /app shell in Chromium (apps/app/e2e)
|
# pnpm db:sandbox e2e-shell [args] = pnpm e2e:shell: the /app shell in Chromium (apps/app/e2e); args go to Playwright (a spec file, --grep)
|
||||||
# pnpm db:sandbox sql psql as postgres on stdin
|
# pnpm db:sandbox sql psql as postgres on stdin
|
||||||
# pnpm db:sandbox down
|
# pnpm db:sandbox down
|
||||||
#
|
#
|
||||||
@@ -247,7 +247,7 @@ case "${1:-}" in
|
|||||||
printf '%s\n' "$out" > packages/supabase/src/database.types.ts; echo "== types written"
|
printf '%s\n' "$out" > packages/supabase/src/database.types.ts; echo "== types written"
|
||||||
fi ;;
|
fi ;;
|
||||||
test) load_secrets; with_sandbox_env node_modules/.bin/pnpm --filter @faunosteo/supabase test:sandbox ;;
|
test) load_secrets; with_sandbox_env node_modules/.bin/pnpm --filter @faunosteo/supabase test:sandbox ;;
|
||||||
e2e-shell) load_secrets; with_sandbox_env node_modules/.bin/pnpm --filter @faunosteo/app e2e:shell ;;
|
e2e-shell) shift; load_secrets; with_sandbox_env node_modules/.bin/pnpm --filter @faunosteo/app e2e:shell "$@" ;;
|
||||||
sql) load_secrets; sb_psql ;;
|
sql) load_secrets; sb_psql ;;
|
||||||
*) sed -n '2,23p' "$0"; exit 1 ;;
|
*) sed -n '2,23p' "$0"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
Reference in new issue
Block a user