Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests - Applications and Messaging Views #94

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
1,189 changes: 1,153 additions & 36 deletions frontend/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"http-status-codes": "^2.2.0",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"msw": "^2.1.5",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a dev dependency.

"pinia": "^2.1.6",
"regenerator-runtime": "^0.14.0",
"rfdc": "^1.3.0",
Expand Down
32 changes: 12 additions & 20 deletions frontend/src/components/account-mgmt/EditFacilityContacts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,12 @@
density="compact"
variant="outlined"
@update:modelValue="addContact"
:error-messages="errorMessage">
</v-autocomplete>
:error-messages="errorMessage"></v-autocomplete>
</v-col>
</v-row>
<v-row>
<v-col class="pt-2">
<v-data-table
:headers="headers"
:items="sortedContacts"
density="compact">
<v-data-table :headers="headers" :items="sortedContacts" density="compact">
<template v-slot:item.name="{ item }">
{{ `${item.firstName} ${item.lastName}` }}
</template>
Expand Down Expand Up @@ -99,24 +95,24 @@ export default {
},
title: {
type: String,
required: true
required: true,
},
titleInfo: {
type: String,
required: true
required: true,
},
contacts: {
type: Array,
required: true
required: true,
},
contactsForAdd: {
type: Array,
required: true
required: true,
},
atLeastOneContactMandatory: {
type: Boolean,
required: false,
default: false
default: false,
},
},
emits: ['save-contact-updates'],
Expand All @@ -133,13 +129,10 @@ export default {
headers: [
{ title: 'Name', value: 'name', width: '20%' },
{ title: 'Role', value: 'role', width: '30%' },
{ title: '', value: 'actions', width: '50%' }
{ title: '', value: 'actions', width: '50%' },
],
errorMessage: '',
atLeastOneContactRules: [
v => !!v || 'At least one expense authority is required for a facility.',
],

atLeastOneContactRules: [(v) => !!v || 'At least one expense authority is required for a facility.'],
}
},
computed: {
Expand Down Expand Up @@ -201,10 +194,10 @@ export default {
if (!this.contactId) {
return
}
const contactToAdd = this.contactsAvailableForAdd.find(item => item.contactId === this.contactId)
const contactToAdd = this.contactsAvailableForAdd.find((item) => item.contactId === this.contactId)
this.contactsToDisplay.push(contactToAdd)
this.updatedContactsToAdd.push(contactToAdd)
this.contactsAvailableForAdd = this.contactsAvailableForAdd.filter(obj => obj.contactId !== contactToAdd.contactId)
this.contactsAvailableForAdd = this.contactsAvailableForAdd.filter((obj) => obj.contactId !== contactToAdd.contactId)
this.contactId = null
this.removeFocus()
},
Expand All @@ -213,7 +206,7 @@ export default {
* Remove a contact from the list of contacts to display and add to the list of contacts available for add
*/
deleteContact(contact) {
this.contactsToDisplay = this.contactsToDisplay.filter(obj => obj.contactId !== contact.contactId)
this.contactsToDisplay = this.contactsToDisplay.filter((obj) => obj.contactId !== contact.contactId)
this.updatedContactsToRemove.push(contact)
this.contactsAvailableForAdd = [...this.contactsAvailableForAdd, contact]
},
Expand Down Expand Up @@ -257,4 +250,3 @@ export default {
},
}
</script>

6 changes: 3 additions & 3 deletions frontend/src/components/messages/MessagesTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<v-row>
<v-col class="mt-3 ml-3">
<div>
<AppButton variant="text" @click="toggleNewRequestDialog()">
<AppButton id="new-message-button" variant="text" @click="toggleNewRequestDialog()">
<v-icon class="icon" left>mdi-email-plus-outline</v-icon>
<span class="btn-label">New message</span>
</AppButton>
Expand All @@ -28,10 +28,10 @@
</v-skeleton-loader>
</v-col>
<v-col sm="12" md="6">
<RequestConversations :assistanceRequestId="selectedAssistanceRequestId" @toggleMarkUnreadButtonInConversationThread="toggleMarkUnreadButtonInConversationThread" />
<RequestConversations id="request-conversations" :assistanceRequestId="selectedAssistanceRequestId" @toggleMarkUnreadButtonInConversationThread="toggleMarkUnreadButtonInConversationThread" />
</v-col>
</v-row>
<NewRequestDialog class="pa-0" :show="showNewRequestDialog" @close="toggleNewRequestDialog" />
<NewRequestDialog id="new-request-dialog" class="pa-0" :show="showNewRequestDialog" @close="toggleNewRequestDialog" />
</template>

<script>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/notifications/NotificationsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</v-skeleton-loader>
</v-col>
<v-col cols="12" md="6">
<NotificationDetails :notificationId="selectedNotificationId" @toggleMarkUnreadButtonInNotificationDetails="toggleMarkUnreadButtonInNotificationDetails" />
<NotificationDetails id="notification-details" :notificationId="selectedNotificationId" @toggleMarkUnreadButtonInNotificationDetails="toggleMarkUnreadButtonInNotificationDetails" />
</v-col>
</v-row>
</template>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/views/MessagingView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<v-container fluid>
<v-card>
<v-tabs v-model="tab" bg-color="#ffffff" density="compact" color="#003366">
<v-tab value="notifications">
<v-tab id="notifications-tab" value="notifications">
Notifications
<div v-if="unreadNotificationCount > 0">&nbsp;({{ unreadNotificationCount }})</div>
<div id="unread-notifications-count" v-if="unreadNotificationCount > 0">&nbsp;({{ unreadNotificationCount }})</div>
</v-tab>
<v-tab value="messages">
<v-tab id="messages-tab" value="messages">
Messages
<div v-if="unreadMessageCount > 0">&nbsp;({{ unreadMessageCount }})</div>
<div id="unread-messages-count" v-if="unreadMessageCount > 0">&nbsp;({{ unreadMessageCount }})</div>
</v-tab>
<v-tab value="archive">Archive</v-tab>
</v-tabs>
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/views/account-mgmt/ManageUsersView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -292,28 +292,28 @@ export default {

/**
* Get the last expense authority facility names for a user
*/
*/
getLastExpenseAuthoritiesForUser(user) {
// Find target users's facilities that are marked as isExpenseAuthority
const targetFacilities = user.facilities.filter(f => f.isExpenseAuthority) || []
const targetFacilities = user.facilities.filter((f) => f.isExpenseAuthority) || []
// If no facilities with isExpenseAuthority true, return false
if (targetFacilities.length === 0) {
return { isLastExpenseAuthority: false, facilityNames: [] }
}
const lastExpenseAuthorityFacilityNames = []
// Check for each of the target's facilities with isExpenseAuthority true
targetFacilities.forEach(facility => {
targetFacilities.forEach((facility) => {
// Check if any other user has a facility with the same facilityId and isExpenseAuthority true
const hasOtherUserWithAuthority = this.usersAndFacilities.some(userToCheck =>
userToCheck.contactId !== user.contactId &&
userToCheck.facilities.some(f => f.facilityId === facility.facilityId && f.isExpenseAuthority))
const hasOtherUserWithAuthority = this.usersAndFacilities.some(
(userToCheck) => userToCheck.contactId !== user.contactId && userToCheck.facilities.some((f) => f.facilityId === facility.facilityId && f.isExpenseAuthority),
)
if (!hasOtherUserWithAuthority) {
lastExpenseAuthorityFacilityNames.push(facility.facilityName)
}
})
return lastExpenseAuthorityFacilityNames
},
}
},
}
</script>

Expand Down
94 changes: 94 additions & 0 deletions frontend/test/utils/mockResponses/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
export const getLookupInfoResponse = {
requestCategories: [
{
categoryName: 'Intake & Renewal',
categoryId: '1e5bedc2-7377-ee11-8179-000d3a09d132',
},
{
categoryName: 'Reporting',
categoryId: '01839dc9-7377-ee11-8179-000d3a09d132',
},
{
categoryName: 'Account Maintenance',
categoryId: 'a640abcf-7377-ee11-8179-000d3a09d132',
},
{
categoryName: 'Funding Agreement',
categoryId: '1eb0aad5-7377-ee11-8179-000d3a09d132',
},
{
categoryName: 'Payments and Funding',
categoryId: 'aa2ba7e1-7377-ee11-8179-000d3a09d132',
},
{
categoryName: 'Policy Question',
categoryId: '3a2ca7e1-7377-ee11-8179-000d3a09d132',
},
{
categoryName: 'Technical Support',
categoryId: '4f749fe7-7377-ee11-8179-000d3a09d132',
},
{
categoryName: 'Other',
categoryId: '64ce97ed-7377-ee11-8179-000d3a09d132',
},
],
userRoles: [
{
id: 1,
description: 'Admin',
},
{
id: 2,
description: 'Account Management',
},
{
id: 3,
description: 'Financial',
},
{
id: 4,
description: 'Reporting',
},
],
healthAuthorities: [
{
id: 1,
description: 'Fraser Health',
},
{
id: 2,
description: 'Interior Health',
},
{
id: 3,
description: 'Island Health',
},
{
id: 4,
description: 'Northern Health',
},
{
id: 5,
description: 'Vancouver Coastal Health',
},
],
facilityTypes: [
{
id: 1,
description: 'Rent/Lease',
},
{
id: 2,
description: 'Owned With Mortgage',
},
{
id: 3,
description: 'Owned Without Mortgage',
},
{
id: 4,
description: 'Provided Free of Charge',
},
],
}
81 changes: 81 additions & 0 deletions frontend/test/utils/mockResponses/applications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
export const getApplicationsResponse = [
{
applicationId: '128b9ba9-be9e-ee11-a569-000d3a09d132',
referenceNumber: 'APP-23000066',
submittedDate: null,
ministryLastUpdated: '2023-12-22T20:40:48Z',
providerLastUpdated: '2023-12-22T20:35:45Z',
facilityId: 'c9ecef6c-437d-ee11-8179-000d3a09d132',
facilityName: 'Test OFM - Facility Number 1',
statusCode: 1,
stateCode: 0,
status: 'Draft',
latestActivity: '2023-12-22T20:40:48.000Z',
},
{
applicationId: 'c8609cc5-0fa1-ee11-a569-000d3a09d499',
referenceNumber: 'APP-23000070',
submittedDate: null,
ministryLastUpdated: null,
providerLastUpdated: '2023-12-22T21:19:21Z',
facilityId: 'c9ecef6c-437d-ee11-8179-000d3a09d132',
facilityName: 'Test OFM - Facility Number 1',
statusCode: 1,
stateCode: 0,
status: 'Draft',
latestActivity: '2023-12-22T21:19:21.000Z',
},
{
applicationId: 'b2b7f374-2995-ee11-be37-000d3a09d4d4',
referenceNumber: 'APP-23000031',
submittedDate: '2023-12-19T18:07:38Z',
ministryLastUpdated: '2023-12-19T18:07:38Z',
providerLastUpdated: null,
facilityId: 'c9ecef6c-437d-ee11-8179-000d3a09d132',
facilityName: 'Test OFM - Facility Number 1',
statusCode: 3,
stateCode: 0,
status: 'Submitted',
latestActivity: '2023-12-19T18:07:38.000Z',
},
]

export const getApplicationResponse = {
applicationId: 'b2b7f374-2995-ee11-be37-000d3a09d4d4',
referenceNumber: 'APP-23000031',
submittedDate: null,
ministryLastUpdated: null,
providerLastUpdated: '2024-01-31T20:00:58Z',
facilityId: 'c9ecef6c-437d-ee11-8179-000d3a09d132',
facilityName: 'Test OFM - Facility Number 1',
statusCode: 1,
stateCode: 0,
status: 'Draft',
staffingInfantECEducatorFullTime: 1,
staffingInfantECEducatorPartTime: 2,
staffingECEducatorFullTime: 3,
staffingECEducatorPartTime: 4,
staffingECEducatorAssistantFullTime: 5,
staffingECEducatorAssistantPartTime: 6,
staffingResponsibleAdultFullTime: 7,
staffingResponsibleAdultPartTime: 8,
primaryContactId: '7e35f2ba-9fb1-ee11-a569-000d3a09d4d4',
secondaryContactId: 'b4cc209f-edab-ee11-a569-000d3a09d699',
providerType: 1,
ownership: 2,
facilityType: 1,
insuranceCost: 0.3,
upkeepLabourCost: 4.13,
suppliesCost: 6.11,
utilitiesCost: 1.44,
maintenanceRepairsCost: 5.12,
furnitureEquipmentsCost: 1.46,
totalYearlyOperatingCosts: 18.56,
rentLeaseCost: 0,
mortgageCost: 0,
propertyTax: 0,
strataFee: 0,
applicableFee: 0,
totalYearlyFacilityCosts: 0,
latestActivity: '2024-01-31T20:00:58.000Z',
}
Loading