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

166 report-level memo initial dev/local testing #407

Merged
merged 14 commits into from
Jul 28, 2022
1,335 changes: 698 additions & 637 deletions front-end/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions front-end/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"@ngrx/effects": "^13.0.2",
"@ngrx/store": "^13.0.2",
"@popperjs/core": "^2.10.2",
"bootstrap": "^5.1.3",
"bootstrap": "5.1.3",
"class-transformer": "^0.5.1",
"fecfile-validate": "https://github.com/fecgov/fecfile-validate#38542f53467786340e85d70a8b6f90876eb51e1e",
"fecfile-validate": "https://github.com/fecgov/fecfile-validate#a7d7568e5942c6177b1c5ccf6edbe2e74e6aa245",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21",
"luxon": "^2.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class MenuReportComponent implements OnInit, OnDestroy {
/^\/transactions\/report\/\d+\/create/, // Enter a transaction group
/^\/reports\/f3x\/summary\/\d+/, // Review a report group
/^\/reports\/f3x\/detailed-summary\/\d+/, // Review a report group
/^\/reports\/f3x\/memo\/\d+/, // Review a report group
/^\/reports\/f3x\/submit\/step1\/\d+/, // Submit your report group
/^\/reports\/f3x\/submit\/step2\/\d+/, // Submit your report group
/^\/reports\/f3x\/submit\/status\/\d+/, // Submit your report group
Expand Down Expand Up @@ -65,53 +66,59 @@ export class MenuReportComponent implements OnInit, OnDestroy {
// regular expressions in the matchUrl array.
this.showMenu = this.isActive(this.urlMatch, event.url);

if (this.showMenu && this.activeReport && this.activeReport.id !== this.currentReportId) {
this.currentReportId = this.activeReport.id;
if (this.showMenu && this.activeReport) {
if (this.activeReport.id !== this.currentReportId) {
this.currentReportId = this.activeReport.id;

this.items = [
{
label: 'ENTER A TRANSACTION',
expanded: this.isActive(this.urlMatch.slice(0, 1), event.url),
items: [
{
label: 'Manage your transactions',
routerLink: [`/reports/f3x/create/step3/${this.currentReportId}`],
},
{
label: 'Add a receipt',
routerLink: [`/transactions/report/${this.currentReportId}/create`],
},
{ label: 'Add a disbursements', styleClass: 'menu-item-disabled' },
{ label: 'Add loans and debts', styleClass: 'menu-item-disabled' },
{ label: 'Add other transactions', styleClass: 'menu-item-disabled' },
],
},
{
label: 'REVIEW A REPORT',
expanded: this.isActive(this.urlMatch.slice(2, 3), event.url),
items: [
{
label: 'View summary page',
routerLink: [`/reports/f3x/summary/${this.currentReportId}`],
},
{
label: 'View detailed summary page',
routerLink: [`/reports/f3x/detailed-summary/${this.currentReportId}`],
},
{ label: 'View print preview', styleClass: 'menu-item-disabled' },
{ label: 'Add a report level memo', styleClass: 'menu-item-disabled' },
],
},
{
label: 'SUBMIT YOUR REPORT',
expanded: this.isActive(this.urlMatch.slice(4, 6), event.url),
items: [
{ label: 'Confirm information', routerLink: [`/reports/f3x/submit/step1/${this.currentReportId}`] },
{ label: 'Submit report', routerLink: [`/reports/f3x/submit/step2/${this.currentReportId}`] },
{ label: 'Report status', routerLink: [`/reports/f3x/submit/status/${this.currentReportId}`] },
],
},
];
this.items = [
{
label: 'ENTER A TRANSACTION',
expanded: false,
items: [
{
label: 'Manage your transactions',
routerLink: [`/reports/f3x/create/step3/${this.currentReportId}`],
},
{
label: 'Add a receipt',
routerLink: [`/transactions/report/${this.currentReportId}/create`],
},
{ label: 'Add a disbursements', styleClass: 'menu-item-disabled' },
{ label: 'Add loans and debts', styleClass: 'menu-item-disabled' },
{ label: 'Add other transactions', styleClass: 'menu-item-disabled' },
],
},
{
label: 'REVIEW A REPORT',
expanded: false,
items: [
{
label: 'View summary page',
routerLink: [`/reports/f3x/summary/${this.currentReportId}`],
},
{
label: 'View detailed summary page',
routerLink: [`/reports/f3x/detailed-summary/${this.currentReportId}`],
},
{ label: 'View print preview', styleClass: 'menu-item-disabled' },
{ label: 'Add a report level memo', routerLink: [`/reports/f3x/memo/${this.currentReportId}`] },
],
},
{
label: 'SUBMIT YOUR REPORT',
expanded: false,
items: [
{ label: 'Confirm information', routerLink: [`/reports/f3x/submit/step1/${this.currentReportId}`] },
{ label: 'Submit report', routerLink: [`/reports/f3x/submit/step2/${this.currentReportId}`] },
{ label: 'Report status', routerLink: [`/reports/f3x/submit/status/${this.currentReportId}`] },
],
},
];
}

this.items[0].expanded = this.isActive(this.urlMatch.slice(0, 2), event.url);
this.items[1].expanded = this.isActive(this.urlMatch.slice(2, 5), event.url);
this.items[2].expanded = this.isActive(this.urlMatch.slice(5, 8), event.url);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<div class="p-fluid">
<div class="summary-header">
<h1>Report level memo</h1>
<div>
<strong>FORM 3X:</strong>
{{ (this.reportCodeLabelList$ | async | findOnReportCodePipe: report.report_code)?.label }}
</div>
</div>

<form id="form" [formGroup]="form" [ngClass]="{ 'ng-submitted': formSubmitted }">
<div class="grid">
<div class="col-11">
<label for="{{ text4kFormProperty }}"><strong>ENTER A MEMO RELATED TO THIS FORM 3X</strong> (OPTIONAL)</label>
<div>
<textarea
id="{{ text4kFormProperty }}"
[rows]="20"
[cols]="30"
pInputTextarea
[autoResize]="true"
formControlName="{{ text4kFormProperty }}"
></textarea>
<app-error-messages
[form]="form"
fieldName="{{ text4kFormProperty }}"
[formSubmitted]="formSubmitted"
></app-error-messages>
</div>
</div>
</div>

<div class="grid">
<div class="col-4">
<div>
<button
pButton
pRipple
label="Back"
class="p-button-secondary"
(click)="router.navigateByUrl('/reports/f3x/memo/' + report.id)"
></button>
</div>
<div class="button-message">PREVIOUS: PRINT PREVIEW</div>
</div>
<div class="col-4"></div>
<div class="col-4 align-right">
<div>
<button pButton pRipple label="Save & continue" class="p-button-primary" (click)="save()"></button>
</div>
<div class="button-message">NEXT: SUBMIT YOUR REPORT</div>
</div>
</div>
</form>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormBuilder, FormControl, ReactiveFormsModule } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { provideMockStore } from '@ngrx/store/testing';
import { F3xSummary } from 'app/shared/models/f3x-summary.model';
import { MemoText } from 'app/shared/models/memo-text.model';
import { MemoTextService } from 'app/shared/services/memo-text.service';
import { SharedModule } from 'app/shared/shared.module';
import { selectReportCodeLabelList } from 'app/store/label-lookup.selectors';
import { Message, MessageService } from 'primeng/api';
import { ButtonModule } from 'primeng/button';
import { CardModule } from 'primeng/card';
import { InputTextareaModule } from 'primeng/inputtextarea';
import { ToastModule } from 'primeng/toast';
import { of } from 'rxjs';
import { ReportLevelMemoComponent } from './report-level-memo.component';

describe('ReportLevelMemoComponent', () => {
let component: ReportLevelMemoComponent;
let fixture: ComponentFixture<ReportLevelMemoComponent>;
let testMemoTextService: MemoTextService;
let testMessageService: MessageService;
let testRouter: Router;
const f3x: F3xSummary = F3xSummary.fromJSON({
id: 999,
coverage_from_date: '2022-05-25',
form_type: 'F3XN',
report_code: 'Q1',
});

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
HttpClientTestingModule,
SharedModule,
CardModule,
ToastModule,
ReactiveFormsModule,
ButtonModule,
InputTextareaModule,
RouterTestingModule.withRoutes([]),
],
declarations: [ReportLevelMemoComponent],
providers: [
MessageService,
MemoTextService,
FormBuilder,
provideMockStore({
selectors: [{ selector: selectReportCodeLabelList, value: {} }],
}),
{
provide: ActivatedRoute,
useValue: {
snapshot: {
data: {
report: f3x,
},
},
},
},
],
}).compileComponents();
});

