Skip to content

Commit

Permalink
Merge pull request #573 from fecgov/feature/uuid-ids
Browse files Browse the repository at this point in the history
Feature/UUID ids
  • Loading branch information
toddlees authored Sep 19, 2022
2 parents a2d00c3 + 54a26e2 commit 112a217
Show file tree
Hide file tree
Showing 48 changed files with 111 additions and 119 deletions.
2 changes: 1 addition & 1 deletion front-end/cypress/support/contacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function deleteAllContacts() {
}

//Deletes a single report by its ID
export function deleteContact(contactID: number, authToken: string | null = null) {
export function deleteContact(contactID: string, authToken: string | null = null) {
if (authToken == null) {
authToken = getAuthToken();
}
Expand Down
2 changes: 1 addition & 1 deletion front-end/cypress/support/reports.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export function deleteAllReports() {
}

//Deletes a single report by its ID
export function deleteReport(reportID: number, authToken: string | null = null) {
export function deleteReport(reportID: string, authToken: string | null = null) {
if (authToken == null) {
authToken = getAuthToken();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('ContactDetailComponent', () => {
});

it('#saveItem should update an existing contact record', () => {
component.contact.id = 10;
component.contact.id = '10';
component.form.patchValue({ ...contact });
component.saveItem(true);
const req = httpTestingController.expectOne(`${environment.apiUrl}/contacts/10/`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('MenuReportComponent', () => {

it('should navigate to menu', () => {
router.navigateByUrl('/transactions/report/999/list');
expect(component.activeReport?.id).toBe(999);
expect(component.activeReport?.id).toBe('999');
});

it('should determine an active url', () => {
Expand All @@ -55,7 +55,7 @@ describe('MenuReportComponent', () => {

it('should process a NavigationEnd event', () => {
component.items = [];
component.currentReportId = 888;
component.currentReportId = '888';
component.handleNavigationEvent({ url: '/transactions/report/999/list' } as NavigationEnd);
expect(component.items.length).toBe(3);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ReportService } from '../../../shared/services/report.service';
})
export class MenuReportComponent implements OnInit, OnDestroy {
activeReport: Report | null = null;
currentReportId: number | undefined;
currentReportId: string | undefined;
currentReportTimestamp: number | null = null;
items: MenuItem[] = [];
showMenu = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('CashOnHandComponent', () => {
});

it('should save', () => {
const f3x = F3xSummary.fromJSON({ id: 999 });
const f3x = F3xSummary.fromJSON({ id: '999' });
spyOn(f3xSummaryService, 'update').and.returnValue(of(f3x));
const navigateSpy = spyOn(router, 'navigateByUrl');
component.report = f3x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('CreateF3XStep1Component', () => {
let f3xSummaryService: F3xSummaryService;
let reportService: ReportService;
const f3x: F3xSummary = F3xSummary.fromJSON({
id: 999,
id: '999',
coverage_from_date: '2022-05-25',
coverage_through_date: '2022-06-25',
form_type: 'F3XN',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('ReportDetailedSummaryComponent', () => {
let component: ReportDetailedSummaryComponent;
let fixture: ComponentFixture<ReportDetailedSummaryComponent>;
const f3x: F3xSummary = F3xSummary.fromJSON({
id: 999,
id: '999',
coverage_from_date: '2022-05-25',
form_type: 'F3XN',
report_code: 'Q1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ReportLevelMemoComponent', () => {
let testMessageService: MessageService;
let testRouter: Router;
const f3x: F3xSummary = F3xSummary.fromJSON({
id: 999,
id: '999',
coverage_from_date: '2022-05-25',
form_type: 'F3XN',
report_code: 'Q1',
Expand Down Expand Up @@ -72,8 +72,8 @@ describe('ReportLevelMemoComponent', () => {
it('should create', () => {
const testText4kValue = 'testText4k';
const testMemoText: MemoText = new MemoText();
testMemoText.id = 4;
testMemoText.report_id = 123;
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';
Expand All @@ -97,7 +97,7 @@ describe('ReportLevelMemoComponent', () => {
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.assignedMemoText.id = '1';
component.save();
expect(testMemoTextServiceSpy).toHaveBeenCalledTimes(1);
expect(navigateSpy).toHaveBeenCalledWith('/reports/f3x/submit/step1/999');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('ReportSummaryComponent', () => {
let component: ReportSubmissionStatusComponent;
let fixture: ComponentFixture<ReportSubmissionStatusComponent>;
const f3x: F3xSummary = F3xSummary.fromJSON({
id: 999,
id: '999',
coverage_from_date: '2022-05-25',
form_type: 'F3XN',
report_code: 'Q1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('SubmitF3xStep2Component', () => {
data: {
report: F3xSummary.fromJSON({
report_code: 'Q1',
id: 999,
id: '999',
}),
},
},
Expand All @@ -68,7 +68,7 @@ describe('SubmitF3xStep2Component', () => {
reportService = TestBed.inject(F3xSummaryService);
fixture = TestBed.createComponent(SubmitF3xStep2Component);
component = fixture.componentInstance;
spyOn(reportService, 'get').and.returnValue(of(F3xSummary.fromJSON({ id: 999 })));
spyOn(reportService, 'get').and.returnValue(of(F3xSummary.fromJSON({ id: '999' })));
fixture.detectChanges();
});

Expand All @@ -77,7 +77,7 @@ describe('SubmitF3xStep2Component', () => {
});

it("should set the default form values with the committee's values", () => {
component.report = F3xSummary.fromJSON({ id: 999 });
component.report = F3xSummary.fromJSON({ id: '999' });
const testCommitteeAccount = CommitteeAccount.fromJSON({
treasurer_name_1: 'Test',
treasurer_name_2: 'McTest',
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('SubmitF3xStep2Component', () => {

it("should catch when there's no change in Treasurer Name", () => {
component.report = F3xSummary.fromJSON({
id: 999,
id: '999',
treasurer_last_name: 'McTest',
treasurer_first_name: 'Test',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('ReportListComponent', () => {
it('#editItem should route properly', () => {
const navigateSpy = spyOn(router, 'navigateByUrl');

component.editItem({ id: 999 } as F3xSummary);
component.editItem({ id: '999' } as F3xSummary);
expect(navigateSpy).toHaveBeenCalledWith('/reports/f3x/create/cash-on-hand/999');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class TestTransactionTypeBaseComponent extends TransactionTypeBaseComponent {
}

const testTransaction = {
id: 123,
report_id: 999,
id: '123',
report_id: '999',
form_type: null,
filer_committee_id_number: null,
transaction_id: null,
Expand Down Expand Up @@ -105,7 +105,7 @@ describe('TransactionTypeBaseComponent', () => {

it('#save should navigate for update', () => {
const testTransaction2: Transaction = {
id: 123,
id: '123',
report_id: null,
form_type: null,
filer_committee_id_number: null,
Expand All @@ -117,7 +117,7 @@ describe('TransactionTypeBaseComponent', () => {
spyOn(testTransactionService, 'update').and.returnValue(of(testTransaction2));
const componentNavigateToSpy = spyOn(component, 'navigateTo');
component.transaction = {
id: 123,
id: '123',
report_id: null,
form_type: null,
filer_committee_id_number: null,
Expand All @@ -144,7 +144,7 @@ describe('TransactionTypeBaseComponent', () => {
});

it("#navigateTo 'add-sub-tran' should show popup + navigate", () => {
const testTransactionId = 1;
const testTransactionId = '1';
const testTransactionTypeToAdd = 'testTransactionTypeToAdd';

component.transaction = testTransaction;
Expand All @@ -167,8 +167,8 @@ describe('TransactionTypeBaseComponent', () => {

it("#navigateTo 'list' should navigate", () => {
const testTransaction3: Transaction = {
id: 123,
report_id: 99,
id: '123',
report_id: '99',
form_type: null,
filer_committee_id_number: null,
transaction_id: null,
Expand All @@ -187,13 +187,13 @@ describe('TransactionTypeBaseComponent', () => {
component.transaction = testTransaction;
const expectedRoute = '/transactions/report/999/list/edit/123/create-sub-transaction/INDV_REC';
const routerNavigateByUrlSpy = spyOn(testRouter, 'navigateByUrl');
component.navigateTo('add-sub-tran', 123, 'INDV_REC');
component.navigateTo('add-sub-tran', '123', 'INDV_REC');
expect(routerNavigateByUrlSpy).toHaveBeenCalledOnceWith(expectedRoute);
});

it("#navigateTo 'to-parent' should navigate", () => {
component.transaction = { ...testTransaction };
component.transaction.parent_transaction_id = 333;
component.transaction.parent_transaction_id = '333';
const expectedRoute = '/transactions/report/999/list/edit/333';
const routerNavigateByUrlSpy = spyOn(testRouter, 'navigateByUrl');
component.navigateTo('to-parent');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export abstract class TransactionTypeBaseComponent implements OnInit, OnDestroy

navigateTo(
navigateTo: 'list' | 'add another' | 'add-sub-tran' | 'to-parent',
transactionId?: number,
transactionId?: string,
transactionTypeToAdd?: string
) {
if (navigateTo === 'add another') {
Expand Down
2 changes: 1 addition & 1 deletion front-end/src/app/shared/guards/cash-on-hand.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class CashOnHandGuard implements CanActivate {
canActivate(route: ActivatedRouteSnapshot): Observable<boolean> {
return this.store.select(selectCashOnHand).pipe(
map((cashOnHand: CashOnHand) => {
const reportId = Number(route.paramMap.get('reportId'));
const reportId = String(route.paramMap.get('reportId'));
if (reportId !== null) {
return reportId === cashOnHand.report_id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
describe('ReportIsEditableGuard', () => {
let guard: ReportIsEditableGuard;
const mockRoute = {
paramMap: convertToParamMap({ reportId: 999 }),
paramMap: convertToParamMap({ reportId: '999' }),
} as ActivatedRouteSnapshot;

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class ReportIsEditableGuard implements CanActivate {
constructor(private reportService: ReportService) {}

canActivate(route: ActivatedRouteSnapshot): Observable<boolean> {
const reportId = Number(route.paramMap.get('reportId'));
const reportId = String(route.paramMap.get('reportId'));
if (reportId !== null) {
return this.reportService
.setActiveReportById(reportId)
Expand Down
4 changes: 2 additions & 2 deletions front-end/src/app/shared/interfaces/report.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { WebPrintSubmission } from '../models/webprint-submission.model';
import { UploadSubmission } from '../models/upload-submission.model';

export interface Report {
id: number | undefined;
id: string | undefined;
form_type: string;
filer_committee_id_number: string | null;
report_code: F3xReportCode | null;
Expand All @@ -17,6 +17,6 @@ export interface Report {
}

export interface CashOnHand {
report_id: number | undefined;
report_id: string | undefined;
value: number | null;
}
6 changes: 3 additions & 3 deletions front-end/src/app/shared/interfaces/transaction.interface.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export interface Transaction {
id: number | null;
report_id: number | null;
id: string | null;
report_id: string | null;
form_type: string | null;
filer_committee_id_number: string | null;
transaction_id: string | null;
transaction_type_identifier: string | null;
contribution_purpose_descrip: string | null;
parent_transaction_id: number | null;
parent_transaction_id: string | null;
}
15 changes: 6 additions & 9 deletions front-end/src/app/shared/models/contact.model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,26 @@ describe('Contact', () => {

it('#fromJSON() should return a populated Contact class', () => {
const data = {
id: 999,
id: '999',
type: ContactTypes.COMMITTEE,
name: 'foo',
};
const contact: Contact = Contact.fromJSON(data);
expect(contact).toBeInstanceOf(Contact);
expect(contact.id).toBe(999);
expect(contact.id).toBe('999');
expect(contact.type).toBe(ContactTypes.COMMITTEE);
expect(contact.name).toBe('foo');
expect(contact.occupation).toBe(null);
});

it('#fromJSON() should return a populated FecCommitteeLookupData class', () => {
const data = {
id: "C123",
id: 'C123',
name: 'foo',
};
const fecCommitteeLookupData: FecCommitteeLookupData =
FecCommitteeLookupData.fromJSON(data);
expect(fecCommitteeLookupData).toBeInstanceOf(
FecCommitteeLookupData);
expect(fecCommitteeLookupData.id).toBe("C123");
const fecCommitteeLookupData: FecCommitteeLookupData = FecCommitteeLookupData.fromJSON(data);
expect(fecCommitteeLookupData).toBeInstanceOf(FecCommitteeLookupData);
expect(fecCommitteeLookupData.id).toBe('C123');
expect(fecCommitteeLookupData.name).toBe('foo');
});

});
2 changes: 1 addition & 1 deletion front-end/src/app/shared/models/contact.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const CandidateOfficeTypeLabels = [
];

export class Contact extends BaseModel {
id: number | null = null;
id: string | null = null;
type: ContactType = ContactTypes.INDIVIDUAL;
candidate_id: string | null = null;
committee_id: string | null = null;
Expand Down
4 changes: 2 additions & 2 deletions front-end/src/app/shared/models/f3x-summary.model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ describe('F3XSummary', () => {

it('#fromJSON() should return a populated F3xSummary instance', () => {
const data = {
id: 999,
id: '999',
form_type: F3xFormTypes.F3XT,
committee_name: 'foo',
};
const f3xSummary: F3xSummary = F3xSummary.fromJSON(data);
expect(f3xSummary).toBeInstanceOf(F3xSummary);
expect(f3xSummary.id).toBe(999);
expect(f3xSummary.id).toBe('999');
expect(f3xSummary.form_type).toBe(F3xFormTypes.F3XT);
expect(f3xSummary.committee_name).toBe('foo');
expect(f3xSummary.election_code).toBe(null);
Expand Down
2 changes: 1 addition & 1 deletion front-end/src/app/shared/models/f3x-summary.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class F3xCoverageDates {
}

export class F3xSummary extends BaseModel implements Report {
id: number | undefined;
id: string | undefined;

form_type: F3xFormType = F3xFormTypes.F3XT;
filer_committee_id_number: string | null = null;
Expand Down
8 changes: 4 additions & 4 deletions front-end/src/app/shared/models/memo-text.model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ describe('MemoText', () => {

it('#fromJSON() should return a populated MemoText class', () => {
const data = {
id: 999,
report_id: 123,
id: '999',
report_id: '123',
rec_type: 'test_rec_type',
text4000: 'test_text',
};
const memoText: MemoText = MemoText.fromJSON(data);
expect(memoText).toBeInstanceOf(MemoText);
expect(memoText.id).toBe(999);
expect(memoText.report_id).toBe(123);
expect(memoText.id).toBe('999');
expect(memoText.report_id).toBe('123');
expect(memoText.rec_type).toBe('test_rec_type');
expect(memoText.text4000).toBe('test_text');
});
Expand Down
Loading

0 comments on commit 112a217

Please sign in to comment.