Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ga 43 pact #1263

Open
wants to merge 5 commits into
base: development/GA/OGD-73-Invite-User-Flow
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions api/test/pact/pact-tests/pactFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,25 @@ export interface Organisation {
superUser: SuperUser;
}

export interface OrganisationInternal {
companyNumber: string;
companyUrl: string;
name: string;
organisationIdentifier: string;
sraId: string;
sraRegulated: boolean;
status: string;
contactInformation: ContactInformation[];
superUser: SuperUser;
lastUpdated: string,
organisationProfileIds: string[]
}

export interface OrganisationInternalResponse {
moreAvailable: boolean;
organisations: OrganisationInternal[]
}

export interface SuspendUserReponseDto {
roleAdditionResponse?: RoleResponse;
roleDeletionResponse?: RoleDeletionResponse[];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { expect } from 'chai';
import { OrganisationInternalResponse } from '../pactFixtures';
import { getOrganisationDetails } from '../pactUtil';
import { PactTestSetup } from '../settings/provider.mock';

const { Matchers } = require('@pact-foundation/pact');
const { somethingLike } = Matchers;
const pactSetUp = new PactTestSetup({ provider: 'referenceData_organisationalInternal', port: 9292 });

describe('Get Internal Organisation Details from RDProfessionalAPI ', () => {
describe('Get Internal Organisation Details', async () => {
before(async () => {
await pactSetUp.provider.setup();
const interaction = {
state: 'Active organisations exists for a logged in user using lastUpdatedSince',
uponReceiving: 'A request for organisation since last updated',
withRequest: {
method: 'GET',
path: '/refdata/internal/v1/organisations',
query: 'since=2019-08-16T15:00:40',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer some-access-token',
'ServiceAuthorization': 'serviceAuthToken'
}
},
willRespondWith: {
status: 200,
headers: {
'Content-type': 'application/json'
},
body:
organisationInternalResponse

}
};
// @ts-ignore
pactSetUp.provider.addInteraction(interaction);
});

it('returns the correct response', async () => {
const taskUrl: string = `${pactSetUp.provider.mockService.baseUrl}/refdata/internal/v1/organisations?since=2019-08-16T15:00:40`;

const resp = getOrganisationDetails(taskUrl);

resp.then((response) => {
const responseDto: OrganisationInternalResponse = <OrganisationInternalResponse> response.data;
assertResponse(responseDto);
}).then(() => {
pactSetUp.provider.verify();
pactSetUp.provider.finalize();
}).finally(() => {
pactSetUp.provider.verify();
pactSetUp.provider.finalize();
});
});

function assertResponse(dto: OrganisationInternalResponse): void {
// eslint-disable-next-line no-unused-expressions
expect(dto).to.be.not.null;
expect(dto.moreAvailable).to.equal('false');
expect(dto.organisations[0].lastUpdated).to.be.not.equal(null);
expect(dto.organisations[0].organisationProfileIds).to.equal('SOLICITOR_PROFILE');
}

const organisationInternalResponse =
{
organisations: [
{
name: somethingLike('Org-Name'),
organisationIdentifier: somethingLike('M0AEAP0'),
status: somethingLike('ACTIVE'),
sraId: somethingLike('sra-id'),
sraRegulated: somethingLike(false),
companyNumber: somethingLike('companyN'),
companyUrl: somethingLike('www.org.com'),
contactInformation: [],
superUser: {
firstName: somethingLike('some-fname'),
lastName: somethingLike('some-lname'),
email: somethingLike('some-email-address')
},
lastUpdated: somethingLike('2023-11-20T15:51:33'),
dateApproved: somethingLike('2023-11-19T15:51:33'),
organisationProfileIds: [somethingLike('SOLICITOR_PROFILE')]
}
],
moreAvailable: somethingLike(false)
};
});
});
2 changes: 1 addition & 1 deletion yarn-audit-known-issues

Large diffs are not rendered by default.