From 68acc2a949c6ba28fb5348fbcfc8dfd6ab9c8b15 Mon Sep 17 00:00:00 2001 From: Simon Priet Date: Wed, 8 Sep 2021 11:35:32 +0200 Subject: [PATCH] feat(Cypress): Implemented test step GET Patient --- cypress/integration/api.spec.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/cypress/integration/api.spec.js b/cypress/integration/api.spec.js index b5df212f..a75eefde 100644 --- a/cypress/integration/api.spec.js +++ b/cypress/integration/api.spec.js @@ -164,8 +164,11 @@ describe("it test the api", () => { }); }); - it("I fetch the CommunicationRequest after waiting 10sec for the IA to process it", () => { + it("I fetch the CommunicationRequest's PatientId after waiting 10 sec for the IA to process it", () => { cy.wait(10000); + // avec cypress-recurse, on surveille jusqu'a ce que l'IA ai finit son traitement ; plutot que d'attendre un temps arbitraire. + // import { recurse } from 'cypress-recurse' // a placer en début de fichier. + // recurse(() => cy.request(...), (response) => { expect(response.body).to.have.property('status', 'suspended') } ).then((response) => {...}) cy.request({ url: `${apiUrl}/fhir/CommunicationRequest/${communicationRequestId}`, method: 'GET', @@ -181,7 +184,23 @@ describe("it test the api", () => { 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; + let patient = response.body.subject.reference; + patientId = patient.split("/")[1]; + }); + }); + + it("I get the Patient", () => { + cy.request({ + url: `${apiUrl}/fhir/Patient/${patientId}`, + 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", "Patient"); + expect(response.body).to.have.property('id', patientId); }); });