Skip to content
Closed
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
8 changes: 4 additions & 4 deletions src/server/plugins/engine/models/SummaryViewModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ describe('SummaryPageController', () => {
})

describe('Save and Return functionality', () => {
it('should show save and return button on summary page', () => {
expect(controller.shouldShowSaveAndReturn(request.server)).toBe(true)
it('should not show save and return button on summary page by default', () => {
expect(controller.shouldShowSaveAndReturn(request.server)).toBe(false)
})

it('should handle save and return from summary page', () => {
it('should not handle save and return from summary page by default', () => {
const state: FormState = {
$$__referenceNumber: 'foobar',
orderType: 'collection',
Expand All @@ -293,7 +293,7 @@ describe('SummaryPageController', () => {
const context = model.getFormContext(request, state)
const viewModel = controller.getViewModel(request, context)

expect(viewModel).toHaveProperty('allowSaveAndReturn', true)
expect(viewModel).toHaveProperty('allowSaveAndReturn', false)
})

it('should display correct page title', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,10 +1119,10 @@ describe('FileUploadPageController', () => {
})
})

describe('shouldShowSaveAndReturn', () => {
it('should return true when save and return is enabled', () => {
describe('shouldNotShowSaveAndReturnByDefault', () => {
it('should return false when save and return is disabled by default', () => {
expect(controller.shouldShowSaveAndReturn(serverWithSaveAndReturn)).toBe(
true
false
)
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ describe('Save and Return functionality', () => {
describe('shouldShowSaveAndReturn', () => {
it('should return true by default', () => {
expect(controller1.shouldShowSaveAndReturn(serverWithSaveAndReturn)).toBe(
true
false
)
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import { merge } from '~/src/server/services/cacheService.js'
export class QuestionPageController extends PageController {
collection: ComponentCollection
errorSummaryTitle = 'There is a problem'
allowSaveAndReturn = true

constructor(model: FormModel, pageDef: Page) {
super(model, pageDef)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ describe('RepeatPageController', () => {
})
})

describe('shouldShowSaveAndReturn', () => {
it('should return true when save and return is enabled', () => {
describe('shouldNotShowSaveAndReturnByDefault', () => {
it('should return false when save and return is disabled by default', () => {
expect(controller.shouldShowSaveAndReturn(serverWithSaveAndReturn)).toBe(
true
false
)
})
})
Expand Down
9 changes: 3 additions & 6 deletions test/form/save-and-return.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,17 @@ describe('Save and Return functionality', () => {
})

describe('Save and Return button', () => {
it('should render the save and return button on question pages with the correct name and value attributes', async () => {
it('should not render the save and return button on question pages with the correct name and value attributes', async () => {
const { container } = await renderResponse(server, {
url: `${basePath}/licence`,
headers
})

const $saveButton = container.getByRole('button', {
const $saveButton = container.queryByRole('button', {
name: 'Save and return'
})

expect($saveButton).toBeInTheDocument()
expect($saveButton).toHaveClass('govuk-button--secondary')
expect($saveButton).toHaveAttribute('name', 'action')
expect($saveButton).toHaveAttribute('value', 'save-and-return')
expect($saveButton).not.toBeInTheDocument()
})
})

Expand Down
Loading