-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add E2E tests for feedback + print button
- Loading branch information
1 parent
9482914
commit 5faafc3
Showing
3 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
tests/Dfe.ContentSupport.Web.E2ETests/cypress/e2e/pages/feedback.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
describe('Feedback banner', () => { | ||
it("should be visible when tracking consented", () => { | ||
cy.visit('content/hello-world', | ||
{ | ||
headers: { | ||
'Cookie': '.AspNet.Consent=yes' | ||
} | ||
} | ||
); | ||
|
||
cy.get("div#feedback-banner") | ||
.should('exist') | ||
.not("govuk-visually-hidden") | ||
.should('not.have.attr', 'aria-hidden'); | ||
}); | ||
|
||
it("should not exist when tracking consent not given", () => { | ||
cy.visit('content/hello-world', | ||
{ | ||
headers: { | ||
'Cookie': '.AspNet.Consent=no' | ||
} | ||
} | ||
); | ||
|
||
cy.get("div#feedback-banner") | ||
.should('not.exist'); | ||
}); | ||
|
||
}); |
25 changes: 25 additions & 0 deletions
25
tests/Dfe.ContentSupport.Web.E2ETests/cypress/e2e/pages/print-button.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
describe('Print button', () => { | ||
beforeEach(() => { | ||
cy.visit('content/hello-world', { | ||
onBeforeLoad(win) { | ||
//Stub the print functionality so we can see if it was called | ||
//Note: could spy instead, but I don't want the print dialog to actually show. | ||
cy.stub(win, 'print', () => { }); | ||
}, | ||
}); | ||
}); | ||
|
||
it("should be visible", () => { | ||
cy.get("div.print-button") | ||
.should('exist') | ||
.not("govuk-visually-hidden") | ||
.should('not.have.attr', 'aria-hidden'); | ||
|
||
cy.get("button#print-link").should("exist"); | ||
}); | ||
|
||
it("should print on click", () => { | ||
cy.get("button#print-link").click(); | ||
cy.window().its("print").should('be.called'); | ||
}); | ||
}); |