Skip to content

Commit

Permalink
Extended material test to including adding a favorite
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobArrow committed Nov 28, 2024
1 parent becb835 commit 46a2ea8
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/apps/material/material.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,34 @@ describe("Material", () => {
.should("have.attr", "aria-pressed", "false");
});

it("Can favorite a material", () => {
cy.interceptGraphql({
operationName: "getMaterial",
fixtureFilePath: "material/fbi-api.json"
});

// Intercept like button to show it as filled
cy.intercept("PUT", "**/list/default/**", {
statusCode: 200
}).as("Favorite list service");

cy.createFakeAuthenticatedSession();

cy.visit("/iframe.html?id=apps-material--default&viewMode=story&type=bog");

// Material should show an unfilled heart icon
cy.get(".icon-favourite").should(
"not.have.class",
"icon-favourite--filled"
);

// Favorite the material
cy.get(".button-favourite").click();

// Material should show a filled heart icon
cy.get(".icon-favourite").should("have.class", "icon-favourite--filled");
});

beforeEach(() => {
cy.interceptRest({
httpMethod: "POST",
Expand Down Expand Up @@ -577,7 +605,7 @@ describe("Material", () => {
fixtureFilePath: "material/availability.json"
});

// Intercept like button
// Intercept like button to show it as unfilled
cy.intercept("HEAD", "**/list/default/**", {
statusCode: 404
}).as("Favorite list service");
Expand Down

0 comments on commit 46a2ea8

Please sign in to comment.