feat(Cypress): Implemented test step GET CommunicationRequest

This commit is contained in:
Simon Priet 2021-09-08 11:13:58 +02:00
parent 7a751125aa
commit 7e88cf0482

View File

@ -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;
});
});
});