Skip to content

Commit 8e28595

Browse files
Merge branch 'master' into feature/VIBE-192-verified-user-email-subscriptions
2 parents 6de235e + bab12a1 commit 8e28595

File tree

169 files changed

+10231
-1566
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+10231
-1566
lines changed

.github/workflows/e2e.yml

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,42 @@ jobs:
2121
name: E2E Tests
2222
runs-on: ubuntu-latest
2323

24+
services:
25+
postgres:
26+
image: postgres:18-alpine
27+
env:
28+
POSTGRES_USER: hmcts
29+
POSTGRES_HOST_AUTH_METHOD: trust
30+
POSTGRES_DB: postgres
31+
ports:
32+
- 5432:5432
33+
options: >-
34+
--health-cmd "pg_isready -U hmcts -d postgres"
35+
--health-interval 5s
36+
--health-timeout 5s
37+
--health-retries 5
38+
--health-start-period 10s
39+
40+
redis:
41+
image: redis:8-alpine
42+
ports:
43+
- 6379:6379
44+
options: >-
45+
--health-cmd "redis-cli ping"
46+
--health-interval 5s
47+
--health-timeout 5s
48+
--health-retries 5
49+
--health-start-period 10s
50+
2451
env:
2552
# Application configuration
2653
BASE_URL: https://localhost:8080
2754
PORT: 8080
2855
SESSION_SECRET: ${{ secrets.SESSION_SECRET }}
29-
DATABASE_URL: postgresql://hmcts@localhost:5433/postgres
56+
57+
# Database Configuration (using service containers)
58+
DATABASE_URL: postgresql://hmcts@localhost:5432/postgres
59+
REDIS_URL: redis://localhost:6379
3060

3161
# SSO Configuration (using existing GitHub Secrets)
3262
SSO_CLIENT_ID: ${{ secrets.SSO_CLIENT_ID }}
@@ -84,14 +114,19 @@ jobs:
84114
- name: Install dependencies
85115
run: yarn install --immutable
86116

87-
- name: Generate Prisma client
88-
run: yarn db:generate
117+
- name: Install PostgreSQL client
118+
run: sudo apt-get update && sudo apt-get install -y postgresql-client
89119

90-
- name: Start PostgreSQL
91-
run: docker compose up -d
120+
- name: Wait for PostgreSQL service to be ready
121+
run: timeout 30 bash -c 'until pg_isready -h localhost -p 5432 -U hmcts; do sleep 1; done'
92122

93-
- name: Wait for PostgreSQL to be ready
94-
run: timeout 30 bash -c 'until docker compose exec -T postgres pg_isready -U hmcts; do sleep 1; done'
123+
- name: Collate Prisma schema
124+
run: |
125+
echo "Collating Prisma schema from all modules..."
126+
cd apps/postgres && npx tsx src/collate-schema.ts && cd ../..
127+
128+
- name: Generate Prisma client
129+
run: yarn db:generate
95130

96131
- name: Run database migrations
97132
run: yarn db:migrate
@@ -105,7 +140,7 @@ jobs:
105140
- name: Verify seed data exists
106141
run: |
107142
echo "Verifying seed data for locationId=9..."
108-
ARTEFACT_COUNT=$(docker compose exec -T postgres psql -U hmcts -d postgres -t -c "SELECT COUNT(*) FROM artefact WHERE location_id = '9';")
143+
ARTEFACT_COUNT=$(psql $DATABASE_URL -t -c "SELECT COUNT(*) FROM artefact WHERE location_id = '9';")
109144
ARTEFACT_COUNT=$(echo $ARTEFACT_COUNT | xargs)
110145
echo "Found $ARTEFACT_COUNT artefacts for locationId=9"
111146
if [ "$ARTEFACT_COUNT" -lt 3 ]; then

.github/workflows/test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ jobs:
9191
- name: Install dependencies
9292
run: yarn install --immutable
9393

94-
- name: Generate Prisma client
95-
run: yarn db:generate
96-
9794
- name: Setup Turbo cache
9895
uses: actions/cache@v4
9996
with:

