Skip to content

Commit

Permalink
Revert "Show submitted referrals"
Browse files Browse the repository at this point in the history
  • Loading branch information
libuk authored Oct 9, 2023
1 parent 0945c32 commit 955e9e1
Show file tree
Hide file tree
Showing 20 changed files with 209 additions and 302 deletions.
56 changes: 0 additions & 56 deletions cypress_shared/pages/apply/full.ts

This file was deleted.

2 changes: 0 additions & 2 deletions cypress_shared/pages/apply/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import SelectOffencePage from './selectOffence'
import StartPage from './startPage'
import SubmissionConfirmation from './submissionConfirmation'
import TaskListPage from './taskListPage'
import ApplicationFullPage from './full'

export {
AccommodationRequiredFromDatePage,
Expand Down Expand Up @@ -93,5 +92,4 @@ export {
SubstanceMisusePage,
SupportInTheCommunityPage,
TaskListPage,
ApplicationFullPage,
}
67 changes: 26 additions & 41 deletions cypress_shared/pages/apply/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ import { isFullPerson, personName } from '../../../server/utils/personUtils'
import Page from '../page'

export default class ListPage extends Page {
constructor(
private readonly inProgressApplications: Array<Application>,
private readonly submittedApplications: Array<Application>,
) {
constructor(private readonly inProgressApplications: Array<Application>) {
super('Transitional Accommodation (CAS3) referrals')
}

static visit(inProgressApplications: Array<Application>, submittedApplications: Array<Application>): ListPage {
static visit(inProgressApplications: Array<Application>): ListPage {
cy.visit(paths.applications.index.pattern)

return new ListPage(inProgressApplications, submittedApplications)
return new ListPage(inProgressApplications)
}

clickApplication(application: Application) {
Expand All @@ -30,47 +27,35 @@ export default class ListPage extends Page {
this.shouldShowApplications(this.inProgressApplications, 'in-progress', 'In Progress')
}

shouldShowSubmittedApplications(): void {
this.shouldShowApplications(this.submittedApplications, 'applications-submitted', 'Submitted')
}

shouldShowSubmittedApplication(application: Application): void {
this.shouldShowApplication(application, 'applications-submitted', 'Submitted')
}

clickSubmit() {
cy.get('.govuk-button').click()
}

clickSubmittedTab() {
cy.get('a').contains('Submitted').click()
}

private shouldShowApplication(application: Application, containerId: string, status: string): void {
cy.get(`#${containerId}`).within(() => {
cy.get(`a[href*="${paths.applications.show({ id: application.id })}"]`)
.parent()
.parent()
.within(() => {
cy.get('th').eq(0).contains(personName(application.person, 'Limited access offender'))
cy.get('td').eq(0).contains(application.person.crn)
cy.get('td')
.eq(1)
.contains(
application.submittedAt
? DateFormats.isoDateToUIDate(application.submittedAt, {
format: 'short',
})
: 'N/A',
)
cy.get('td').eq(2).contains(status)
})
})
}

private shouldShowApplications(applications: Array<Application>, containerId: string, status: string): void {
cy.get(`#${containerId}`).find('tbody>tr').should('have.length', applications.length)

applications.forEach(application => this.shouldShowApplication(application, containerId, status))
applications.forEach(application => {
const releaseDate = application.data['basic-information']?.['release-date']?.releaseDate

cy.get(`#${containerId}`).within(() => {
cy.get(`a[href*="${paths.applications.show({ id: application.id })}"]`)
.parent()
.parent()
.within(() => {
cy.get('th').eq(0).contains(personName(application.person, 'Limited access offender'))
cy.get('td').eq(0).contains(application.person.crn)
cy.get('td')
.eq(1)
.contains(
releaseDate
? DateFormats.isoDateToUIDate(releaseDate, {
format: 'short',
})
: 'N/A',
)
cy.get('td').eq(2).contains(status)
})
})
})
}
}
3 changes: 1 addition & 2 deletions e2e/tests/apply-and-place.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Feature: Apply for and book a Temporary Accommodation bedspace
Given I am logged in as a referrer
When I start a new application
And I fill in and complete an application
And I see a confirmation of the application
Then I can see the full submitted application
Then I should see a confirmation of the application
Scenario: Booking a bedspace from an assessment
Given I am logged in as an assessor
When I view an existing active premises
Expand Down
18 changes: 1 addition & 17 deletions e2e/tests/stepDefinitions/apply.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Given, Then } from '@badeball/cypress-cucumber-preprocessor'

import ApplyHelper from '../../../cypress_shared/helpers/apply'
import ListPage from '../../../cypress_shared/pages/apply/list'
import ApplicationFullPage from '../../../cypress_shared/pages/apply/full'
import SelectOffencePage from '../../../cypress_shared/pages/apply/selectOffence'
import SubmissionConfirmation from '../../../cypress_shared/pages/apply/submissionConfirmation'
import Page from '../../../cypress_shared/pages/page'
Expand Down Expand Up @@ -50,22 +48,8 @@ Given('I fill in and complete an application', () => {
})
})

Given('I see a confirmation of the application', () => {
Then('I should see a confirmation of the application', () => {
const confirmationPage = Page.verifyOnPage(SubmissionConfirmation)

confirmationPage.clickBackToDashboard()
})

Then('I can see the full submitted application', () => {
cy.url().then(function _() {
const listPage = Page.verifyOnPage(ListPage, [], [])

listPage.clickSubmittedTab()

listPage.shouldShowSubmittedApplication(this.application)

listPage.clickApplication(this.application)

Page.verifyOnPage(ApplicationFullPage, this.application)
})
})
32 changes: 5 additions & 27 deletions integration_tests/tests/apply/apply.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
ApplicationFullPage,
EnterCRNPage,
ListPage,
MoveOnPlanPage,
Expand Down Expand Up @@ -188,7 +187,7 @@ context('Apply', () => {
confirmationPage.clickBackToDashboard()

// Then I am taken back to the dashboard
Page.verifyOnPage(ListPage, applications, [])
Page.verifyOnPage(ListPage, applications)
})

it('shows an error if the application is submitted without checking the confirm checkbox', function test() {
Expand All @@ -199,7 +198,7 @@ context('Apply', () => {
apply.setupApplicationStubs()

// When I visit the application listing page
const listPage = ListPage.visit([this.application], [])
const listPage = ListPage.visit([this.application])

// And I click on the application
listPage.clickApplication(this.application)
Expand All @@ -221,7 +220,7 @@ context('Apply', () => {
apply.setupApplicationStubs()

// When I visit the application listing page
const listPage = ListPage.visit([application], [])
const listPage = ListPage.visit([application])

// And I click on the application
listPage.clickApplication(application)
Expand All @@ -239,7 +238,7 @@ context('Apply', () => {
apply.setupApplicationStubs()

// When I visit the application listing page
const listPage = ListPage.visit([this.application], [])
const listPage = ListPage.visit([this.application])

// And I click on the application
listPage.clickApplication(this.application)
Expand Down Expand Up @@ -278,7 +277,7 @@ context('Apply', () => {
apply.setupApplicationStubs()

// When I visit the application listing page
const listPage = ListPage.visit([this.application], [])
const listPage = ListPage.visit([this.application])

// And I click on the application
listPage.clickApplication(this.application)
Expand All @@ -297,25 +296,4 @@ context('Apply', () => {
// Then I check your answers should be marked as completed
taskListPage.shouldShowTaskStatus('check-your-answers', 'Completed')
})

it('shows the full submitted application', function test() {
// Given there is a complete and submitted application
const application = { ...this.application, status: 'submitted' }

cy.task('stubApplications', [application])
cy.task('stubApplicationGet', { application })

// When I visit the application listing page
const listPage = ListPage.visit([], [application])

// And I click on the submitted tab
listPage.clickSubmittedTab()

// And I click on an application
listPage.clickApplication(application)

// Then I should see the full application
const applicationFullPage = Page.verifyOnPage(ApplicationFullPage, application)
applicationFullPage.shouldShowApplication(application.document)
})
})
8 changes: 1 addition & 7 deletions integration_tests/tests/apply/list.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,11 @@ context('Applications dashboard', () => {
cy.signIn()

// When I visit the Previous Applications page
const page = ListPage.visit(inProgressApplications, submittedApplications)
const page = ListPage.visit(inProgressApplications)

// Then I should see all of the in progress applications
page.shouldShowInProgressApplications()

// And I click on the submitted tab
page.clickSubmittedTab()

// Then I should see the applications that have been submitted
page.shouldShowSubmittedApplications()

// And I the button should take me to the application start page
page.clickSubmit()

Expand Down
2 changes: 1 addition & 1 deletion integration_tests/tests/apply/show.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ context('Application Page', () => {
page.clickBack()

// Then I navigate to the list application page
Page.verifyOnPage(ListPage, inProgressApplications, [])
Page.verifyOnPage(ListPage, inProgressApplications)
})
})
2 changes: 1 addition & 1 deletion integration_tests/tests/landing.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ context('Landing', () => {
cy.signIn()

// I am redirected to the application listing page
Page.verifyOnPage(ListPage, [], [])
Page.verifyOnPage(ListPage, [])
})

it('redirects a user who is not an assessor or a referrer', () => {
Expand Down
15 changes: 0 additions & 15 deletions server/controllers/apply/applicationsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,19 +348,4 @@ describe('applicationsController', () => {
expect(response.render).toHaveBeenCalledWith('applications/confirm')
})
})

describe('full', () => {
it('renders the full application page for submitted referrals', async () => {
const application = createMock<TemporaryAccommodationApplication>()

request = createMock<Request>({
params: { id: application.id },
})

const requestHandler = applicationsController.full()
await requestHandler(request, response, next)

expect(response.render).toHaveBeenCalledWith('applications/full', application)
})
})
})
13 changes: 0 additions & 13 deletions server/controllers/apply/applicationsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,4 @@ export default class ApplicationsController {
return res.render('applications/confirm')
}
}

full(): RequestHandler {
return async (req: Request, res: Response) => {
const callConfig = extractCallConfig(req)

const { id } = req.params
const application = await this.applicationService.findApplication(callConfig, id)

return res.render('applications/full', {
application,
})
}
}
}
1 change: 0 additions & 1 deletion server/paths/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const paths = {
index: applicationsPath,
show: applicationPath,
update: applicationPath,
full: applicationPath.path('full'),
checkYourAnswers: applicationPath.path('check-your-answers'),
submission: applicationPath.path('submission'),
confirm: applicationPath.path('confirm'),
Expand Down
1 change: 0 additions & 1 deletion server/routes/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default function routes(controllers: Controllers, services: Services, rou
get(paths.applications.index.pattern, applicationsController.index(), { auditEvent: 'VIEW_APPLICATIONS_LIST' })
get(paths.applications.new.pattern, applicationsController.new(), { auditEvent: 'VIEW_APPLICATION_NEW' })
get(paths.applications.show.pattern, applicationsController.show(), { auditEvent: 'VIEW_APPLICATION' })
get(paths.applications.full.pattern, applicationsController.full(), { auditEvent: 'VIEW_FULL_APPLICATION' })
get(paths.applications.confirm.pattern, applicationsController.confirm(), {
auditEvent: 'VIEW_APPLICATION_CONFIRM',
})
Expand Down
1 change: 0 additions & 1 deletion server/services/applicationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ describe('ApplicationService', () => {

expect(result).toEqual({
inProgress: inProgressApplications,
submitted: submittedApplications,
})

expect(applicationClientFactory).toHaveBeenCalledWith(callConfig)
Expand Down
4 changes: 0 additions & 4 deletions server/services/applicationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default class ApplicationService {
const allApplications = await applicationClient.all()
const result = {
inProgress: [],
submitted: [],
} as GroupedApplications

await Promise.all(
Expand All @@ -44,9 +43,6 @@ export default class ApplicationService {
case 'inProgress':
result.inProgress.push(application)
break
case 'submitted':
result.submitted.push(application)
break
default:
break
}
Expand Down
Loading

0 comments on commit 955e9e1

Please sign in to comment.