Skip to content

Commit

Permalink
Reactify OMIS quote page (#6515)
Browse files Browse the repository at this point in the history
* Add remarkGfm markdown plugin

* Create component to render OMIS terms and conditions

* Reactify OMIS quote page

* Add tests

* Remove legacy code

* Fixup! use STATUS constant
  • Loading branch information
cgsunkel authored Feb 19, 2024
1 parent 664adcb commit a091cff
Show file tree
Hide file tree
Showing 48 changed files with 6,018 additions and 2,403 deletions.
4,789 changes: 4,591 additions & 198 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"redis": "4.6.13",
"redux": "^4.2.1",
"redux-saga": "^1.3.0",
"remark-gfm": "^4.0.0",
"request-promise": "^4.2.6",
"resolve-url-loader": "^5.0.0",
"sass": "^1.70.0",
Expand Down
130 changes: 0 additions & 130 deletions src/apps/omis/__test__/middleware.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const proxyquire = require('proxyquire')

const buildMiddlewareParameters = require('../../../../test/unit/helpers/middleware-parameters-builder')
const companyData = require('../../../../test/unit/data/company.json')
const orderData = require('../../../../test/unit/data/omis/simple-order.json')

describe('OMIS middleware', () => {
Expand Down Expand Up @@ -42,86 +40,6 @@ describe('OMIS middleware', () => {
})
})

describe('setCompany()', () => {
beforeEach(() => {
this.companyId = 'c-1234567890'
})

context('when get company resolves', () => {
beforeEach(() => {
this.getDitCompanyStub.resolves(companyData)
})

it('should call getDitCompany() with correct arguments', async () => {
await this.middleware.setCompany(
this.reqMock,
this.resMock,
this.nextSpy,
this.companyId
)

expect(this.getDitCompanyStub).to.have.been.calledWith(
this.reqMock,
this.companyId
)
})

it('should set a company property on locals', async () => {
await this.middleware.setCompany(
this.reqMock,
this.resMock,
this.nextSpy,
this.companyId
)

expect(this.resMock.locals).to.have.property('company')
expect(this.resMock.locals.company).to.deep.equal(companyData)
})

it('should call next with no errors', async () => {
await this.middleware.setCompany(
this.reqMock,
this.resMock,
this.nextSpy,
this.companyId
)

expect(this.nextSpy).to.have.been.calledWith()
})
})

context('when a company rejects', () => {
beforeEach(() => {
this.error = {
statusCode: 404,
}
this.getDitCompanyStub.rejects(this.error)
})

it('should call next with an error', async () => {
await this.middleware.setCompany(
this.reqMock,
this.resMock,
this.nextSpy,
this.companyId
)

expect(this.nextSpy).to.have.been.calledWith(this.error)
})

it('should not set a company property on locals', async () => {
await this.middleware.setCompany(
this.reqMock,
this.resMock,
this.nextSpy,
this.companyId
)

expect(this.resMock.locals).to.not.have.property('company')
})
})
})

describe('setOrder()', () => {
beforeEach(() => {
this.orderId = 'o-1234567890'
Expand Down Expand Up @@ -332,52 +250,4 @@ describe('OMIS middleware', () => {
})
})
})

describe('setOrderBreadcrumb()', () => {
beforeEach(() => {
this.resMock.locals.order = {
id: '123456789',
reference: '12345/AS',
}
})

it('should call setHomeBreadcrumb with order reference', () => {
this.middleware.setOrderBreadcrumb({}, this.resMock, this.nextSpy)

expect(this.setHomeBreadcrumbStub).to.have.been.calledOnce
expect(this.setHomeBreadcrumbStub).to.have.been.calledWith('12345/AS')

expect(this.setHomeBreadcrumbReturnSpy).to.have.been.calledOnce
expect(this.setHomeBreadcrumbReturnSpy).to.have.been.calledWith(
{},
this.resMock,
this.nextSpy
)
})
})

describe('translate()', () => {
beforeEach(() => {
this.middlewareParameters = buildMiddlewareParameters({})

this.middleware.translate(
this.middlewareParameters.reqMock,
this.middlewareParameters.resMock,
this.middlewareParameters.nextSpy
)
})

it('should set the translate function', () => {
const actual = this.middlewareParameters.resMock.locals.translate(
'fields.contact.label'
)
expect(actual).to.equal('Contact responsible for the order')
})

it('should call next()', () => {
expect(
this.middlewareParameters.nextSpy
).to.have.been.calledOnceWithExactly()
})
})
})
36 changes: 0 additions & 36 deletions src/apps/omis/apps/create/steps.js

This file was deleted.

59 changes: 0 additions & 59 deletions src/apps/omis/apps/edit/steps.js

This file was deleted.

16 changes: 0 additions & 16 deletions src/apps/omis/apps/list/orders.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/apps/omis/apps/list/router.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const router = require('express').Router()

const urls = require('../../../../lib/urls')
const { QUERY_FIELDS } = require('../../constants')

const {
Expand All @@ -9,10 +8,6 @@ const {

const { getRequestBody } = require('../../../../middleware/collection')

const { renderOrdersView } = require('./orders')

router.get(urls.omis.index(), renderOrdersView)

router.get('/export', getRequestBody(QUERY_FIELDS), exportCollection('order'))

module.exports = router
39 changes: 0 additions & 39 deletions src/apps/omis/apps/view/__test__/controllers.test.js

This file was deleted.

Loading

0 comments on commit a091cff

Please sign in to comment.