Skip to content

Commit

Permalink
fix issue details page tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeGoodall committed Oct 7, 2024
1 parent 68ec323 commit 558da86
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
6 changes: 4 additions & 2 deletions test/unit/issueDetailsPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ describe(`issueDetails.html(seed: ${seed})`, () => {
...params.entry,
geometries: ['POINT(0 0)']
},
issueType: params.issueType
issueType: params.issueType,
issueField: params.issueField
}

const mapHtml = nunjucks.render('organisations/issueDetails.html', paramWithGeometry)
Expand All @@ -206,7 +207,8 @@ describe(`issueDetails.html(seed: ${seed})`, () => {
...params.entry,
geometries: []
},
issueType: params.issueType
issueType: params.issueType,
issueField: params.issueField
}

const mapHtml = nunjucks.render('organisations/issueDetails.html', paramWithGeometry)
Expand Down
55 changes: 27 additions & 28 deletions test/unit/middleware/issueDetails.middleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ describe('issueDetails.middleware.js', () => {
{
field: 'start-date',
value: '02-02-2022',
entry_number: 1
entry_number: 10
}
]
const issues = [
{
entry_number: 0,
entry_number: 10,
field: 'start-date',
value: '02-02-2022'
}
Expand All @@ -32,27 +32,25 @@ describe('issueDetails.middleware.js', () => {
issue_type: 'test-issue-type',
issue_field: 'test-issue-field',
resourceId: 'test-resource-id',
entityNumber: '1'
entryNumber: '10'
}
const req = {
params: requestParams,
// middleware supplies the below
entryNumber: 1,
entityCount: { entity_count: 3 },
issueEntitiesCount: 1,
pageNumber: 1,
orgInfo,
dataset,
entryData,
issues,
resource: { resource: requestParams.resourceId },
issuesByEntryNumber: {
1: [
10: [
{
field: 'start-date',
value: '02-02-2022',
line_number: 1,
entry_number: 1,
entry_number: 10,
message: 'mock message',
issue_type: 'mock type'
}
Expand All @@ -79,15 +77,15 @@ describe('issueDetails.middleware.js', () => {
dataset: 'mock-dataset',
collection: 'mock-collection'
},
errorHeading: 'mockMessageFor: 0',
errorHeading: 'mockMessageFor: 10',
issueItems: [
{
html: 'mock task message 1 in record 1',
href: '/organisations/test-lpa/test-dataset/test-issue-type/test-issue-field/1'
html: 'mock task message 1 in record 10',
href: '/organisations/test-lpa/test-dataset/test-issue-type/test-issue-field/entry/10'
}
],
entry: {
title: 'entry: 1',
title: 'entry: 10',
fields: [
{
key: { text: 'start-date' },
Expand All @@ -98,16 +96,16 @@ describe('issueDetails.middleware.js', () => {
geometries: []
},
issueType: 'test-issue-type',
issueField: 'test-issue-field',
pagination: {
items: [{
current: true,
href: '/organisations/test-lpa/test-dataset/test-issue-type/test-issue-field/1',
href: '/organisations/test-lpa/test-dataset/test-issue-type/test-issue-field/entry/10',
number: 1,
type: 'number'
}]
},
issueEntitiesCount: 1,
pageNumber: 1
issueEntitiesCount: 1
}

expect(req.templateParams).toEqual(expectedTempalteParams)
Expand All @@ -118,12 +116,12 @@ describe('issueDetails.middleware.js', () => {
{
field: 'start-date',
value: '02-02-2022',
entry_number: 1
entry_number: 10
},
{
field: 'geometry',
value: 'POINT(0 0)',
entry_number: 1
entry_number: 10
}
]
const requestParams = {
Expand All @@ -132,34 +130,34 @@ describe('issueDetails.middleware.js', () => {
issue_type: 'test-issue-type',
issue_field: 'test-issue-field',
resourceId: 'test-resource-id',
entityNumber: '1'
entryNumber: '10'
}
const req = {
params: requestParams,
// middleware supplies the below
entryNumber: 1,
entryNumber: 10,
entityCount: { entity_count: 3 },
issueEntitiesCount: 1,
pageNumber: 1,
orgInfo,
dataset,
entryData,
issues,
resource: { resource: requestParams.resourceId },
issuesByEntryNumber: {
1: [
10: [
{
field: 'start-date',
value: '02-02-2022',
line_number: 1,
entry_number: 1,
entry_number: 10,
message: 'mock message',
issue_type: 'mock type'
}
]
}
// errorHeading -- set in prepare* fn
}

v.parse(IssueDetailsQueryParams, req.params)

issues.forEach(issue => {
Expand All @@ -179,15 +177,15 @@ describe('issueDetails.middleware.js', () => {
dataset: 'mock-dataset',
collection: 'mock-collection'
},
errorHeading: 'mockMessageFor: 0',
errorHeading: 'mockMessageFor: 10',
issueItems: [
{
html: 'mock task message 1 in record 1',
href: '/organisations/test-lpa/test-dataset/test-issue-type/test-issue-field/1'
html: 'mock task message 1 in record 10',
href: '/organisations/test-lpa/test-dataset/test-issue-type/test-issue-field/entry/10'
}
],
entry: {
title: 'entry: 1',
title: 'entry: 10',
fields: [
{
key: { text: 'start-date' },
Expand All @@ -207,16 +205,16 @@ describe('issueDetails.middleware.js', () => {
geometries: ['POINT(0 0)']
},
issueType: 'test-issue-type',
issueField: 'test-issue-field',
pagination: {
items: [{
current: true,
href: '/organisations/test-lpa/test-dataset/test-issue-type/test-issue-field/1',
href: '/organisations/test-lpa/test-dataset/test-issue-type/test-issue-field/entry/10',
number: 1,
type: 'number'
}]
},
issueEntitiesCount: 1,
pageNumber: 1
issueEntitiesCount: 1
}

expect(req.templateParams).toEqual(expectedTemplateParams)
Expand Down Expand Up @@ -264,6 +262,7 @@ describe('issueDetails.middleware.js', () => {
geometries: ['POINT(0 0)']
},
issueType: 'test-issue-type',
issueField: 'test-issue-field',
pagination: {
items: [{
current: true,
Expand Down

0 comments on commit 558da86

Please sign in to comment.