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

Form Inputs #3

Merged
merged 44 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
89567ff
added scss
GeorgeGoodall Oct 24, 2023
993d411
updated readme
GeorgeGoodall Oct 24, 2023
bcbed13
added the start page
GeorgeGoodall Oct 25, 2023
5a00204
added the start page
GeorgeGoodall Oct 25, 2023
c2a56ef
remove old files
GeorgeGoodall Oct 25, 2023
08a3b29
added pages up to upload
GeorgeGoodall Oct 26, 2023
3a98f4f
Merge pull request #2 from digital-land/github-workflows
GeorgeGoodall Oct 26, 2023
de6ca51
Merge remote-tracking branch 'origin/main' into basicPages
GeorgeGoodall Oct 26, 2023
784f132
remove helloWorld.test.js
GeorgeGoodall Oct 26, 2023
82996a1
add empty test files
GeorgeGoodall Oct 26, 2023
14019c7
added playwright and testing scripts
GeorgeGoodall Oct 26, 2023
2a179d1
correctly install playwright
GeorgeGoodall Oct 26, 2023
a1d3c5f
add pages load ok tests
GeorgeGoodall Oct 26, 2023
0bef200
remove test from pre-commit
GeorgeGoodall Oct 26, 2023
f2a9872
fix linting
GeorgeGoodall Oct 27, 2023
7662d3f
add codegen to package json
GeorgeGoodall Oct 27, 2023
0fe128f
fix linting
GeorgeGoodall Oct 27, 2023
73b9fd6
add skipped playwright test for uploading data
GeorgeGoodall Oct 27, 2023
2068dcf
started playing with hmpo-form-wizard
GeorgeGoodall Oct 31, 2023
44d225f
updated gitignore
GeorgeGoodall Oct 31, 2023
c87a8c7
Merge branch 'Initial-tests-for-tdd' into hmpo-form-wizard
GeorgeGoodall Oct 31, 2023
e0fe2ba
update upload_data.test to better highlight what should be developed
GeorgeGoodall Nov 1, 2023
340324f
update tests to better drive development
GeorgeGoodall Nov 1, 2023
7a38656
update views to have correct form field ids
GeorgeGoodall Nov 1, 2023
610c6ad
add controllers for the relevant routes
GeorgeGoodall Nov 1, 2023
d45bbf4
extend the index file to use the hmpo-form-wizard
GeorgeGoodall Nov 1, 2023
40e206a
add uploads to gitignore
GeorgeGoodall Nov 1, 2023
d69c1ba
add hmpo and multer packages
GeorgeGoodall Nov 1, 2023
445aa0c
change testdata size
GeorgeGoodall Nov 1, 2023
2b80da7
rename conservation area file
GeorgeGoodall Nov 1, 2023
187e710
remove unused routes
GeorgeGoodall Nov 1, 2023
a463f8b
fix file chooser testing
GeorgeGoodall Nov 3, 2023
f827a71
remove comments from uploadController
GeorgeGoodall Nov 3, 2023
810034a
tidy up index.js file
GeorgeGoodall Nov 3, 2023
e06d556
updated start to point at '.'
GeorgeGoodall Nov 3, 2023
639dc75
removed unneeded action from data-subject form
GeorgeGoodall Nov 3, 2023
290a071
updated the submit form to return the response back to the user
GeorgeGoodall Nov 3, 2023
06346f9
start server for playwright
GeorgeGoodall Nov 3, 2023
0f269b0
add hello world tests for testing that doesn't yet exist so the pipel…
GeorgeGoodall Nov 3, 2023
989cdc2
update start page path to '/'
GeorgeGoodall Nov 3, 2023
0d8bcca
install playwright deps before test
GeorgeGoodall Nov 3, 2023
7f50d45
Merge remote-tracking branch 'origin/main' into hmpo-form-wizard
GeorgeGoodall Nov 3, 2023
3ebf575
refresh package.locl
GeorgeGoodall Nov 3, 2023
ffa1d65
fix playwright install command
GeorgeGoodall Nov 3, 2023
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
1 change: 1 addition & 0 deletions .github/workflows/lint_and_test_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ jobs:
- uses: actions/checkout@v4
- run: |
npm ci
npx playwright install --with-deps
npm run test
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,14 @@ dist
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.pnp.*

# playwright
/test-results/
/playwright-report/*
/playwright/.cache/

public/*
.vscode/launch.json

uploads/*
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run test
npm run lint
8 changes: 8 additions & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
port: 3000
logs:
console: true
app: false
error: false
api: {
url: http://localhost:3000/api
}
5 changes: 5 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const HmpoConfig = require('hmpo-config')

const config = new HmpoConfig()
config.addFile('./config/default.yaml')
module.exports = config.toJSON()
86 changes: 77 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,87 @@
'use strict'

const hmpoLogger = require('hmpo-logger')
const express = require('express')
const cookieParser = require('cookie-parser')
const session = require('express-session')
const nunjucks = require('nunjucks')
const path = require('path')
const bodyParser = require('body-parser')
const config = require('./config')
const { govukMarkdown } = require('@x-govuk/govuk-prototype-filters')

const logger = hmpoLogger.config(config.logs).get()

const app = express()

nunjucks.configure('src/views', {
express: app
// log access requests
app.use(hmpoLogger.middleware())

// add routing for static assets
app.use('/public', express.static(path.resolve(__dirname, 'public')))

// cookies and sessions (redis or elasticache should be used in a prod env)
app.use(cookieParser())
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: false,
cookie: { secure: false }
}))

// templating engine (turn on caching and turn off watching in prod env)
app.set('view engine', 'html')
const nunjucksEnv = nunjucks.configure([
'src/views',
'node_modules/govuk-frontend/',
'node_modules/@x-govuk/govuk-prototype-components/'
], {
express: app,
dev: true,
noCache: true,
watch: true
})

const globalValues = {
serviceName: 'Publish planning and housing data for England'
}

Object.keys(globalValues).forEach((key) => {
nunjucksEnv.addGlobal(key, globalValues[key])
})
nunjucksEnv.addFilter('govukMarkdown', govukMarkdown)

app.get('/', (req, res) => {
const data = {
title: 'Hello World',
content: 'This is a sample content'
// body parser
app.use(bodyParser.urlencoded({ extended: true }))

app.use('/', require('./src/routes/form-wizard'))

// file not found handler
app.use((req, res, next) => {
res.status(404).render('pages/file-not-found')
})

// error handler
app.use((err, req, res, next) => {
logger.error('Request error', { req, err })

// handle session expired
if (err.code === 'SESSION_TIMEOUT') {
err.template = 'pages/session-expired'
}

// handle errors with automatic redirects
if (err.redirect) {
return res.redirect(err.redirect)
}
res.render('helloWorld.html', data)

// show error page
err.status = err.status || 500
err.template = err.template || 'pages/error'
res.status(err.status).render(err.template, { err })
})

app.listen(3000, () => {
console.log('Server listening on port 3000')
// listen for incomming requests
app.listen(config.port, () => {
logger.info('App listening on http://localhost::port', { port: config.port })
})
Loading