#!/usr/bin/env bash
set -euo pipefail

ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
TMP_ROOT="$(mktemp -d)"
trap 'rm -rf "$TMP_ROOT"' EXIT

TARGET="$TMP_ROOT/Aeroflot.Flights.Front"
mkdir -p "$TARGET"

"$ROOT/scripts/ci/sync-to-gitlab.sh" "$TARGET" >/tmp/sync-to-gitlab-test.log

test -f "$TARGET/tests/e2e/schedule-calendar-operating-days.spec.ts"
grep -q "Schedule return calendar uses swapped route operating days" \
  "$TARGET/tests/e2e/schedule-calendar-operating-days.spec.ts"

test -f "$TARGET/scripts/ci/bundle-size-gate.mjs"
test -f "$TARGET/scripts/ci/check-coverage-delta.mjs"
test -f "$TARGET/tests/ci/test-sync-to-gitlab.sh"

grep -q '"bundle-size": "node scripts/ci/bundle-size-gate.mjs"' "$TARGET/package.json"
grep -q '"check-coverage": "node scripts/ci/check-coverage-delta.mjs"' "$TARGET/package.json"

test ! -d "$TARGET/tests/e2e-angular"
test ! -d "$TARGET/tests/parity"
