Untitled
unknown
plain_text
a year ago
2.9 kB
4
Indexable
it("should be able to for practitioner to see tags", () => { // Given signIn( "/appointments/746c607d-79ac-41ac-a249-ef7af1cd6691", practitionerAccount ); const backendUrl = Cypress.env("backendUrl"); // Step 1: Intercept the requests cy.log("Setting up intercepts"); cy.intercept( "GET", `${backendUrl}/appointments/746c607d-79ac-41ac-a249-ef7af1cd6691` ).as("getAppointments"); cy.intercept( "GET", `${backendUrl}/patients/442b4be8-9e89-434b-9e3c-dbcc586b33f0/encounters?appointment_id=746c607d-79ac-41ac-a249-ef7af1cd6691` ).as("getEncounter"); cy.intercept( "GET", `${backendUrl}/medication_requests?encounter_id=36d1448f-df8a-4d95-9a94-dacd95bb4019` ).as("getMedicationRequests"); // Step 2: Wait for the requests to complete cy.log("Waiting for requests to complete"); cy.wait(["@getAppointments", "@getEncounter", "@getMedicationRequests"], { timeout: 15000, }).then(([appointments, encounter, medication_requests]) => { expect(appointments, "Appointments request should not be null").to.not.be .null; expect(encounter, "Encounter request should not be null").to.not.be.null; if (appointments && appointments.response) { expect(appointments.response.statusCode).to.eq(200); } else { cy.log("Appointments request did not complete successfully"); } if (encounter && encounter.response) { expect(encounter.response.statusCode).to.eq(200); } else { cy.log("Encounter request did not complete successfully"); } if (medication_requests && medication_requests.response) { expect(medication_requests.response.statusCode).to.eq(200); } else { cy.log("Encounter request did not complete successfully"); } }); // Step 3: Trigger the actions that cause the requests cy.log("Triggering actions that should cause the requests"); // When practitioner searches for a medication cy.log("Searching for a medication"); cy.get('[data-cy="add-medicine-button"]') .scrollIntoView() .should("be.visible") .click({ force: true }); cy.get('[data-cy="medication-search-autocomplete"]') .should("be.visible") .last() .type(cypressE2eMedication, { force: true }); cy.contains("No data available").should("be.visible"); cy.get("div.v-list-item__title") .contains(cypressE2eMedication) .should("be.visible") .click(); // Then the practitioner should see the tags as error message cy.log("Checking for error message"); cy.get('[data-cy="medication-select"]') .last() .find(".v-messages__message") .should(($messages) => { expect($messages, "Expected exactly one error message").to.have.length( 1 ); }); });
Editor is loading...
Leave a Comment