Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM: Add News and Comms with sorting and small form controls #1212

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions app/full-page-examples.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
module.exports = (app) => {
require('./views/full-page-examples/have-you-changed-your-name')(app)
require('./views/full-page-examples/feedback')(app)
require('./views/full-page-examples/how-do-you-want-to-sign-in')(app)
require('./views/full-page-examples/news-and-communications')(app)
require('./views/full-page-examples/passport-details')(app)
require('./views/full-page-examples/update-your-account-details')(app)
require('./views/full-page-examples/upload-your-photo')(app)
require('./views/full-page-examples/what-is-your-address')(app)
require('./views/full-page-examples/what-is-your-nationality')(app)
require('./views/full-page-examples/what-is-your-postcode')(app)
require('./views/full-page-examples/what-was-the-last-country-you-visited')(app)

// Display full page examples index by default if not handled already
app.get('/full-page-examples/:example', function (req, res, next) {
Expand Down
334 changes: 5 additions & 329 deletions app/full-page-examples.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,7 @@ const configPaths = require('../config/paths.json')
const PORT = configPaths.ports.test

const expectedPages = [
'bank-holidays',
'check-your-answers',
'feedback',
'have-you-changed-your-name',
'how-do-you-want-to-sign-in',
'news-and-communications',
'passport-details',
'service-manual-topic',
'start-page',
'update-your-account-details',
'upload-your-photo',
'what-is-your-address',
'what-is-your-nationality',
'what-is-your-postcode',
'what-was-the-last-country-you-visited'
'news-and-communications'
]

// Returns a wrapper for `request` which applies these options by default
Expand Down Expand Up @@ -57,338 +43,28 @@ describe(`http://localhost:${PORT}/full-page-examples/`, () => {
})

describe('/full-page-examples/', () => {
describe('feedback', () => {
it('should not show errors if submit with no input', (done) => {
requestPath.get('feedback', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('Send your feedback to GOV.UK Verify')

// Check that the error summary is not visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeFalsy()
done(err)
})
})
it('should show errors if form is submitted with no input', (done) => {
requestPath.post('feedback', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('Send your feedback to GOV.UK Verify')

// Check that the error summary is visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeTruthy()
done(err)
})
})
})

describe('have-you-changed-your-name', () => {
it('should not show errors if submit with no input', (done) => {
requestPath.get('have-you-changed-your-name', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('Have you changed your name?')

// Check that the error summary is not visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeFalsy()
done(err)
})
})
it('should show errors if form is submitted with no input', (done) => {
requestPath.post('have-you-changed-your-name', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('Have you changed your name?')

// Check that the error summary is visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeTruthy()
done(err)
})
})
})

describe('passport-details', () => {
it('should not show errors if submit with no input', (done) => {
requestPath.get('passport-details', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('Passport details')

// Check that the error summary is not visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeFalsy()
done(err)
})
})
it('should show errors if form is submitted with no input', (done) => {
requestPath.post('passport-details', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('Passport details')

// Check that the error summary is visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeTruthy()
done(err)
})
})
})

describe('update-your-account-details', () => {
it('should not show errors if submit with no input', (done) => {
requestPath.get('update-your-account-details', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('Update your account details')

// Check that the error summary is not visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeFalsy()
done(err)
})
})
it('should show errors if form is submitted with no input', (done) => {
requestPath.post('update-your-account-details', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('Update your account details')

// Check that the error summary is visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeTruthy()
done(err)
})
})
})

describe('upload-your-photo', () => {
it('should not show errors if submit with no input', (done) => {
requestPath.get('upload-your-photo', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('Upload your photo')

// Check that the error summary is not visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeFalsy()
done(err)
})
})
it('should show errors if form is submitted with no input', (done) => {
requestPath.post('upload-your-photo', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('Upload your photo')

// Check that the error summary is visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeTruthy()
done(err)
})
})
})

describe('how-do-you-want-to-sign-in', () => {
it('should not show errors if submit with no input', (done) => {
requestPath.get('how-do-you-want-to-sign-in', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('How do you want to sign in?')

// Check that the error summary is not visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeFalsy()
done(err)
})
})
it('should show errors if form is submitted with no input', (done) => {
requestPath.post('how-do-you-want-to-sign-in', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('How do you want to sign in?')

// Check that the error summary is visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeTruthy()
done(err)
})
})
})

describe('what-is-your-nationality', () => {
it('should not show errors if submit with no input', (done) => {
requestPath.get('what-is-your-nationality', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('What is your nationality?')

// Check that the error summary is not visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeFalsy()
done(err)
})
})
it('should show errors if form is submitted with no input', (done) => {
requestPath.post('what-is-your-nationality', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('What is your nationality?')

// Check that the error summary is visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeTruthy()
done(err)
})
})
})

describe('what-is-your-address', () => {
it('should not show errors if submit with no input', (done) => {
requestPath.get('what-is-your-address', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('What is your address?')

// Check that the error summary is not visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeFalsy()
done(err)
})
})
it('should show errors if form is submitted with no input', (done) => {
requestPath.post('what-is-your-address', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('What is your address?')

// Check that the error summary is visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeTruthy()
done(err)
})
})
})

describe('what-is-your-postcode', () => {
it('should not show errors if submit with no input', (done) => {
requestPath.get('what-is-your-postcode', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('What is your home postcode?')

// Check that the error summary is not visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeFalsy()
done(err)
})
})
it('should show errors if form is submitted with no input', (done) => {
requestPath.post('what-is-your-postcode', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('What is your home postcode?')

// Check that the error summary is visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeTruthy()
done(err)
})
})
})

describe('news-and-communications', () => {
it('should show most wanted results by default', (done) => {
requestPath.get('news-and-communications', (err, res) => {
let $ = cheerio.load(res.body)
// Check the results are correct
expect($.html()).toContain('128,124 results')
expect($.html()).toContain('822,411 results')
done(err)
})
})
it('should show sorted results when selected', (done) => {
requestPath.get('news-and-communications?order=updated-newest', (err, res) => {
let $ = cheerio.load(res.body)
// Check the results are correct
expect($.html()).toContain('128,123 results')
expect($.html()).toContain('142,218 results')
done(err)
})
})
it('should show brexit results when checked', (done) => {
requestPath.get('news-and-communications?order=most-viewed&brexit=true', (err, res) => {
requestPath.get('news-and-communications?order=updated-newest&organisation=hmrc', (err, res) => {
let $ = cheerio.load(res.body)
// Check the results are correct
expect($.html()).toContain('586 results')
done(err)
})
})
})

describe('what-was-the-last-country-you-visited', () => {
it('should not show errors if submit with no input', (done) => {
requestPath.get('what-was-the-last-country-you-visited', (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('What was the last country you visited?')

// Check that the error summary is not visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeFalsy()
done(err)
})
})
it('should show errors if form is submitted with no input', (done) => {
requestPath.post(`what-was-the-last-country-you-visited`, (err, res) => {
let $ = cheerio.load(res.body)

// Check the page responded correctly
expect(res.statusCode).toBe(200)
expect($.html()).toContain('What was the last country you visited?')

// Check that the error summary is visible
let $errorSummary = $('[data-module="error-summary"]')
expect($errorSummary.length).toBeTruthy()
expect($.html()).toContain('421,182 results')
done(err)
})
})
Expand Down
Loading