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

FSADT1-861: BC Service Card form #593

Merged
merged 19 commits into from
Nov 1, 2023
Merged
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
34 changes: 17 additions & 17 deletions backend/src/main/resources/db/migration/V1__initializing_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,16 @@ comment on column nrfc.submission.create_user is 'The user or proxy account that
comment on column nrfc.submission.update_user is 'The user or proxy account that created or last updated the record.';

create table if not exists nrfc.submission_detail (
submission_detail_id integer not null,
submission_id integer not null,
submission_detail_id integer not null,
submission_id integer not null,
client_number varchar(8) null,
business_type_code varchar(1) not null,
incorporation_number varchar(50) null,
business_type_code varchar(1) not null,
incorporation_number varchar(50) null,
organization_name varchar(100) null,
client_type_code varchar(1) not null,
client_type_code varchar(1) not null,
good_standing_ind varchar(1) null,
constraint submission_detail_id_pk primary key (submission_detail_id),
constraint submission_id_fk foreign key (submission_id) references nrfc.submission(submission_id),
constraint submission_detail_id_pk primary key (submission_detail_id),
constraint submission_id_fk foreign key (submission_id) references nrfc.submission(submission_id),
constraint submission_detail_business_type_code_fk foreign key (business_type_code) references nrfc.business_type_code(business_type_code),
constraint submission_detail_client_type_code_fk foreign key (client_type_code) references nrfc.client_type_code(client_type_code)
);
Expand All @@ -235,9 +235,9 @@ comment on column nrfc.submission_detail.client_type_code is 'A code representin
comment on column nrfc.submission_detail.good_standing_ind is 'An indicator that determines whether a client is in good standing with respect to their financial obligations.';