beforeEach(() => {
testRouter = TestBed.inject(Router);
testMemoTextService = TestBed.inject(MemoTextService);
testMessageService = TestBed.inject(MessageService);
fixture = TestBed.createComponent(ReportLevelMemoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
const testText4kValue = 'testText4k';
const testMemoText: MemoText = new MemoText();
testMemoText.id = 4;
testMemoText.report_id = 123;
testMemoText.rec_type = 'test_rec_type';
testMemoText.filer_committee_id_number = 'test_fcin';
testMemoText.transaction_id_number = 'test_tin';
testMemoText.back_reference_tran_id_number = 'test_brtin';
testMemoText.back_reference_sched_form_name = 'test_brsfn';
testMemoText.text4000 = 'test_text4k';
component.form.addControl('text4000', new FormControl());
component.form.get('text4000')?.setValue(testText4kValue);
spyOn(testMemoTextService, 'getForReportId').and.returnValue(of([testMemoText]));
component.ngOnInit();
expect(component).toBeTruthy();
});

it('save for existing memo text happy path', () => {
const expectedMessage: Message = {
severity: 'success',
summary: 'Successful',
detail: 'Report Memo Updated',
life: 3000,
};
const testMemoTextServiceSpy = spyOn(testMemoTextService, 'update').and.returnValue(of(new MemoText()));
const navigateSpy = spyOn(testRouter, 'navigateByUrl');
const testMessageServiceSpy = spyOn(testMessageService, 'add');
component.assignedMemoText.id = 1;
component.save();
expect(testMemoTextServiceSpy).toHaveBeenCalledTimes(1);
expect(navigateSpy).toHaveBeenCalledWith('/reports/f3x/submit/step1/999');
expect(testMessageServiceSpy).toHaveBeenCalledOnceWith(expectedMessage);
});

it('save for new memo text happy path', () => {
const expectedMessage: Message = {
severity: 'success',
summary: 'Successful',
detail: 'Report Memo Created',
life: 3000,
};
const testMemoTextServiceSpy = spyOn(testMemoTextService, 'create').and.returnValue(of(new MemoText()));
const navigateSpy = spyOn(testRouter, 'navigateByUrl');
const testMessageServiceSpy = spyOn(testMessageService, 'add');
component.assignedMemoText.id = null;
component.save();
expect(testMemoTextServiceSpy).toHaveBeenCalledTimes(1);
expect(navigateSpy).toHaveBeenCalledWith('/reports/f3x/submit/step1/999');
expect(testMessageServiceSpy).toHaveBeenCalledOnceWith(expectedMessage);
});
});
Loading