cypress-gherkin #1
81
cypress/integration/api.spec.js
Normal file
81
cypress/integration/api.spec.js
Normal file
@ -0,0 +1,81 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
describe("it test the api", () => {
|
||||
let jsonWebToken = "";
|
||||
const apiUrl = "https://fhir-api.public.post-prod.lifen.fr"
|
||||
|
||||
it("I have a JWT", () => {
|
||||
|
||||
cy.request({
|
||||
url: "https://lifen-post-prod.eu.auth0.com/oauth/token",
|
||||
method: "POST",
|
||||
body: {
|
||||
client_id: 'szVsMPaDPUdwqngGiLoHfXFT5XCYPFcy',
|
||||
client_secret: 'sMp2PB-QWBZupCB4IXJrWDJ-7tlpUl09vQ2tMKdy049He7-g93ofbXz7ESlAc82B',
|
||||
audience: 'post-prod-apis',
|
||||
grant_type: 'client_credentials',
|
||||
}
|
||||
}).its('body').then((body) => {
|
||||
jsonWebToken = body.access_token;
|
||||
//cy.log(json_web_token);
|
||||
expect(jsonWebToken).to.not.be.empty;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it("I have a the document #1615660", () => {
|
||||
cy.request({
|
||||
url:`${apiUrl}/fhir/Binary/1615660`,
|
||||
method:'GET',
|
||||
headers: {
|
||||
"Authorization" : `Bearer ${jsonWebToken}`,
|
||||
"contet-type": "application/json",
|
||||
"Prefer": "return=presentation"
|
||||
}
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(200);
|
||||
expect(response.headers["content-type"]).to.eq("application/pdf");
|
||||
})
|
||||
});
|
||||
|
||||
it("I prepare the DocumentReference", () => {
|
||||
cy.request({
|
||||
url:`${apiUrl}/fhir/DocumentReference`,
|
||||
method:'POST',
|
||||
headers: {
|
||||
"Authorization" : `Bearer ${jsonWebToken}`,
|
||||
"contet-type": "application/json",
|
||||
"Prefer": "return=presentation"
|
||||
},
|
||||
body: {
|
||||
"status": "current",
|
||||
"docStatus": "final",
|
||||
"type": {
|
||||
"coding": [
|
||||
{
|
||||
"system": "http://loinc.org",
|
||||
"code": "34109-9",
|
||||
"display": "Document médical"
|
||||
}
|
||||
]
|
||||
},
|
||||
"indexed": "2021-02-11T09:25:39Z",
|
||||
"description": "aelgain-copiepatient.pdf",
|
||||
"content": [
|
||||
{
|
||||
"attachment": {
|
||||
"contentType": "application/pdf",
|
||||
"url": "Binary/1615660",
|
||||
"title": "aelgain-copiepatient.pdf"
|
||||
}
|
||||
}
|
||||
],
|
||||
"resourceType": "DocumentReference"
|
||||
}
|
||||
}).then(response => {
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user