- scripts/products/events.sh: packages/auth-client is installed and built (after contracts) when Events uses it, as 3.0.0 does; without it a 3.0 deploy would fail at the first sign-in through Accounts. bats test. - test:accounts runs on real Postgres for both apps with EVENTS_TEST_DATABASE_URL and ACCOUNTS_TEST_DATABASE_URL (14/14); the Accounts test harness takes a real Prisma client. - e2e/excel.spec.ts resolves excelts from the backend (hoisted in the monorepo), so the e2e suite loads again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
3.0 KiB
Bash
68 lines
3.0 KiB
Bash
#!/usr/bin/env bats
|
|
# Cross Events' hooks that don't need a server: which shared packages a checkout builds first
|
|
# (contracts and seo from 2.4.0), and that an older checkout (2.3.x) builds without them.
|
|
# Run with `npm run test:scripts`.
|
|
|
|
setup() {
|
|
# shellcheck source=../products/events.sh
|
|
source "$BATS_TEST_DIRNAME/../products/events.sh"
|
|
TMP="$BATS_TEST_TMPDIR"
|
|
CALLS="$TMP/calls"
|
|
: > "$CALLS"
|
|
# Record what would run, as the app user, instead of running it.
|
|
run_as() { local user="$1" dir="$2"; shift 2; echo "$user|${dir#"$TMP"/}|$*" >> "$CALLS"; }
|
|
}
|
|
|
|
checkout() {
|
|
local dir="$TMP/$1"; shift
|
|
mkdir -p "$dir/apps/events/backend" "$dir/apps/events/frontend" "$dir/packages/contracts" "$dir/packages/seo" "$dir/packages/auth-client"
|
|
echo '{"name":"@crosscode/contracts"}' > "$dir/packages/contracts/package.json"
|
|
echo '{"name":"@crosscode/auth-client"}' > "$dir/packages/auth-client/package.json"
|
|
echo '{"name":"@crosscode/seo"}' > "$dir/packages/seo/package.json"
|
|
printf '{"dependencies":{%s}}' "$1" > "$dir/apps/events/backend/package.json"
|
|
printf '{"dependencies":{%s}}' "$2" > "$dir/apps/events/frontend/package.json"
|
|
}
|
|
|
|
@test "2.4.0: contracts and seo are installed and built before Events" {
|
|
checkout new '"@crosscode/contracts":"*"' '"@crosscode/contracts":"*","@crosscode/seo":"*"'
|
|
run events_shared_packages "$TMP/new"
|
|
[ "$output" = $'packages/contracts\npackages/seo' ]
|
|
|
|
events_install_deps "$TMP/new" hope
|
|
grep -qx 'hope|new|npm ci --include=dev --no-audit --no-fund -w packages/contracts -w packages/seo --include-workspace-root -w apps/events/backend -w apps/events/frontend' "$CALLS"
|
|
|
|
: > "$CALLS"
|
|
events_build "$TMP/new" hope
|
|
[ "$(cut -d'|' -f2 "$CALLS" | tr '\n' ' ')" = "new/packages/contracts new/packages/seo new/apps/events/backend new/apps/events/frontend " ]
|
|
}
|
|
|
|
@test "3.0.0: auth-client is installed and built after contracts, before Events" {
|
|
checkout new '"@crosscode/auth-client":"*","@crosscode/contracts":"*"' '"@crosscode/contracts":"*","@crosscode/seo":"*"'
|
|
run events_shared_packages "$TMP/new"
|
|
[ "$output" = $'packages/contracts
|
|
packages/auth-client
|
|
packages/seo' ]
|
|
events_build "$TMP/new" hope
|
|
[ "$(cut -d'|' -f2 "$CALLS" | tr '
|
|
' ' ')" = "new/packages/contracts new/packages/auth-client new/packages/seo new/apps/events/backend new/apps/events/frontend " ]
|
|
}
|
|
|
|
@test "2.3.x (no shared packages used): installed and built as before" {
|
|
checkout old '' ''
|
|
run events_shared_packages "$TMP/old"
|
|
[ -z "$output" ]
|
|
events_install_deps "$TMP/old" hope
|
|
grep -qx 'hope|old|npm ci --include=dev --no-audit --no-fund -w apps/events/backend -w apps/events/frontend' "$CALLS"
|
|
: > "$CALLS"
|
|
events_build "$TMP/old" hope
|
|
[ "$(cut -d'|' -f2 "$CALLS" | tr '\n' ' ')" = "old/apps/events/backend old/apps/events/frontend " ]
|
|
}
|
|
|
|
@test "a failing package build stops before Events is built" {
|
|
checkout new '"@crosscode/contracts":"*"' ''
|
|
run_as() { echo "${2#"$TMP"/}" >> "$CALLS"; [[ "$2" != */packages/contracts ]]; }
|
|
run events_build "$TMP/new" hope
|
|
[ "$status" -ne 0 ]
|
|
[ "$(cat "$CALLS")" = "new/packages/contracts" ]
|
|
}
|