create table if not exists nrfc.submission_matching_detail (
submission_matching_detail_id integer not null,
submission_id integer not null,
matching_fields jsonb null,
submission_matching_detail_id integer not null,
submission_id integer not null,
matching_fields jsonb null,
confirmed_match_status_ind varchar(1) null,
confirmed_match_message varchar(255) null,
confirmed_match_timestamp timestamp null,
Expand All @@ -258,8 +258,8 @@ comment on column nrfc.submission_matching_detail.confirmed_match_userid is 'The
comment on column nrfc.submission_matching_detail.submission_matching_processed is 'A flag to indicate that the submission was finally processed.';

create table if not exists nrfc.submission_location (
submission_location_id integer not null,
submission_id integer not null,
submission_location_id integer not null,
submission_id integer not null,
street_address varchar(50) not null,
country_code varchar(2) not null,
province_code varchar(2) not null,
Expand All @@ -282,11 +282,11 @@ comment on column nrfc.submission_location.city_name is 'The name of the city of
comment on column nrfc.submission_location.location_name is 'The location name of an address. Examples of location names include, but are not limited to, Mailing Address, Billing Address among others.';

create table if not exists nrfc.submission_contact (
submission_contact_id integer not null,
submission_id integer not null,
submission_contact_id integer not null,
submission_id integer not null,
contact_type_code varchar(2) not null,
first_name varchar(100) null,
last_name varchar(100) null,
last_name varchar(100) null,
business_phone_number varchar(20) not null,
email_address varchar(100) not null,
idp_user_id varchar(50) null,
Expand All @@ -306,8 +306,8 @@ comment on column nrfc.submission_contact.email_address is 'The email address of
comment on column nrfc.submission_contact.idp_user_id is 'The unique identifier assigned to a user by the Identity Provider.';

create table if not exists nrfc.submission_location_contact_xref (
submission_location_id integer not null,
submission_contact_id integer not null,
submission_location_id integer not null,
submission_contact_id integer not null,
constraint submission_location_contact_xref_id_pk primary key (submission_location_id, submission_contact_id),
constraint submission_location_id_fk foreign key (submission_location_id) references nrfc.submission_location(submission_location_id),
constraint submission_contact_id_fk foreign key (submission_contact_id) references nrfc.submission_contact(submission_contact_id)
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/forms/TextInputComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ const selectValue = (event: any) => {
<div class="grouping-02" v-if="enabled">
<div class="input-group">
<div class="cds--text-input__label-wrapper">
<label :for="id" class="cds-text-input-label">
<label :id="id + 'Label'"
:for="id"
class="cds-text-input-label">
{{ enabled ? label : null }}
<span v-if="requiredLabel"
class="cds-text-input-required-label">
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/dto/ApplyClientNumberDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export interface ForestClientDetailsDto {
contacts: Contact[];
}

export const locationName = { value: "0", text: "Mailing address" };

export const formDataDto: FormDataDto = {
businessInformation: {
businessType: "",
Expand All @@ -64,7 +66,7 @@ export const formDataDto: FormDataDto = {
location: {
addresses: [
{
locationName: "Mailing address",
locationName: locationName.text,
streetAddress: "",
country: { value: "CA", text: "Canada" },
province: { value: "BC", text: "British Columbia" },
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/helpers/DataConversors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Address, emptyAddress } from "@/dto/ApplyClientNumberDto";
import { type Address, emptyAddress, locationName } from "@/dto/ApplyClientNumberDto";

export const retrieveClientType = (legalType: string): string => {
if (legalType) {
Expand Down Expand Up @@ -38,5 +38,5 @@ export const exportAddress = (addresses: Address[]): Address[] => {
if (addresses && addresses.length > 0) {
return addresses;
}
return [{ ...emptyAddress(), locationName: "Mailing address" }];
return [{ ...emptyAddress(), locationName: locationName.text }];
};
8 changes: 4 additions & 4 deletions frontend/src/pages/FormBCSCPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@

<script setup lang="ts">
import { ref, reactive, computed, watch, getCurrentInstance, toRef } from "vue";
import { newFormDataDto, emptyContact } from "@/dto/ApplyClientNumberDto";
import { newFormDataDto, emptyContact, locationName as defaultLocation } from "@/dto/ApplyClientNumberDto";
import { BusinessTypeEnum, ClientTypeEnum, LegalTypeEnum } from "@/dto/CommonTypesDto";
import { useFetchTo, usePost } from "@/composables/useFetch";
import { useFocus } from "@/composables/useFocus";
Expand All @@ -215,10 +215,9 @@ import { useRouter } from "vue-router";
const { setFocusedComponent } = useFocus();
const errorMessage = ref<string | undefined>("");
const submitterInformation = ForestClientUserSession.user;
console.log(JSON.stringify(submitterInformation));

const submitterContact: Contact = {
locationNames: [{ value: "0", text: "Mailing address" }],
locationNames: [defaultLocation],
contactType: { value: "BL", text: "Billing" },
phoneNumber: "",
firstName: submitterInformation?.firstName ?? "",
Expand Down Expand Up @@ -273,7 +272,7 @@ watch(country, (newValue) => {
country: { value: newValue.value, text: newValue.text },
province: codeConversionFn(formData.businessInformation.address.province),
postalCode: formData.businessInformation.address.postalCode.replace(/\s/g, ""),
locationName: "Mailing address",
locationName: defaultLocation.text,
};

formData.location.addresses.push(formData.businessInformation.address);
Expand All @@ -298,6 +297,7 @@ fetch();
//New contact being added
const otherContacts = computed(() => formData.location.contacts.slice(1));
const addContact = (autoFocus = true) => {
emptyContact.locationNames.push(defaultLocation);
const newLength = formData.location.contacts.push(
JSON.parse(JSON.stringify(emptyContact))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe("<AddressGroupComponent />", () => {

// Wait for the option's inner, standard HTML element to exist before clicking the combo-box
cy.get("#country_0")
.find('cds-combo-box-item[data-id="US"]')
.find('cds-combo-box-item[data-id="CA"]')
.shadow()
.find("div");

Expand All @@ -210,7 +210,7 @@ describe("<AddressGroupComponent />", () => {
.and("have.value", "Canada")
.click();

cy.get("#country_0")
cy.get("#country_0", { timeout: 10000 })
.find('cds-combo-box-item[data-id="US"]')
.should("be.visible")
.click()
Expand Down
114 changes: 57 additions & 57 deletions frontend/tests/unittests/services/ForestClientService.spec.ts
Original file line number Diff line number Diff line change
@@ -1,85 +1,85 @@
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
import { addNewAddress, addNewContact } from '@/services/ForestClientService'
import type { Contact, Address } from '@/dto/ApplyClientNumberDto'
import { describe, it, expect, beforeEach, afterEach } from "vitest";
import { addNewAddress, addNewContact } from "@/services/ForestClientService";
import type { Contact, Address } from "@/dto/ApplyClientNumberDto";

describe('ForestClientService.ts', () => {
describe("ForestClientService.ts", () => {
// create an array of Address and an array of Contact to be used during test and set some random values inside beforeEach and clean it up before the next test

let addresses: Address[]
let contacts: Contact[]
let addresses: Address[];
let contacts: Contact[];

const sampleAddress = {
streetAddress: '2975 Jutland Rd',
streetAddress: "2975 Jutland Rd",
country: {
value: 'CA',
text: 'Canada'
value: "CA",
text: "Canada",
},
province: {
value: 'BC',
text: 'British Columbia'
value: "BC",
text: "British Columbia",
},
city: 'Victoria',
postalCode: 'V8T5J9',
locationName: 'Mailing address'
}
city: "Victoria",
postalCode: "V8T5J9",
locationName: "Mailing address",
};
const sampleContact = {
contactType: {
value: 'P',
text: 'Person'
value: "P",
text: "Person",
},
firstName: 'Jhon',
lastName: 'Wick',
phoneNumber: '(111) 222-3344',
email: '[email protected]',
firstName: "Jhon",
lastName: "Wick",
phoneNumber: "(111) 222-3344",
email: "[email protected]",
locationNames: [
{
value: '0',
text: 'Mailing address'
}
]
}
value: "0",
text: "Mailing address",
},
],
};

beforeEach(() => {
addresses = [sampleAddress]
contacts = [sampleContact]
})
addresses = [sampleAddress];
contacts = [sampleContact];
});

afterEach(() => {
addresses = []
contacts = []
})
addresses = [];
contacts = [];
});

it('add new address and return the result while modifying the original', () => {
const result = addNewAddress(addresses)
it("add new address and return the result while modifying the original", () => {
const result = addNewAddress(addresses);

expect(result).toEqual(2)
expect(result).toEqual(2);
expect(addresses).toStrictEqual([
sampleAddress,
{
locationName: '',
streetAddress: '',
country: { value: '', text: '' },
province: { value: '', text: '' },
city: '',
postalCode: ''
}
])
})
locationName: "",
streetAddress: "",
country: { value: "", text: "" },
province: { value: "", text: "" },
city: "",
postalCode: "",
},
]);
});

it('add new contact and return the result while modifying the original', () => {
const result = addNewContact(contacts)
it("add new contact and return the result while modifying the original", () => {
const result = addNewContact(contacts);

expect(result).toEqual(2)
expect(result).toEqual(2);
expect(contacts).toStrictEqual([
sampleContact,
{
locationNames: [{ value: '', text: '' }],
contactType: { value: '', text: '' },
firstName: '',
lastName: '',
phoneNumber: '',
email: ''
}
])
})
})
locationNames: [{ value: "", text: "" }],
contactType: { value: "", text: "" },
firstName: "",
lastName: "",
phoneNumber: "",
email: "",
},
]);
});
});
Loading