apps/api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
},
1616
"dependencies": {
1717
"@hmcts/cloud-native-platform": "workspace:*",
18+
"@hmcts/location": "workspace:*",
1819
"@hmcts/postgres": "workspace:*",
1920
"@hmcts/simple-router": "workspace:*",
2021
"compression": "1.8.1",

apps/api/src/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from "node:path";
22
import { fileURLToPath } from "node:url";
33
import { healthcheck } from "@hmcts/cloud-native-platform";
4+
import { apiRoutes as locationRoutes } from "@hmcts/location/config";
45
import { createSimpleRouter } from "@hmcts/simple-router";
56
import compression from "compression";
67
import cors from "cors";
@@ -26,7 +27,7 @@ export async function createApp(): Promise<Express> {
2627
app.use(express.json());
2728
app.use(express.urlencoded({ extended: true }));
2829

29-
const routeMounts = [{ path: `${__dirname}/routes` }];
30+
const routeMounts = [{ path: `${__dirname}/routes` }, locationRoutes];
3031

3132
app.use(await createSimpleRouter(...routeMounts));
3233

apps/postgres/prisma.config.test.ts

Lines changed: 0 additions & 84 deletions
This file was deleted.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
-- CreateTable
2+
CREATE TABLE "region" (
3+
"region_id" INTEGER NOT NULL,
4+
"name" TEXT NOT NULL,
5+
"welsh_name" TEXT NOT NULL,
6+
7+
CONSTRAINT "region_pkey" PRIMARY KEY ("region_id")
8+
);
9+
10+
-- CreateTable
11+
CREATE TABLE "jurisdiction" (
12+
"jurisdiction_id" INTEGER NOT NULL,
13+
"name" TEXT NOT NULL,
14+
"welsh_name" TEXT NOT NULL,
15+
16+
CONSTRAINT "jurisdiction_pkey" PRIMARY KEY ("jurisdiction_id")
17+
);
18+
19+
-- CreateTable
20+
CREATE TABLE "sub_jurisdiction" (
21+
"sub_jurisdiction_id" INTEGER NOT NULL,
22+
"name" TEXT NOT NULL,
23+
"welsh_name" TEXT NOT NULL,
24+
"jurisdiction_id" INTEGER NOT NULL,
25+
26+
CONSTRAINT "sub_jurisdiction_pkey" PRIMARY KEY ("sub_jurisdiction_id")
27+
);
28+
29+
-- CreateTable
30+
CREATE TABLE "location" (
31+
"location_id" INTEGER NOT NULL,
32+
"name" TEXT NOT NULL,
33+
"welsh_name" TEXT NOT NULL,
34+
"email" TEXT,
35+
"contact_no" TEXT,
36+
37+
CONSTRAINT "location_pkey" PRIMARY KEY ("location_id")
38+
);
39+
40+
-- CreateTable
41+
CREATE TABLE "location_region" (
42+
"location_id" INTEGER NOT NULL,
43+
"region_id" INTEGER NOT NULL,
44+
45+
CONSTRAINT "location_region_pkey" PRIMARY KEY ("location_id","region_id")
46+
);
47+
48+
-- CreateTable
49+
CREATE TABLE "location_sub_jurisdiction" (
50+
"location_id" INTEGER NOT NULL,
51+
"sub_jurisdiction_id" INTEGER NOT NULL,
52+
53+
CONSTRAINT "location_sub_jurisdiction_pkey" PRIMARY KEY ("location_id","sub_jurisdiction_id")
54+
);
55+
56+
-- CreateIndex
57+
CREATE UNIQUE INDEX "region_name_key" ON "region"("name");
58+
59+
-- CreateIndex
60+
CREATE UNIQUE INDEX "region_welsh_name_key" ON "region"("welsh_name");
61+
62+
-- CreateIndex
63+
CREATE UNIQUE INDEX "jurisdiction_name_key" ON "jurisdiction"("name");
64+
65+
-- CreateIndex
66+
CREATE UNIQUE INDEX "jurisdiction_welsh_name_key" ON "jurisdiction"("welsh_name");
67+
68+
-- CreateIndex
69+
CREATE UNIQUE INDEX "sub_jurisdiction_name_key" ON "sub_jurisdiction"("name");
70+
71+
-- CreateIndex
72+
CREATE UNIQUE INDEX "sub_jurisdiction_welsh_name_key" ON "sub_jurisdiction"("welsh_name");
73+
74+
-- CreateIndex
75+
CREATE UNIQUE INDEX "location_name_key" ON "location"("name");
76+
77+
-- CreateIndex
78+
CREATE UNIQUE INDEX "location_welsh_name_key" ON "location"("welsh_name");
79+
80+
-- AddForeignKey
81+
ALTER TABLE "sub_jurisdiction" ADD CONSTRAINT "sub_jurisdiction_jurisdiction_id_fkey" FOREIGN KEY ("jurisdiction_id") REFERENCES "jurisdiction"("jurisdiction_id") ON DELETE RESTRICT ON UPDATE CASCADE;
82+
83+
-- AddForeignKey
84+
ALTER TABLE "location_region" ADD CONSTRAINT "location_region_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "location"("location_id") ON DELETE CASCADE ON UPDATE CASCADE;
85+
86+
-- AddForeignKey
87+
ALTER TABLE "location_region" ADD CONSTRAINT "location_region_region_id_fkey" FOREIGN KEY ("region_id") REFERENCES "region"("region_id") ON DELETE RESTRICT ON UPDATE CASCADE;
88+
89+
-- AddForeignKey
90+
ALTER TABLE "location_sub_jurisdiction" ADD CONSTRAINT "location_sub_jurisdiction_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "location"("location_id") ON DELETE CASCADE ON UPDATE CASCADE;
91+
92+
-- AddForeignKey
93+
ALTER TABLE "location_sub_jurisdiction" ADD CONSTRAINT "location_sub_jurisdiction_sub_jurisdiction_id_fkey" FOREIGN KEY ("sub_jurisdiction_id") REFERENCES "sub_jurisdiction"("sub_jurisdiction_id") ON DELETE RESTRICT ON UPDATE CASCADE;

apps/postgres/src/index.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ vi.mock("@prisma/client", () => {
1212
};
1313
});
1414

15-
describe("Prisma Client Module", () => {
15+
/**
16+
* These tests verify Prisma client exports and require @prisma/client to be generated.
17+
* They are integration tests, not unit tests, so they are skipped in the standard test run.
18+
* Run them manually with: yarn generate && yarn test
19+
*/
20+
describe.skip("Prisma Client Module", () => {
1621
beforeEach(() => {
1722
vi.clearAllMocks();
1823
delete (globalThis as any).prisma;

apps/postgres/src/schema-discovery.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ describe("Schema Discovery", () => {
1212
expect(Array.isArray(result)).toBe(true);
1313
});
1414

15-
it("should return array with email-subscriptions schema", () => {
15+
it("should return array with email-subscriptions and location schemas", () => {
1616
const result = getPrismaSchemas();
17-
expect(result.length).toBe(1);
17+
expect(result.length).toBe(2);
1818
expect(result[0]).toContain("email-subscriptions");
19+
expect(result[1]).toContain("location");
1920
});
2021

2122
it("should return a new array on each call", () => {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Schema discovery functionality for module integration
22
import { prismaSchemas as emailSubscriptionsSchemas } from "@hmcts/email-subscriptions/config";
3+
import { prismaSchemas as locationSchemas } from "@hmcts/location/config";
34

45
export function getPrismaSchemas(): string[] {
5-
return [emailSubscriptionsSchemas];
6+
return [emailSubscriptionsSchemas, locationSchemas];
67
}

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@hmcts/admin-pages": "workspace:*",
2424
"@hmcts/cloud-native-platform": "workspace:*",
2525
"@hmcts/cookie-manager": "1.1.0",
26+
"@hmcts/location": "workspace:*",
2627
"@hmcts/postgres": "workspace:*",
2728
"@hmcts/public-pages": "workspace:*",
2829
"@hmcts/simple-router": "workspace:*",

0 commit comments

Comments
 (0)