Does not Display Accept or Reject Buttons on Completed Request
does not display accept reject buttons on completed request
Before continuing, make sure you have read the Transaction View Overview & Setup lesson first.
it("does not display accept/reject buttons on completed request", () => {
cy.database("find", "transactions", {
receiverId: ctx.authenticatedUser!.id,
status: "complete",
requestStatus: "accepted",
}).then((transactionRequest) => {
cy.visit(`/transaction/${transactionRequest!.id}`);
cy.wait("@getNotifications");
cy.getBySel("nav-top-notifications-count").should("be.visible");
cy.getBySel("transaction-detail-header").should("be.visible");
cy.getBySel("transaction-accept-request").should("not.exist");
cy.getBySel("transaction-reject-request").should("not.exist");
cy.getBySel("transaction-detail-header").should("be.visible");
cy.visualSnapshot("Transaction Completed (not able to accept or reject)");
});
});
You can find out more information about the custom Cypress commands used in this test here.
The first thing we do is retrieve a "complete" transaction from the database associated with our authenticatedUser
, which we set up in the beforeEach()
hook at the top of this spec file. This test is another example of a "Data-Driven Test." Rather than hard-coding this information, we are using real data from our database to drive our test.
cy.database("find", "transactions", {
receiverId: ctx.authenticatedUser!.id,
status: "complete",
requestStatus: "accepted",
}).then((transactionRequest) => {
// ...
Once we locate the transaction, we then navigate the application to the specific transactions screen.
cy.visit(`/transaction/${transactionRequest!.id}`);
Next, we wait for the @getNotifications
intercept.
cy.wait("@getNotifications")
Finally, we confirm that certain elements are visible or not visible.
cy.getBySel("nav-top-notifications-count").should("be.visible")
cy.getBySel("transaction-detail-header").should("be.visible")
cy.getBySel("transaction-accept-request").should("not.exist")
cy.getBySel("transaction-reject-request").should("not.exist")
cy.getBySel("transaction-detail-header").should("be.visible")