Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
5 changes: 3 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"build": "ng build -c $npm_config_config",
"postbuild": "npm run --prefix scripts copy-asset-links",
"build-all": "npm run build-local-deps && npm run build",
"build-and-test": "npm run build && npm run test",
"build-all-and-test": "npm run build-all && npm run test",
"build-and-test": "npm run build --config=local && npm run test",
"build-all-and-test": "npm run build-all --config=local && npm run test",
"build-all-and-test-headless": "npm run build-all --config=local && npm run test-headless",
"watch": "npm run build -- --watch",
"start": "ng serve -c $npm_config_config",
"build-and-start": "npm run build && npm run start",
Expand Down
2 changes: 1 addition & 1 deletion web/scripts/copy-asset-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ if (existsSync(assertLinksFilepath)) {

writeFileSync(`${wellKnownDir}/assetLinks.json`, assertLinks);
} else {
console.warn('Missing asserLinks.json file');
console.warn('Warning: Missing assetLinks.json file');
}
2 changes: 2 additions & 0 deletions web/src/app/components/header/header.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import {NO_ERRORS_SCHEMA} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {MatDialog} from '@angular/material/dialog';
import {MatMenuModule} from '@angular/material/menu';
Expand Down Expand Up @@ -46,6 +47,7 @@ describe('HeaderComponent', () => {
{provide: Router, useValue: {events: of()}},
{provide: SurveyService, useValue: {canManageSurvey: () => false}},
],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
* limitations under the License.
*/

import {NO_ERRORS_SCHEMA} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {GoogleMapsModule} from '@angular/google-maps';
import {MatDialog} from '@angular/material/dialog';
import {MatIconModule} from '@angular/material/icon';
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
import {List, Map} from 'immutable';

import {ImportDialogComponent} from 'app/components/import-dialog/import-dialog.component';
Expand Down Expand Up @@ -79,8 +82,9 @@ describe('LoiEditorComponent', () => {
matDialogSpy = jasmine.createSpyObj<MatDialog>('MatDialog', ['open']);

TestBed.configureTestingModule({
imports: [GoogleMapsModule],
imports: [GoogleMapsModule, MatSlideToggleModule, MatIconModule],
declarations: [LoiEditorComponent],
schemas: [NO_ERRORS_SCHEMA],
providers: [
{
provide: DataStoreService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
* limitations under the License.
*/

import {NO_ERRORS_SCHEMA} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {GoogleMapsModule} from '@angular/google-maps';
import {MatDialog} from '@angular/material/dialog';
import {MatIconModule} from '@angular/material/icon';
import {MatListModule} from '@angular/material/list';
import {List, Map} from 'immutable';

import {Coordinate} from 'app/models/geometry/coordinate';
Expand Down Expand Up @@ -75,7 +78,12 @@ describe('LoiSelectionComponent', () => {
matDialogSpy = jasmine.createSpyObj<MatDialog>('MatDialog', ['open']);

TestBed.configureTestingModule({
imports: [GoogleMapsModule, GroundIconModule],
imports: [
GoogleMapsModule,
GroundIconModule,
MatListModule,
MatIconModule,
],
declarations: [LoiSelectionComponent],
providers: [
{
Expand All @@ -87,6 +95,7 @@ describe('LoiSelectionComponent', () => {
useValue: matDialogSpy,
},
],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();

fixture = TestBed.createComponent(LoiSelectionComponent);
Expand Down
25 changes: 13 additions & 12 deletions web/src/app/components/share-list/share-list.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
import {MatListModule} from '@angular/material/list';
import {MatListHarness} from '@angular/material/list/testing';
import {MatSelectModule} from '@angular/material/select';
import {Map} from 'immutable';
import {Subject, firstValueFrom, of} from 'rxjs';

Expand Down Expand Up @@ -55,7 +56,7 @@ describe('ShareListComponent', () => {
{type: DataSharingType.PRIVATE}
);

const user = new User('', '', true);
const user = new User('user1', 'user1@gmail.com', true);

beforeEach(waitForAsync(() => {
draftSurveyServiceSpy = jasmine.createSpyObj<DraftSurveyService>(
Expand All @@ -74,7 +75,7 @@ describe('ShareListComponent', () => {

TestBed.configureTestingModule({
declarations: [ShareListComponent],
imports: [MatListModule],
imports: [MatListModule, MatSelectModule],
providers: [
{provide: DraftSurveyService, useValue: draftSurveyServiceSpy},
{provide: AuthService, useValue: authServiceSpy},
Expand All @@ -95,10 +96,10 @@ describe('ShareListComponent', () => {

it('updates itself when acl changes', async () => {
activeSurvey$.next(survey);
fixture.detectChanges();
await fixture.whenStable();

fixture.whenStable().then(async () => {
expect(component.acl?.length).toBe(0);
});
expect(component.acl?.length).toBe(0);

activeSurvey$.next(
new Survey(
Expand All @@ -107,18 +108,18 @@ describe('ShareListComponent', () => {
surveyDescription,
/* jobs= */ Map(),
/* acl= */ Map({a: Role.OWNER, b: Role.OWNER}),
/* ownerId= */ '',
/* ownerId= */ 'user1',
{type: DataSharingType.PRIVATE}
)
);
fixture.detectChanges();
await fixture.whenStable();

fixture.whenStable().then(async () => {
expect(component.acl?.length).toBe(2);
expect(component.acl?.length).toBe(2);

const aclList = await loader.getHarness(MatListHarness);
const aclListItems = await aclList.getItems();
const aclList = await loader.getHarness(MatListHarness);
const aclListItems = await aclList.getItems();

expect(aclListItems.length).toBe(2);
});
expect(aclListItems.length).toBe(3);
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {NO_ERRORS_SCHEMA} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {MatCardModule} from '@angular/material/card';
import {MatDialogModule} from '@angular/material/dialog';
import {MatIconModule} from '@angular/material/icon';

Expand All @@ -10,8 +12,9 @@ describe('ShareSurveyComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MatIconModule, MatDialogModule],
imports: [MatIconModule, MatDialogModule, MatCardModule],
declarations: [ShareSurveyComponent],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();

fixture = TestBed.createComponent(ShareSurveyComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import {NO_ERRORS_SCHEMA} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {NavigationEnd, Router} from '@angular/router';
import {BehaviorSubject, NEVER, of} from 'rxjs';
Expand Down Expand Up @@ -41,6 +42,7 @@ describe('SignInPageComponent', () => {
useValue: {getUser$: () => NEVER, isAuthenticated$: () => NEVER},
},
],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {AngularFireAuth} from '@angular/fire/compat/auth';
import {AngularFirestore} from '@angular/fire/compat/firestore';
import {MatButtonModule} from '@angular/material/button';
import {MatCardModule} from '@angular/material/card';
import {MatChipsModule} from '@angular/material/chips';
import {MatDialog, MatDialogRef} from '@angular/material/dialog';
import {MatGridListModule} from '@angular/material/grid-list';
import {MatIconModule} from '@angular/material/icon';
Expand Down Expand Up @@ -176,6 +177,7 @@ describe('SurveyListComponent', () => {
MatCardModule,
MatGridListModule,
MatIconModule,
MatChipsModule,
],
declarations: [SurveyListComponent, HeaderComponent],
providers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import {ComponentFixture, TestBed} from '@angular/core/testing';
import {MatIconModule} from '@angular/material/icon';

import {AddTaskButtonComponent} from './add-task-button.component';

Expand All @@ -24,6 +25,7 @@ describe('TaskButtonComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MatIconModule],
declarations: [AddTaskButtonComponent],
}).compileComponents();

Expand Down
10 changes: 7 additions & 3 deletions web/src/app/pages/create-survey/create-survey.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import {NO_ERRORS_SCHEMA} from '@angular/core';
import {
ComponentFixture,
TestBed,
Expand All @@ -23,6 +24,7 @@ import {
waitForAsync,
} from '@angular/core/testing';
import {MatDialogModule} from '@angular/material/dialog';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import {By} from '@angular/platform-browser';
import {ActivatedRoute} from '@angular/router';
import {List, Map} from 'immutable';
Expand All @@ -43,6 +45,7 @@ import {SurveyDetailsComponent} from 'app/pages/create-survey/survey-details/sur
import {DraftSurveyService} from 'app/services/draft-survey/draft-survey.service';
import {JobService} from 'app/services/job/job.service';
import {LocationOfInterestService} from 'app/services/loi/loi.service';
import {SURVEY_ID_NEW} from 'app/services/navigation/navigation.constants';
import {NavigationService} from 'app/services/navigation/navigation.service';
import {SurveyService} from 'app/services/survey/survey.service';
import {TaskService} from 'app/services/task/task.service';
Expand Down Expand Up @@ -198,14 +201,15 @@ describe('CreateSurveyComponent', () => {
]);

TestBed.configureTestingModule({
imports: [MatDialogModule],
imports: [MatDialogModule, MatProgressSpinnerModule],
declarations: [
CreateSurveyComponent,
SurveyDetailsComponent,
JobDetailsComponent,
DataSharingTermsComponent,
ShareSurveyComponent,
],
schemas: [NO_ERRORS_SCHEMA],
providers: [
{provide: NavigationService, useValue: navigationServiceSpy},
{provide: SurveyService, useValue: surveyServiceSpy},
Expand Down Expand Up @@ -246,7 +250,7 @@ describe('CreateSurveyComponent', () => {

describe('when no survey', () => {
beforeEach(fakeAsync(() => {
surveyId$.next(NavigationService.SURVEY_ID_NEW);
surveyId$.next(SURVEY_ID_NEW);
activeSurvey$.next(Survey.UNSAVED_NEW);
tick();
fixture.detectChanges();
Expand Down Expand Up @@ -314,7 +318,7 @@ describe('CreateSurveyComponent', () => {
describe('Survey Details', () => {
describe('when no survey', () => {
beforeEach(fakeAsync(() => {
surveyId$.next(NavigationService.SURVEY_ID_NEW);
surveyId$.next(SURVEY_ID_NEW);
activeSurvey$.next(Survey.UNSAVED_NEW);
tick();
fixture.detectChanges();
Expand Down
8 changes: 4 additions & 4 deletions web/src/app/pages/create-survey/create-survey.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {TaskDetailsComponent} from 'app/pages/create-survey/task-details/task-de
import {DraftSurveyService} from 'app/services/draft-survey/draft-survey.service';
import {JobService} from 'app/services/job/job.service';
import {LocationOfInterestService} from 'app/services/loi/loi.service';
import {SURVEY_ID_NEW} from 'app/services/navigation/navigation.constants';
import {NavigationService} from 'app/services/navigation/navigation.service';
import {SurveyService} from 'app/services/survey/survey.service';
import {TaskService} from 'app/services/task/task.service';
Expand Down Expand Up @@ -155,7 +156,7 @@ export class CreateSurveyComponent implements OnInit {
ngOnInit(): void {
this.subscription.add(
this.navigationService.getSurveyId$().subscribe(async surveyId => {
this.surveyId = surveyId ? surveyId : NavigationService.SURVEY_ID_NEW;
this.surveyId = surveyId ? surveyId : SURVEY_ID_NEW;
this.surveyService.activateSurvey(this.surveyId);
await this.draftSurveyService.init(this.surveyId);
this.draftSurveyService
Expand All @@ -172,8 +173,7 @@ export class CreateSurveyComponent implements OnInit {
.pipe(
filter(
([survey]) =>
this.surveyId === NavigationService.SURVEY_ID_NEW ||
survey.id === this.surveyId
this.surveyId === SURVEY_ID_NEW || survey.id === this.surveyId
)
)
.subscribe(([survey, lois]) => {
Expand Down Expand Up @@ -332,7 +332,7 @@ export class CreateSurveyComponent implements OnInit {

private async saveSurveyTitleAndDescription(): Promise<string | void> {
const [name, description] = this.surveyDetails!.toTitleAndDescription();
if (this.surveyId === NavigationService.SURVEY_ID_NEW) {
if (this.surveyId === SURVEY_ID_NEW) {
return await this.surveyService.createSurvey(name, description);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*/

import {CommonModule} from '@angular/common';
import {NO_ERRORS_SCHEMA} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {ReactiveFormsModule} from '@angular/forms';
import {MatCardModule} from '@angular/material/card';
import {MatRadioModule} from '@angular/material/radio';

import {
DATA_SHARING_TYPE_DESCRIPTION,
Expand All @@ -30,7 +34,13 @@ describe('DataSharingTermsComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [DataSharingTermsComponent],
imports: [CommonModule],
imports: [
CommonModule,
MatCardModule,
MatRadioModule,
ReactiveFormsModule,
],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();

fixture = TestBed.createComponent(DataSharingTermsComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* limitations under the License.
*/

import {NO_ERRORS_SCHEMA} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {ReactiveFormsModule} from '@angular/forms';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatInputModule} from '@angular/material/input';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';

import {SurveyDetailsComponent} from 'app/pages/create-survey/survey-details/survey-details.component';

Expand All @@ -26,6 +31,17 @@ describe('SurveyDetailsComponent', () => {
const description = 'description';

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [SurveyDetailsComponent],
imports: [
MatFormFieldModule,
MatInputModule,
ReactiveFormsModule,
NoopAnimationsModule,
],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();

fixture = TestBed.createComponent(SurveyDetailsComponent);
component = fixture.componentInstance;
component.title = title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import {NO_ERRORS_SCHEMA} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {MatDialogModule} from '@angular/material/dialog';
import {Map} from 'immutable';
Expand Down Expand Up @@ -55,6 +56,7 @@ describe('TaskDetailsComponent', () => {
},
},
],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();

fixture = TestBed.createComponent(TaskDetailsComponent);
Expand Down
Loading
Loading