From 028feeadfab4e09bb3062dd4f18c7ac9bbdad365 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 11 Oct 2025 13:54:53 +0200 Subject: [PATCH] feat: Shared refined pact with provider --- pacts | 2 +- .../chatroom/chatroom.service.pact.spec.ts | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/pacts b/pacts index b2bf161f..6ec14b0e 160000 --- a/pacts +++ b/pacts @@ -1 +1 @@ -Subproject commit b2bf161fa71acd4128b040ebb81af65fc1509cac +Subproject commit 6ec14b0e50ab269edd0d0f9a98a4a3b167bffed3 diff --git a/src/app/chatroom/chatroom.service.pact.spec.ts b/src/app/chatroom/chatroom.service.pact.spec.ts index 3eab0f08..34f64e1a 100644 --- a/src/app/chatroom/chatroom.service.pact.spec.ts +++ b/src/app/chatroom/chatroom.service.pact.spec.ts @@ -1,6 +1,6 @@ import { Matchers, Pact, SpecificationVersion } from '@pact-foundation/pact'; import { TestBed } from '@angular/core/testing'; -import { HttpErrorResponse, provideHttpClient } from '@angular/common/http'; +import { provideHttpClient } from '@angular/common/http'; import { lastValueFrom } from 'rxjs'; import { ChatroomService } from './chatroom.service'; import { Chatroom } from './chatroom.model'; @@ -33,7 +33,11 @@ describe('Pact between the ChatroomService and the backend', () => { .given('the server is responsible for shard 2') .given('chatroom 5c73531c-6fc4-426c-adcb-afc5c140a0f7 exists in shard 2') .uponReceiving('a request for /list') - .withRequest('GET', '/list') + .withRequest('GET', '/list', (builder) => { + builder.headers({ + Accept: Matchers.like('application/json'), + }); + }) .willRespondWith(200, (builder) => { builder.headers({ 'Content-Type': 'application/json' }); builder.jsonBody(Matchers.eachLike(EXAMPLE_CHATROOM)); @@ -62,7 +66,11 @@ describe('Pact between the ChatroomService and the backend', () => { .given('the server is responsible for shard 2') .given('there are no chatrooms available at all in shard 2') .uponReceiving('a request for /list') - .withRequest('GET', '/list') + .withRequest('GET', '/list', (builder) => { + builder.headers({ + Accept: Matchers.like('application/json'), + }); + }) .willRespondWith(200, (builder) => { builder.headers({ 'Content-Type': 'application/json' }); builder.jsonBody([]); @@ -92,7 +100,10 @@ describe('Pact between the ChatroomService and the backend', () => { .given('chatroom 5c73531c-6fc4-426c-adcb-afc5c140a0f7 exists in shard 2') .uponReceiving('a request for /5c73531c-6fc4-426c-adcb-afc5c140a0f7') .withRequest('GET', '/5c73531c-6fc4-426c-adcb-afc5c140a0f7', (builder) => { - builder.headers({ 'X-Shard': 2 }) + builder.headers({ + Accept: Matchers.like('application/json'), + 'X-Shard': 2, + }); }) .willRespondWith(200, (builder) => { builder.headers({ 'Content-Type': 'application/json' }); @@ -123,7 +134,10 @@ describe('Pact between the ChatroomService and the backend', () => { .given('chatroom 7f59ec77-832e-4a17-8d22-55ef46242c17 does not exists in shard 2') .uponReceiving('a request for /7f59ec77-832e-4a17-8d22-55ef46242c17') .withRequest('GET', '/7f59ec77-832e-4a17-8d22-55ef46242c17', (builder) => { - builder.headers({ 'X-Shard': 2 }) + builder.headers({ + Accept: Matchers.like('application/json'), + 'X-Shard': 2, + }); }) .willRespondWith(404) .executeTest(async (mockserver) => { -- 2.39.5