Skip to content

Commit

Permalink
updated tests to log seed
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeGoodall committed Oct 1, 2024
1 parent 509dd10 commit 41c6558
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 34 deletions.
6 changes: 4 additions & 2 deletions test/unit/dataset-details.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ function errorTestFn ({
}
}

describe('dataset details View', () => {
const params = mock(DatasetDetails)
const seed = new Date().getTime()

describe(`dataset details View (seed: ${seed})`, () => {
const params = mock(DatasetDetails, seed)
params.errors = {}
const html = stripWhitespace(nunjucks.render('dataset-details.html', params))
const datasetName = params.values.dataset.toLowerCase()
Expand Down
6 changes: 4 additions & 2 deletions test/unit/datasetTaskListPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { OrgDatasetTaskList } from '../../src/routes/schemas.js'

const nunjucks = setupNunjucks({})

describe('Dataset Task List Page', () => {
const params = mocker(OrgDatasetTaskList)
const seed = new Date().getTime()

describe(`Dataset Task List Page (seed: ${seed})`, () => {
const params = mocker(OrgDatasetTaskList, seed)
const html = nunjucks.render('organisations/datasetTaskList.html', params)

const dom = new jsdom.JSDOM(html)
Expand Down
6 changes: 4 additions & 2 deletions test/unit/findPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { OrgFindPage } from '../../src/routes/schemas.js'

const nunjucks = setupNunjucks({})

describe('Organisations Find Page', () => {
const params = mock(OrgFindPage)
const seed = new Date().getTime()

describe(`Organisations Find Page (seed: ${seed})`, () => {
const params = mock(OrgFindPage, seed)

const html = nunjucks.render('organisations/find.html', params)

Expand Down
27 changes: 5 additions & 22 deletions test/unit/get-startedPage.test.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,18 @@
// getStartedPage.test.js

import { describe, it, expect } from 'vitest'
import nunjucks from 'nunjucks'
import addFilters from '../../src/filters/filters'
import { runGenericPageTests } from './generic-page.js'
import jsdom from 'jsdom'
import mocker from '../utils/mocker.js'
import { OrgGetStarted } from '../../src/routes/schemas.js'
import { setupNunjucks } from '../../src/serverSetup/nunjucks.js'

const nunjucksEnv = nunjucks.configure([
'src/views',
'src/views/check',
'src/views/submit',
'node_modules/govuk-frontend/dist/',
'node_modules/@x-govuk/govuk-prototype-components/'
], {
dev: true,
noCache: true,
watch: true
})

const datasetNameMapping = new Map([
['article-4-direction', 'Article 4 Direction'],
['article-4-direction-area', 'Article 4 Direction Area']
// ...
])
const nunjucks = setupNunjucks({})

addFilters(nunjucksEnv, { datasetNameMapping })
const seed = new Date().getTime()

describe('Get Started Page', () => {
const params = mocker(OrgGetStarted)
describe(`Get Started Page (seed: ${seed})`, () => {
const params = mocker(OrgGetStarted, seed)
const html = nunjucks.render('organisations/get-started.html', params)

const dom = new jsdom.JSDOM(html)
Expand Down
6 changes: 4 additions & 2 deletions test/unit/http-errorPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ const nunjucks = setupNunjucks({ datasetNameMapping: new Map() })

const dateRegex = /\d{1,2} \w{3,9} \d{4} at \d{1,2}(?::\d{2})?(?:am|pm)/g

describe('http-error.html', () => {
const params = mock(OrgEndpointError)
const seed = new Date().getTime()

describe(`http-error.html(seed: ${seed})`, () => {
const params = mock(OrgEndpointError, seed)

const html = nunjucks.render('organisations/http-error.html', params)
const dom = new JSDOM(html)
Expand Down
6 changes: 4 additions & 2 deletions test/unit/issueDetailsPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import mocker from '../utils/mocker.js'

const nunjucks = setupNunjucks({})

describe('issueDetails.html', () => {
const params = mocker(OrgIssueDetails)
const seed = new Date().getTime()

describe(`issueDetails.html(seed: ${seed})`, () => {
const params = mocker(OrgIssueDetails, seed)

params.issueEntitiesCount = undefined

Expand Down
6 changes: 4 additions & 2 deletions test/unit/lpaOverviewPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import { datasetStatusEnum, OrgOverviewPage } from '../../src/routes/schemas.js'
const datasetNameMapping = new Map()
const nunjucks = setupNunjucks({ datasetNameMapping })

describe('LPA Overview Page', () => {
const params = mocker(OrgOverviewPage)
const seed = new Date().getTime()

describe(`LPA Overview Page (seed: ${seed})`, () => {
const params = mocker(OrgOverviewPage, seed)
const html = nunjucks.render('organisations/overview.html', params)

const dom = new jsdom.JSDOM(html)
Expand Down

0 comments on commit 41c6558

Please sign in to comment.