Skip to content

Commit

Permalink
fix: grantShow cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-McFaddin committed Jul 14, 2023
1 parent f07c816 commit 78ed440
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
31 changes: 7 additions & 24 deletions cypress/e2e/boilerplate-e2e/grantShow.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ describe("View a Grant on the Grants Show page", () => {
cy.intercept("GET", "/api/organizations/**/boilerplates").as(
"getBoilerplate"
);
cy.intercept("DELETE", "/api/organizations/**/boilerplates/**").as(
"deleteBoilerplate"
);

// Select grant to view
cy.get("td:contains('Cypress Tree Neighborhood Grant')").first().click();
Expand Down Expand Up @@ -57,6 +60,7 @@ describe("View a Grant on the Grants Show page", () => {
cy.get("button:contains('Save')").click();
});
cy.wait("@createGrant");
cy.reload();
cy.get("h1:contains('Cypress Tree Neighborhood Grant copy')");

// Edit grant
Expand All @@ -75,7 +79,6 @@ describe("View a Grant on the Grants Show page", () => {
cy.get("button[type=submit]").click();
});
cy.wait("@editGrant");
// cy.wait("@getGrant");

// Delete copy
cy.get("a[type=button]:contains('Edit')").click();
Expand All @@ -96,6 +99,7 @@ describe("View a Grant on the Grants Show page", () => {
});
cy.wait("@createSection");
cy.wait("@getGrant");
cy.reload();

// Edit the newly created section
cy.get("h2:contains('New Section Title')")
Expand Down Expand Up @@ -150,27 +154,8 @@ describe("View a Grant on the Grants Show page", () => {
"contain",
"Ekram Hanna, MIRA Community Engagement Manager, Certified Mental Health First Aid Trainer"
);
// Clear search inputs and display all boilerplates
// cy.get('[data-testid="Max Word Count"]').clear();
// cy.get(".dropdown__menu").last().clear(); // !!!!!! This won't work because the dropdown can't be cleared. Need all boilerplate option
// Paste another boilerplate
// cy.get("h6.accordion-item__header:contains('Mission)").click();
// Then check for the pasted boilerplate inside the form
// cy.get(".ql-editor").should(
// "contain",
// "With the introduction of a new shorter (4 hour) course, MIRA staff"
// );
// Text appears multiple times?

// Cancel/close select and paste boilerplates
cy.get(".paste-boilerplate-content-popout__close-button").click();

cy.get("h2:contains('New Section Title')")
.first()
.within(() => {
cy.get("button").first().click();
});

// Store section as boilerplate
cy.get("button:contains('Store Section as Boilerplate')").click();
cy.get("h1:contains('Store Section as Boilerplate')");
Expand All @@ -191,10 +176,8 @@ describe("View a Grant on the Grants Show page", () => {
cy.get("a:contains('Section To Boilerplate Test')").first().click();
cy.get("button:contains('Edit')").click();
cy.get("button:contains('Delete')").click();
cy.wait("@getBoilerplate");
cy.get("td").first().should("contain", "Mission");
cy.get("td").last().should("not.contain", "Section To Boilerplate Test");
// cy.get("td:contains('Section To Boilerplate Test')").should("not.exist");
cy.reload();
cy.get("tr").last().should("not.contain", "Section To Boilerplate Test");

// Delete the newly added section
cy.get("a:contains('Grants')").click();
Expand Down
3 changes: 3 additions & 0 deletions cypress/e2e/boilerplate-e2e/grantShowOverview.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe("Grant overview DnD", () => {
cy.get("button:contains('Undo')").should("have.class", "button--disabled");
cy.get("button:contains('Redo')").should("have.class", "button--disabled");

// TODO: Could not get this to work
// Drag another section, select Undo and check that Save and Undo are disabled and Redo is enabled
cy.get('[data-testid="Section 2"]').move({
deltaY: 400,
Expand All @@ -80,6 +81,7 @@ describe("Grant overview DnD", () => {
// "button--disabled"
// );

// TODO: Could not get this to work
// Drag a section, select Rndo and check that Save and Uedo is active
cy.get('[data-testid="Section 4"]').move({
deltaY: 300,
Expand Down Expand Up @@ -115,6 +117,7 @@ describe("Grant overview DnD", () => {
});
cy.wait(2000);

// TODO
// Save

// Grab the sections and check that the order is reversed
Expand Down

0 comments on commit 78ed440

Please sign in to comment.