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

No errors page #11

Merged
merged 6 commits into from
Nov 20, 2023
Merged
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
3 changes: 2 additions & 1 deletion config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ logs:
error: false
api: {
url: http://127.0.0.1:8082,
validationEndpoint: /api/dataset/validate/file/request/
port: 8082,
validationEndpoint: /api/dataset/validate/file/request
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"prepare": "husky install",
"start": "node index.js",
"start:watch": "concurrently \"nodemon .index.js\" \"npm run scss:watch\"",
"mock:api": "node ./test/mock-api/index.js",
"scss": "sass --quiet-deps --load-path=./ src/assets/scss:public/stylesheets",
"scss:watch": "sass --quiet-deps --load-path=./ --watch src/assets/scss:public/stylesheets",
"mock:api": "node ./test/mock-api/index.js",
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default defineConfig({

/* Run your local dev server before starting the tests */
webServer: {
command: 'concurrently "NODE_ENV=test npm run start" "NODE_ENV=test npm run mock:api"',
command: 'NODE_ENV=test npm run start', // 'concurrently "NODE_ENV=test npm run start" "NODE_ENV=test npm run mock:api"',
url: 'http://127.0.0.1:3000',
reuseExistingServer: !process.env.CI
}
Expand Down
5 changes: 4 additions & 1 deletion src/routes/form-wizard/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export default {
'/upload': {
controller: uploadController,
fields: ['validationResult'],
next: 'errors'
next: [
{ fn: 'hasErrors', next: 'errors' },
'no-errors'
]
},
'/errors': {
controller: errorsController,
Expand Down
35 changes: 35 additions & 0 deletions src/views/no-errors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends "layouts/main.html" %}

{% from 'govuk/components/button/macro.njk' import govukButton %}

{% set pageName = 'Your data has been checked and can be published' %}

{% block content %}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<span class="govuk-caption-l">
{% if data.check.dataset %}
{{data.check.dataset}}
{% else %}
{{data.check.dataSubject}}
{% endif %}
</span>
<h1 class="govuk-heading-l">
{{pageName}}
</h1>
</div>
</div>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<form novalidate method="post">
{{ govukButton({
text: "Continue",
href: '/email-address'
}) }}
</form>

</div>
</div>
{% endblock %}
40 changes: 39 additions & 1 deletion test/acceptance/upload_data.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,45 @@ test('Enter form information', async ({ page }) => {
const fileChooserPromise = page.waitForEvent('filechooser')
await page.getByText('Upload data').click()
const fileChooser = await fileChooserPromise
await fileChooser.setFiles('test/testData/conservation-area.csv')
await fileChooser.setFiles('test/testData/conservation-area-errors.csv')
})

// currently skipping this test as im not sure how to go about providing the pipeline runner api
test.skip('Enter form information and upload a file with errors and without errors', async ({ page }) => {
await page.goto('/')
await page.getByRole('button', { name: 'Start now' }).click()

await page.waitForURL('**/data-subject')

await page.getByLabel('Conservation area').check()
await page.getByRole('button', { name: 'Continue' }).click()

await page.waitForURL('**/dataset')

await page.getByLabel('Conservation area dataset').check()
await page.getByRole('button', { name: 'Continue' }).click()

await page.waitForURL('**/upload')

let fileChooserPromise = page.waitForEvent('filechooser')
await page.getByText('Upload data').click()
let fileChooser = await fileChooserPromise
await fileChooser.setFiles('test/testData/conservation-area-errors.csv')

await page.getByRole('button', { name: 'Continue' }).click()

await page.waitForURL('**/errors')

await page.getByRole('button', { name: 'Upload a new version' }).click()

await page.waitForURL('**/upload')

fileChooserPromise = page.waitForEvent('filechooser')
await page.getByText('Upload data').click()
fileChooser = await fileChooserPromise
await fileChooser.setFiles('test/testData/conservation-area-ok.csv')

await page.getByRole('button', { name: 'Continue' }).click()

await page.waitForURL('**/no-errors')
})
15 changes: 13 additions & 2 deletions test/mock-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@ app.post(config.api.validationEndpoint, (req, res) => {
const filename = req.file.originalname
if (filename === 'conservation-area-errors.csv') {
res.json({
errors: 'true'
issueLog: [
{
row: 2,
column: 'name',
issue: 'Name is required'
},
{
row: 3,
column: 'location',
issue: 'Location is required'
}
]
})
} else {
res.json({
errors: 'false'
issueLog: []
})
}
})
Expand Down
3 changes: 3 additions & 0 deletions test/testData/conservation-area-errors.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
geometry,reference,name,area(ha),documentation-url,Layer,start-date,organisation
"MULTIPOLYGON (((417470.001684007 567301.714013675,417470.028180008 567301.819869675,417472.17410001 567315.500253689,417474.129300011 567328.516317701,417475.822612013 567339.523037711,417476.087188013 567341.110621711,417477.674644015 567341.851357713,417477.992212015 567346.296413718,417477.806996015 567347.592925718,417478.600724015 567353.281373724,417494.860052031 567353.394269723,417495.795988032 567353.585885724,417496.989332032 567353.757661724,417497.669652034 567353.899485724,417499.820308035 567354.233949725,417516.118676051 567357.805789728,417520.566804055 567358.743773729,417534.692500068 567361.827549731,417537.999764071 567362.224349732,417544.190996077 567363.097437732,417554.456852086 567364.552669734,417568.3210441 567366.351837736,417576.576148107 567367.463133737,417580.41256411 567367.939421738,417581.814932112 567368.230365738,417583.137812113 567368.600797737,417584.936980114 567368.944733739,417589.911188119 567369.553373739,417596.790292126 567370.426461739,417616.131348143 567373.813085742,417622.50792415 567375.241949745,417635.842964162 567377.808349747,417642.748564169 567379.051869748,417648.992660174 567380.189661749,417663.095060187 567382.888413751,417663.756564188 567382.994141752,417665.052948189 567383.417565752,417667.063828191 567383.920221752,417668.704276193 567384.528733753,417669.498004193 567384.952157753,417670.609172194 567385.481309753,417671.508756195 567386.010461753,417673.202196197 567386.830685755,417685.029012208 567392.730845761,417686.034452209 567393.207133761,417686.378388209 567393.49820576,417688.495124212 567394.450653762,417690.267796213 567395.006301763,417695.585940218 567397.043549765,417700.136724222 567401.197533768,417700.507156222 567408.579421775,417707.809684229 567409.188061776,417718.102036239 567410.008157777,417721.118228242 567410.008157777,417723.578900244 567409.770077776,417728.394388248 567409.002845775,417730.80206825 567408.261981774,417731.966228251 567407.812189775,417739.427476259 567404.584285771,417754.111892272 567398.154845765,417769.881108287 567391.355101759,417776.098836293 567388.682717757,417781.628564298 567386.301533755,417781.998996298 567384.475869752,417782.263572298 567384.158429753,417782.766356299 567382.83542175,417783.057428299 567381.96233375,417783.163156299 567381.38018975,417783.1896523 567379.581021748,417783.136788299 567379.078365747,417782.9779403 567378.469853748,417782.157844299 567373.813085742,417780.041108296 567362.621277733,417778.850452296 567357.197277727,417776.919060294 567346.957917718,417775.543188293 567339.708253711,417774.087956291 567332.299869703,417772.209428289 567322.616157696,417768.796308286 567305.603421679,417767.790868285 567300.735069675,417766.150420283 567292.162525667,417764.192532281 567281.949661657,417759.959188278 567258.877917636,417747.071892265 567190.413917571,417742.999316262 567168.443101551,417742.829204261 567167.567069551,417742.563092262 567166.196701549,417741.994004261 567166.19414155,417735.141268254 567166.591069549,417724.346260244 567167.067357549,417704.846356226 567168.152157551,417686.087444209 567169.210461551,417667.010836191 567170.268765554,417655.23688418 567170.930269554,417646.796692172 567169.501533553,417645.367956171 567162.410589546,417634.943380161 567163.151453547,417613.750164142 567164.686045548,417601.28821213 567165.638493549,417592.054292121 567166.220637549,417571.152148101 567167.570013551,417555.197716087 567168.654813552,417532.152468066 567170.295261553,417510.641812045 567171.803357555,417500.402452036 567172.544221556,417493.92014803 567173.390813556,417477.198484015 567174.581469556,417464.180884002 567175.481053557,417447.829651987 567176.592349559,417450.68712399 567185.984989567,417452.645011991 567197.547357578,417453.756307992 567204.082525585,417454.788115993 567210.53846159,417456.613779996 567221.650909601,417459.047955997 567235.277021613,417460.370835999 567242.76476562,417462.858004001 567256.893533634,417464.921748003 567269.408349646,417467.091348005 567282.584669657,417469.207956007 567296.50172567,417470.001684007 567301.714013675)))",4,South Jesmond,35.4,https://www.newcastle.gov.uk/services/planning-building-and-development/historic-enviornment-and-urban-design/conservation-areas,Conservation Area,04/04/2024,local-authority-eng:CAT
"MULTIPOLYGON (((-0.307721 51.724964, -0.307831 51.72504, -0.307919 51.725121, -0.309609 51.724308, -0.309719 51.724396, -0.309827 51.724351, -0.310567 51.724111, -0.311557 51.724209, -0.311289 51.725021, -0.312243 51.725144, -0.313361 51.724663, -0.313442 51.724816, -0.313542 51.724941, -0.313769 51.725148, -0.313958 51.725282, -0.314149 51.725388, -0.314346 51.725476, -0.314968 51.72568, -0.315165 51.725757, -0.315342 51.725857, -0.315646 51.7261, -0.315062 51.726357, -0.31565 51.726857, -0.315697 51.726829, -0.316334 51.726541, -0.315174 51.725607, -0.315196 51.725567, -0.316655 51.724859, -0.319179 51.723653, -0.319324 51.72359, -0.319542 51.723529, -0.319311 51.723296, -0.319208 51.72317, -0.319171 51.723098, -0.319121 51.722938, -0.319074 51.722819, -0.318901 51.722609, -0.318655 51.722231, -0.318531 51.722079, -0.318429 51.721913, -0.318361 51.721818, -0.318117 51.721539, -0.31806 51.721433, -0.317967 51.721297, -0.317954 51.721231, -0.317906 51.721137, -0.317558 51.720619, -0.31744 51.720403, -0.317395 51.720347, -0.317332 51.720289, -0.317188 51.720327, -0.317193 51.720374, -0.316058 51.720405, -0.315945 51.720396, -0.315832 51.720366, -0.315523 51.720249, -0.314269 51.719732, -0.314235 51.719711, -0.314208 51.719682, -0.314108 51.719528, -0.314055 51.719543, -0.313452 51.718625, -0.311919 51.718993, -0.311247 51.718465, -0.309691 51.718939, -0.309808 51.719455, -0.30981 51.719479, -0.309762 51.719529, -0.30977 51.71964, -0.309807 51.719735, -0.304259 51.721425, -0.304714 51.721882, -0.304754 51.721885, -0.30476 51.721903, -0.304774 51.721904, -0.304756 51.721927, -0.305138 51.722323, -0.305439 51.722622, -0.306437 51.723516, -0.306725 51.723869, -0.306781 51.723867, -0.306827 51.723892, -0.306886 51.723969, -0.306895 51.723991, -0.30688 51.724023, -0.30685 51.724037, -0.307218 51.724556, -0.307196 51.724572, -0.307501 51.72482, -0.307721 51.724964)))",6,Northumberland Gardens,6.2,https://www.newcastle.gov.uk/services/planning-building-and-development/historic-enviornment-and-urban-design/conservation-areas,Conservation Area,40/04/2024,local-authority-eng:CAT
3 changes: 3 additions & 0 deletions test/testData/conservation-area-ok.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
geometry,reference,name,area(ha),documentation-url,Layer,start-date,organisation
"MULTIPOLYGON (((-0.307721 51.724964, -0.307831 51.72504, -0.307919 51.725121, -0.309609 51.724308, -0.309719 51.724396, -0.309827 51.724351, -0.310567 51.724111, -0.311557 51.724209, -0.311289 51.725021, -0.312243 51.725144, -0.313361 51.724663, -0.313442 51.724816, -0.313542 51.724941, -0.313769 51.725148, -0.313958 51.725282, -0.314149 51.725388, -0.314346 51.725476, -0.314968 51.72568, -0.315165 51.725757, -0.315342 51.725857, -0.315646 51.7261, -0.315062 51.726357, -0.31565 51.726857, -0.315697 51.726829, -0.316334 51.726541, -0.315174 51.725607, -0.315196 51.725567, -0.316655 51.724859, -0.319179 51.723653, -0.319324 51.72359, -0.319542 51.723529, -0.319311 51.723296, -0.319208 51.72317, -0.319171 51.723098, -0.319121 51.722938, -0.319074 51.722819, -0.318901 51.722609, -0.318655 51.722231, -0.318531 51.722079, -0.318429 51.721913, -0.318361 51.721818, -0.318117 51.721539, -0.31806 51.721433, -0.317967 51.721297, -0.317954 51.721231, -0.317906 51.721137, -0.317558 51.720619, -0.31744 51.720403, -0.317395 51.720347, -0.317332 51.720289, -0.317188 51.720327, -0.317193 51.720374, -0.316058 51.720405, -0.315945 51.720396, -0.315832 51.720366, -0.315523 51.720249, -0.314269 51.719732, -0.314235 51.719711, -0.314208 51.719682, -0.314108 51.719528, -0.314055 51.719543, -0.313452 51.718625, -0.311919 51.718993, -0.311247 51.718465, -0.309691 51.718939, -0.309808 51.719455, -0.30981 51.719479, -0.309762 51.719529, -0.30977 51.71964, -0.309807 51.719735, -0.304259 51.721425, -0.304714 51.721882, -0.304754 51.721885, -0.30476 51.721903, -0.304774 51.721904, -0.304756 51.721927, -0.305138 51.722323, -0.305439 51.722622, -0.306437 51.723516, -0.306725 51.723869, -0.306781 51.723867, -0.306827 51.723892, -0.306886 51.723969, -0.306895 51.723991, -0.30688 51.724023, -0.30685 51.724037, -0.307218 51.724556, -0.307196 51.724572, -0.307501 51.72482, -0.307721 51.724964)))",4,South Jesmond,35.4,https://www.newcastle.gov.uk/services/planning-building-and-development/historic-enviornment-and-urban-design/conservation-areas,Conservation Area,04/04/2024,local-authority-eng:CAT
"MULTIPOLYGON (((-0.307721 51.724964, -0.307831 51.72504, -0.307919 51.725121, -0.309609 51.724308, -0.309719 51.724396, -0.309827 51.724351, -0.310567 51.724111, -0.311557 51.724209, -0.311289 51.725021, -0.312243 51.725144, -0.313361 51.724663, -0.313442 51.724816, -0.313542 51.724941, -0.313769 51.725148, -0.313958 51.725282, -0.314149 51.725388, -0.314346 51.725476, -0.314968 51.72568, -0.315165 51.725757, -0.315342 51.725857, -0.315646 51.7261, -0.315062 51.726357, -0.31565 51.726857, -0.315697 51.726829, -0.316334 51.726541, -0.315174 51.725607, -0.315196 51.725567, -0.316655 51.724859, -0.319179 51.723653, -0.319324 51.72359, -0.319542 51.723529, -0.319311 51.723296, -0.319208 51.72317, -0.319171 51.723098, -0.319121 51.722938, -0.319074 51.722819, -0.318901 51.722609, -0.318655 51.722231, -0.318531 51.722079, -0.318429 51.721913, -0.318361 51.721818, -0.318117 51.721539, -0.31806 51.721433, -0.317967 51.721297, -0.317954 51.721231, -0.317906 51.721137, -0.317558 51.720619, -0.31744 51.720403, -0.317395 51.720347, -0.317332 51.720289, -0.317188 51.720327, -0.317193 51.720374, -0.316058 51.720405, -0.315945 51.720396, -0.315832 51.720366, -0.315523 51.720249, -0.314269 51.719732, -0.314235 51.719711, -0.314208 51.719682, -0.314108 51.719528, -0.314055 51.719543, -0.313452 51.718625, -0.311919 51.718993, -0.311247 51.718465, -0.309691 51.718939, -0.309808 51.719455, -0.30981 51.719479, -0.309762 51.719529, -0.30977 51.71964, -0.309807 51.719735, -0.304259 51.721425, -0.304714 51.721882, -0.304754 51.721885, -0.30476 51.721903, -0.304774 51.721904, -0.304756 51.721927, -0.305138 51.722323, -0.305439 51.722622, -0.306437 51.723516, -0.306725 51.723869, -0.306781 51.723867, -0.306827 51.723892, -0.306886 51.723969, -0.306895 51.723991, -0.30688 51.724023, -0.30685 51.724037, -0.307218 51.724556, -0.307196 51.724572, -0.307501 51.72482, -0.307721 51.724964)))",6,Northumberland Gardens,6.2,https://www.newcastle.gov.uk/services/planning-building-and-development/historic-enviornment-and-urban-design/conservation-areas,Conservation Area,04/04/2024,local-authority-eng:CAT