Skip to content

Commit

Permalink
feat: DAH-2932 use layered_preference_validation__c (#696)
Browse files Browse the repository at this point in the history
* feat: use layered_preference_validation

* fix: post_lottery_validation for non-veterans

* fix: update unit test

* test: update cassettes

* test: e2e

* Revert "test: e2e"

This reverts commit 248d295.

* test: e2e
  • Loading branch information
cliu02 authored Jan 2, 2025
1 parent 63cc79e commit 2d134ce
Show file tree
Hide file tree
Showing 10 changed files with 438 additions and 406 deletions.
1 change: 1 addition & 0 deletions app/controllers/api/v1/lease_up_applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def lease_up_apps_params
:general_lottery_rank,
:general,
:pagination,
:layered_preference_validation,
accessibility: [],
preference: [],
status: [],
Expand Down
19 changes: 16 additions & 3 deletions app/javascript/components/lease_ups/LeaseUpApplicationsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import StatusCell from 'components/lease_ups/application_page/StatusCell'
import appPaths from 'utils/appPaths'
import { useAppContext } from 'utils/customHooks'
import { MAX_SERVER_LIMIT } from 'utils/EagerPagination'
import { useFeatureFlag } from 'utils/hooks/useFeatureFlag'
import { cellFormat } from 'utils/reactTableUtils'
import { getLeaseUpStatusClass } from 'utils/statusUtils'

Expand Down Expand Up @@ -62,6 +63,9 @@ const LeaseUpApplicationsTable = ({

const navigate = useNavigate()

const { unleashFlag: partnersPaginationEnabled, flagsReady } =
useFeatureFlag('PARTNERS_PAGINATION')

const updateSelectedApplicationState = (application, navigateToApplication = false) => {
applicationRowClicked(dispatch, application)

Expand All @@ -75,6 +79,17 @@ const LeaseUpApplicationsTable = ({
} pages of applications at this time. Please use the filters above to narrow your results.`
const noDataMsg =
atMaxPages || page >= 100 ? maxPagesMsg : 'No results, try adjusting your filters'

const getPreferenceValidation = (cell) => {
if (partnersPaginationEnabled && flagsReady) {
return cell.original.layered_preference_validation
? cell.original.layered_preference_validation
: cell.original.post_lottery_validation
} else {
return prefMap[`${cell.original.application_id}-${cell.original.preference_name}`]
}
}

const columns = [
{
Header: '',
Expand Down Expand Up @@ -102,9 +117,7 @@ const LeaseUpApplicationsTable = ({
Cell: (cell) => (
<PreferenceRankCell
preferenceRank={cell.original.preference_rank}
preferenceValidation={
prefMap[`${cell.original.application_id}-${cell.original.preference_name}`]
}
preferenceValidation={getPreferenceValidation(cell)}
/>
)
},
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/components/lease_ups/leaseUpAppPrefModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const buildLeaseUpAppPrefModel = (applicationPreference) => {
applicationPreference.preference_lottery_rank,
post_lottery_validation: applicationPreference.post_lottery_validation,
lottery_status: applicationPreference.lottery_status,
total_household_size: application.total_household_size
total_household_size: application.total_household_size,
layered_preference_validation: applicationPreference.layered_preference_validation
}
}
12 changes: 6 additions & 6 deletions app/models/force/preference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Preference < Force::ObjectBase
# Individual_preference has a lowercase 'p' on purpose.
{ custom_api: 'individualPreference', domain: 'individual_preference', salesforce: 'Individual_preference' },

# TODO Split this into two fields, the String Listing_Preference_ID__c version, and the hash Listing_Preference_ID__r version.
# TODO: Split this into two fields, the String Listing_Preference_ID__c version, and the hash Listing_Preference_ID__r version.
{ custom_api: 'listingPreferenceID', domain: 'listing_preference_id', salesforce: 'Listing_Preference_ID' },
{ custom_api: '', domain: 'lottery_status', salesforce: 'Lottery_Status' },
{ custom_api: 'lwPreferenceProof', domain: 'lw_type_of_proof', salesforce: 'LW_Type_of_Proof' },
Expand All @@ -43,6 +43,7 @@ class Preference < Force::ObjectBase
{ custom_api: '', domain: 'total_household_rent', salesforce: 'Total_Household_Rent' },
{ custom_api: '', domain: 'custom_preference_type', salesforce: 'Custom_Preference_Type' },
{ custom_api: 'zip', domain: 'zip_code', salesforce: 'Zip_Code' },
{ custom_api: '', domain: 'layered_preference_validation', salesforce: 'Layered_Preference_Validation' },
].freeze

PREFERENCE_TYPES = [
Expand All @@ -69,7 +70,8 @@ def self.from_salesforce(attributes)

# Listing_Preference_ID actually refers to both Listing_Preference_ID__r and Listing_Preference_ID__c
if fields.Listing_Preference_ID && !fields.Listing_Preference_ID.is_a?(String)
preference.fields.salesforce['Listing_Preference_ID.Record_Type_For_App_Preferences'] = fields.Listing_Preference_ID.Record_Type_For_App_Preferences
preference.fields.salesforce['Listing_Preference_ID.Record_Type_For_App_Preferences'] =
fields.Listing_Preference_ID.Record_Type_For_App_Preferences
preference.fields.salesforce.delete 'Listing_Preference_ID'
end

Expand All @@ -84,7 +86,7 @@ def to_domain
# Special field conversion cases for preferences
domain_fields.total_household_rent = domain_fields.total_household_rent.to_s if domain_fields.total_household_rent

if !domain_fields.preference_name
unless domain_fields.preference_name
if @fields.salesforce.Preference_All_Name
domain_fields.preference_name = @fields.salesforce.Preference_All_Name
elsif @fields.salesforce.empty?
Expand All @@ -100,9 +102,7 @@ def to_domain
domain_fields.application_member = Force::ApplicationMember.from_salesforce(domain_fields.application_member).to_domain
end

if domain_fields.application
domain_fields.application = Force::Application.from_salesforce(domain_fields.application).to_domain
end
domain_fields.application = Force::Application.from_salesforce(domain_fields.application).to_domain if domain_fields.application

domain_fields
end
Expand Down
3 changes: 2 additions & 1 deletion config/salesforce/fields/preferences.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ preferences:
label: "Status Updated"
Listing_Preference_ID__r.Record_Type_For_App_Preferences__c:
Custom_Preference_Type__c:
Layered_Preference_Validation__c:
app_preferences_for_lottery_results_fields:
Application__r.General_Lottery__c:
Application__r.General_Lottery_Rank__c:
Application__r.Lottery_Number__c:
Application__r.Lottery_Number__c:
Application__r.Lottery_Number_Manual__c:
Application__r.Lottery_Rank__c:
Preference_All_Name__c:
Expand Down
11 changes: 0 additions & 11 deletions cypress/e2e/LeaseUpApplicationsPage/status_update.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,10 @@ describe('LeaseUpApplicationsPage status update', () => {
cy.intercept('api/v1/applications/**/field_update_comments', {
fixture: 'fieldUpdateComments.json'
}).as('fieldUpdateComments')
cy.intercept(`api/v1/lease-ups/applications?listing_id=${LEASE_UP_LISTING_ID}&general=true`, {
fixture: 'leaseUpApplicationsGeneral.json'
}).as('leaseUpApplicationsGeneral')
} else {
cy.intercept('api/v1/lease-ups/listings/**').as('leaseUpListing')
cy.intercept('api/v1/lease-ups/applications?listing_id=**').as('leaseUpApplications')
cy.intercept('api/v1/applications/**/field_update_comments').as('fieldUpdateComments')
cy.intercept(
`api/v1/lease-ups/applications?listing_id=${LEASE_UP_LISTING_ID}&general=true`
).as('leaseUpApplicationsGeneral')
}
})
describe('using the individual row status dropdown', () => {
Expand All @@ -48,7 +42,6 @@ describe('LeaseUpApplicationsPage status update', () => {
cy.visit(`/lease-ups/listings/${LEASE_UP_LISTING_ID}?featureFlag[PARTNERS_PAGINATION]=false`)
cy.wait('@leaseUpListing')
cy.wait('@leaseUpApplications')
cy.wait('@leaseUpApplicationsGeneral')

// Change status to one that is not currently selected.
cy.getText(firstRowStatusDropdown).then((text) => {
Expand All @@ -73,7 +66,6 @@ describe('LeaseUpApplicationsPage status update', () => {
)
cy.wait('@leaseUpListing')
cy.wait('@leaseUpApplications')
cy.wait('@leaseUpApplicationsGeneral')

// Check the checkboxes in the 2nd and 3rd row
cy.get(bulkActionCheckboxId(SECOND_ROW_LEASE_UP_APP_ID)).click()
Expand Down Expand Up @@ -123,7 +115,6 @@ describe('LeaseUpApplicationsPage status update', () => {
)
cy.wait('@leaseUpListing')
cy.wait('@leaseUpApplications')
cy.wait('@leaseUpApplicationsGeneral')

cy.get(bulkEditCheckboxId).click()

Expand All @@ -142,7 +133,6 @@ describe('LeaseUpApplicationsPage status update', () => {
)
cy.wait('@leaseUpListing')
cy.wait('@leaseUpApplications')
cy.wait('@leaseUpApplicationsGeneral')

const originalStatus = cy.getText(nthRowStatusDropdownSelector(2))
const originalSubStatus = cy.getText(secondRowSubstatus)
Expand Down Expand Up @@ -174,7 +164,6 @@ describe('LeaseUpApplicationsPage status update', () => {
)
cy.wait('@leaseUpListing')
cy.wait('@leaseUpApplications')
cy.wait('@leaseUpApplicationsGeneral')

cy.contains('button', 'Show Filters').click()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'

import { render } from '@testing-library/react'
import { useFlag, useFlagsStatus } from '@unleash/proxy-client-react'
import { BrowserRouter } from 'react-router-dom'

import LeaseUpApplicationsTable from 'components/lease_ups/LeaseUpApplicationsTable'
Expand All @@ -13,6 +14,8 @@ import {
mockPrefMap
} from '../../fixtures/lease_up_applications'

jest.mock('@unleash/proxy-client-react')

describe('LeaseUpApplicationsTable', () => {
let spy

Expand All @@ -30,6 +33,10 @@ describe('LeaseUpApplicationsTable', () => {
})

test('should render succesfully when not loading', () => {
useFlag.mockImplementation(() => true)
useFlagsStatus.mockImplementation(() => ({
flagsError: false
}))
const { asFragment } = render(
<BrowserRouter>
<Provider value={{ applicationsListData: {} }}>
Expand Down
322 changes: 169 additions & 153 deletions spec/vcr/api/v1/lease-ups/applications.yml

Large diffs are not rendered by default.

236 changes: 118 additions & 118 deletions spec/vcr/api/v1/lease-ups/applications_paginated.yml

Large diffs are not rendered by default.

Loading

0 comments on commit 2d134ce

Please sign in to comment.