Skip to content

Commit adad1c9

Browse files
committed
add integrations tests
1 parent c24d3dd commit adad1c9

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
context('Applications Page', () => {
2+
beforeEach(() => {
3+
cy.task('reset')
4+
cy.task('stubSignIn')
5+
cy.signIn()
6+
cy.visit('/')
7+
8+
cy.fixture('sections.json').then(data => {
9+
this.sections = data
10+
})
11+
})
12+
13+
it('should display the page title', () => {
14+
cy.title().should('include', 'Applications')
15+
})
16+
17+
it('should display the banner with the correct content', () => {
18+
cy.get('.applications-landing-page__banner')
19+
.should('exist')
20+
.within(() => {
21+
cy.get('h1').contains('Applications')
22+
cy.get('p').eq(0).contains('Log, action and reply to prisoner applications.')
23+
cy.get('p').eq(1).contains('Give us your').find('a').should('exist')
24+
})
25+
})
26+
27+
it('should display the log an application button', () => {
28+
cy.get('a.govuk-button').should('exist').and('have.text', '\n Log an application\n').and('have.attr', 'href', '#')
29+
})
30+
31+
it('should display all sections with their items', () => {
32+
cy.fixture('sections.json').then(({ sections }) => {
33+
sections.forEach(section => {
34+
cy.contains('h2.govuk-heading-m', section.title).should('exist')
35+
36+
section.items.forEach(item => {
37+
cy.contains('.applications-landing-page__list-menu-item', item.name)
38+
.should('exist')
39+
.within(() => {
40+
cy.get('.applications-landing-page__list-menu-item-notification').should('exist')
41+
cy.get('a').contains(item.name)
42+
})
43+
})
44+
})
45+
})
46+
})
47+
48+
it('should ensure links are functional (if paths are set)', () => {
49+
cy.get('.applications-landing-page__list-menu-item a').each($link => {
50+
const href = $link.attr('href')
51+
if (href && href !== '#') {
52+
cy.request(href).its('status').should('eq', 200)
53+
}
54+
})
55+
})
56+
})
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"sections": [
3+
{
4+
"title": "Departments",
5+
"items": [
6+
{ "name": "Business Hub", "tagText": "44", "path": "" },
7+
{ "name": "OMU", "tagText": "9", "path": "" }
8+
]
9+
},
10+
{
11+
"title": "Wings",
12+
"items": [
13+
{ "name": "First Night Centre", "tagText": "3", "path": "" },
14+
{ "name": "A", "tagText": "0", "path": "" },
15+
{ "name": "B", "tagText": "2", "path": "" },
16+
{ "name": "C", "tagText": "1", "path": "" },
17+
{ "name": "D", "tagText": "0", "path": "" },
18+
{ "name": "E", "tagText": "1", "path": "" }
19+
]
20+
},
21+
{
22+
"title": "Governors",
23+
"items": [
24+
{ "name": "Paul White", "tagText": "1", "path": "" },
25+
{ "name": "James Smart", "tagText": "0", "path": "" },
26+
{ "name": "Syed Hasan", "tagText": "4", "path": "" }
27+
]
28+
}
29+
]
30+
}

0 commit comments

Comments
 (0)