From 7e88cf0482cd8dfb01d116d29737356159018945 Mon Sep 17 00:00:00 2001 From: Simon Priet Date: Wed, 8 Sep 2021 11:13:58 +0200 Subject: [PATCH] feat(Cypress): Implemented test step GET CommunicationRequest --- cypress/integration/api.spec.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/cypress/integration/api.spec.js b/cypress/integration/api.spec.js index b8174ea7..b5df212f 100644 --- a/cypress/integration/api.spec.js +++ b/cypress/integration/api.spec.js @@ -3,7 +3,7 @@ describe("it test the api", () => { let jsonWebToken = ""; const apiUrl = "https://fhir-api.public.post-prod.lifen.fr"; - let documentReferenceId, communicationRequestId = ""; + let documentReferenceId, communicationRequestId, patientId = ""; it("I have a JWT", () => { @@ -24,13 +24,12 @@ describe("it test the api", () => { }); - it.skip("I have a the document #1615660", () => { + it("I have a the document #1615660", () => { cy.request({ url:`${apiUrl}/fhir/Binary/1615660`, method:'GET', headers: { "authorization" : `Bearer ${jsonWebToken}`, - "content-type": "application/json", "Prefer": "return=representation" } }).then((response) => { @@ -165,6 +164,26 @@ describe("it test the api", () => { }); }); + it("I fetch the CommunicationRequest after waiting 10sec for the IA to process it", () => { + cy.wait(10000); + cy.request({ + url: `${apiUrl}/fhir/CommunicationRequest/${communicationRequestId}`, + method: 'GET', + headers: { + authorization: `Bearer ${jsonWebToken}` + } + }).then((response) => { + expect(response.status).to.eq(200); + expect(response.headers["content-type"]).to.eq("application/fhir+json;charset=UTF-8"); + expect(response.body).to.have.property("resourceType", "CommunicationRequest"); + expect(response.body).to.have.property('id'); + expect(response.body).to.have.property('status', 'suspended'); + expect(response.body).to.have.property('subject'); + expect(response.body).to.have.property('recipient'); + expect(response.body.subject).to.have.property('reference'); + patientId = response.body.subject.reference; + }); + }); });