Skip to content

Commit 1ba25b6

Browse files
authored
Feature/RA-247-swap vos pin credit details page tests (#19)
* adding tests for swap vos pin credit details page * Fixing a linter check error * Trying the standard approach for testing * Fxing and trying the standard approach for testing * Fixing a test * Fix: improve test structure and fix errors in test execution * Refactoring the code * Renaming the file to make it consistent
1 parent 23b45b3 commit 1ba25b6

File tree

2 files changed

+72
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)