Skip to content

Commit 53133c4

Browse files
committed
adding tests for swap vos pin credit details page
1 parent c11e0d6 commit 53133c4

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import Page from '../pages/page'
2+
import SwapVosDetailsPage from '../pages/swapVosDetailsPage'
3+
4+
context('Swap VOs for PIN Credit Details Page', () => {
5+
beforeEach(() => {
6+
cy.task('reset')
7+
cy.task('stubSignIn')
8+
cy.signIn()
9+
cy.visit('/log/swap-vos-pin-credit-details')
10+
})
11+
12+
it('should direct the user to the correct page', () => {
13+
Page.verifyOnPage(SwapVosDetailsPage)
14+
})
15+
16+
it('should display the correct page title', () => {
17+
cy.title().should('include', 'Log swap VOs for PIN credit details')
18+
})
19+
20+
it('should render the page heading correctly', () => {
21+
const page = Page.verifyOnPage(SwapVosDetailsPage)
22+
page.pageHeading().should('have.text', 'Log details')
23+
})
24+
25+
it('should render the back link with correct text and href', () => {
26+
const page = Page.verifyOnPage(SwapVosDetailsPage)
27+
page.backLink().should('have.text', 'Back').and('have.attr', 'href', '/log/prisoner-details')
28+
})
29+
30+
it('should render the correct app type title', () => {
31+
const page = Page.verifyOnPage(SwapVosDetailsPage)
32+
page.appTypeTitle().should('have.text', 'Swap VOs for PIN credit')
33+
})
34+
35+
it('should render the correct form label for the textarea', () => {
36+
const page = Page.verifyOnPage(SwapVosDetailsPage)
37+
page.formLabel().should('contain.text', 'Details (optional)')
38+
})
39+
40+
it('should display the hint text correctly', () => {
41+
const page = Page.verifyOnPage(SwapVosDetailsPage)
42+
page.hintText().should('have.text', 'Add a brief summary, for example, if this person is a Foreign National')
43+
})
44+
45+
it('should contain a textarea with the correct ID', () => {
46+
const page = Page.verifyOnPage(SwapVosDetailsPage)
47+
page.textArea().should('have.attr', 'id', 'swap-vos-pin-credit-details')
48+
})
49+
50+
it('should include a hidden CSRF token input field', () => {
51+
const page = Page.verifyOnPage(SwapVosDetailsPage)
52+
page.csrfToken().should('exist')
53+
})
54+
55+
it('should render a Continue button with the correct text', () => {
56+
const page = Page.verifyOnPage(SwapVosDetailsPage)
57+
page.continueButton().should('have.text', 'Continue')
58+
})
59+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Page, { PageElement } from './page'
2+
3+
export default class SwapVosDetailsPage extends Page {
4+
constructor() {
5+
super('Log details')
6+
}
7+
8+
backLink = () => cy.get('.govuk-back-link')
9+
10+
appTypeTitle = () => cy.get('.govuk-caption-xl')
11+
12+
pageHeading = () => cy.get('.govuk-heading-xl')
13+
14+
pageTitle = () => cy.title()
15+
16+
hintText = () => cy.get('#swap-vos-pin-credit-details-hint')
17+
18+
formLabel = () => cy.get('label[for="swap-vos-pin-credit-details"]')
19+
20+
textArea = () => cy.get('#swap-vos-pin-credit-details')
21+
22+
csrfToken = () => cy.get('input[name="_csrf"]')
23+
24+
continueButton = () => cy.get('.govuk-button--primary')
25+
}

0 commit comments

Comments
 (0)