Files
crosscode-platform/scripts/tests/events.bats
T
joshuaandClaude Opus 5.5 716d47242a Events 2.4.0 frontend, deploy and docs: Linked products, linked events, seo
- Site settings → Linked products (Connect, Show events from, Publish my
  events), help, command palette.
- Events from linked products on /events, the home and campus pages, and
  /events/linked/<product>/<id> (markdown with HTML off, canonical to the
  origin, no JSON-LD, not in the sitemap).
- Event page JSON-LD from @crosscode/seo; lib/eventSchema.ts removed.
- Readiness check for linked products' sync; e2e spec with a fake
  Church Website (not run yet: needs the e2e Postgres).
- crosscode: install and build the shared packages Events uses first
  (an older tag still builds as before); scripts/tests/events.bats.
- Release notes, changelogs, handovers, hub-protocol.md, and the plan's
  "Changes while building".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 12:58:50 +02:00

56 lines
2.4 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"
echo '{"name":"@crosscode/contracts"}' > "$dir/packages/contracts/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 "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" ]
}