Skip to content

Commit

Permalink
Add support for geometry tasks in submission details view
Browse files Browse the repository at this point in the history
  • Loading branch information
amysorto committed Feb 2, 2024
1 parent 613c9e5 commit bc835d4
Show file tree
Hide file tree
Showing 7 changed files with 299 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {LocationOfInterest} from 'app/models/loi.model';
import {Survey} from 'app/models/survey.model';
import {AuthService} from 'app/services/auth/auth.service';
import {LocationOfInterestService} from 'app/services/loi/loi.service';
import {NavigationService} from 'app/services/navigation/navigation.service';
import {SurveyService} from 'app/services/survey/survey.service';

import {SurveyLoiComponent} from './survey-loi.component';
Expand All @@ -42,6 +43,7 @@ describe('SurveyLoiComponent', () => {
let component: SurveyLoiComponent;

let loiServiceSpy: jasmine.SpyObj<LocationOfInterestService>;
let navigationServiceSpy: jasmine.SpyObj<NavigationService>;
let surveyServiceSpy: jasmine.SpyObj<SurveyService>;

const mockLois$ = new BehaviorSubject<List<LocationOfInterest>>(
Expand All @@ -60,13 +62,23 @@ describe('SurveyLoiComponent', () => {
['getLocationsOfInterest$', 'getLoisWithLabels$']
);

navigationServiceSpy = jasmine.createSpyObj<NavigationService>(
'NavigationService',
['getLocationOfInterestId$', 'getSubmissionId$']
);

surveyServiceSpy = jasmine.createSpyObj<SurveyService>('SurveyService', [
'getActiveSurvey',
'getActiveSurvey$',
'canManageSurvey',
]);

loiServiceSpy.getLoisWithLabels$.and.returnValue(mockLois$);

navigationServiceSpy.getSubmissionId$.and.returnValue(
of<string | null>(null)
);

surveyServiceSpy.canManageSurvey.and.returnValue(true);
surveyServiceSpy.getActiveSurvey.and.returnValue(mockSurvey);
surveyServiceSpy.getActiveSurvey$.and.returnValue(mockSurvey$);
Expand All @@ -79,6 +91,7 @@ describe('SurveyLoiComponent', () => {
{provide: AngularFireAuth, useValue: {}},
{provide: AuthService, useValue: {}},
{provide: LocationOfInterestService, useValue: loiServiceSpy},
{provide: NavigationService, useValue: navigationServiceSpy},
{provide: SurveyService, useValue: surveyServiceSpy},
{provide: MatDialog, useValue: {}},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
tick,
waitForAsync,
} from '@angular/core/testing';
import {AngularFireAuth} from '@angular/fire/compat/auth';
import {AngularFirestore} from '@angular/fire/compat/firestore';
import {GoogleMapsModule} from '@angular/google-maps';
import {List, Map} from 'immutable';
import {BehaviorSubject, of} from 'rxjs';
Expand All @@ -33,14 +35,18 @@ import {
GenericLocationOfInterest,
LocationOfInterest,
} from 'app/models/loi.model';
import {Submission} from 'app/models/submission/submission.model';
import {Survey} from 'app/models/survey.model';
import {AuthService} from 'app/services/auth/auth.service';
import {
DrawingToolsService,
EditMode,
} from 'app/services/drawing-tools/drawing-tools.service';
import {GroundPinService} from 'app/services/ground-pin/ground-pin.service';
import {LoadingState} from 'app/services/loading-state.model';
import {LocationOfInterestService} from 'app/services/loi/loi.service';
import {NavigationService} from 'app/services/navigation/navigation.service';
import {SubmissionService} from 'app/services/submission/submission.service';
import {SurveyService} from 'app/services/survey/survey.service';
import {polygonShellCoordsToPolygon} from 'testing/helpers';

Expand All @@ -54,6 +60,7 @@ describe('MapComponent', () => {
let loiServiceSpy: jasmine.SpyObj<LocationOfInterestService>;
let mockLocationOfInterestId$: BehaviorSubject<string | null>;
let navigationServiceSpy: jasmine.SpyObj<NavigationService>;
let submissionServiceSpy: jasmine.SpyObj<SubmissionService>;
let mockEditMode$: BehaviorSubject<EditMode>;
let drawingToolsServiceSpy: jasmine.SpyObj<DrawingToolsService>;

Expand Down Expand Up @@ -174,6 +181,7 @@ describe('MapComponent', () => {
'getSubmissionId$',
'selectLocationOfInterest',
'clearLocationOfInterestId',
'showSubmissionDetailWithHighlightedTask',
]
);
mockLocationOfInterestId$ = new BehaviorSubject<string | null>(null);
Expand All @@ -184,6 +192,14 @@ describe('MapComponent', () => {
of<string | null>(null)
);

submissionServiceSpy = jasmine.createSpyObj<SubmissionService>(
'SubmissionService',
['getSelectedSubmission$']
);
submissionServiceSpy.getSelectedSubmission$.and.returnValue(
new BehaviorSubject<Submission | LoadingState>(LoadingState.LOADING)
);

mockEditMode$ = new BehaviorSubject<EditMode>(EditMode.None);
drawingToolsServiceSpy = jasmine.createSpyObj<DrawingToolsService>(
'DrawingToolsService',
Expand All @@ -202,7 +218,20 @@ describe('MapComponent', () => {
useValue: loiServiceSpy,
},
{provide: NavigationService, useValue: navigationServiceSpy},
{provide: SubmissionService, useValue: submissionServiceSpy},
{provide: DrawingToolsService, useValue: drawingToolsServiceSpy},
{provide: AuthService, useValue: {}},
{
provide: AngularFireAuth,
useValue: {
authState: of({
displayName: null,
isAnonymous: true,
uid: '',
}),
},
},
{provide: AngularFirestore, useValue: {}},
],
}).compileComponents();
}));
Expand Down
Loading

0 comments on commit bc835d4

Please sign in to comment.