Skip to content

Commit

Permalink
fix: use general spinner + fix cypress AB#17459 AB#17590
Browse files Browse the repository at this point in the history
  • Loading branch information
arsforza committed Jan 27, 2023
1 parent 7a2ec2e commit c298635
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 38 deletions.
3 changes: 0 additions & 3 deletions interfaces/IBF-dashboard/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Component, OnDestroy } from '@angular/core';
import { Platform } from '@ionic/angular';
import { TranslateService } from '@ngx-translate/core';
import { Subscription } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { DEBOUNCE_TIME_LOADER } from 'src/app/config';
import { LoaderService } from 'src/app/services/loader.service';

@Component({
Expand All @@ -24,7 +22,6 @@ export class AppComponent implements OnDestroy {
this.initializeApp();
this.loaderSubscription = this.loaderService
.getLoaderSubscription()
.pipe(debounceTime(DEBOUNCE_TIME_LOADER))
.subscribe(this.onLoaderChange);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
<ion-row>
<div
*ngFor="let disasterType of disasterTypes"
data-test="disaster-type-button"
class="disaster-type-button-container"
[attr.data-test]="
isSelectedDisaster(disasterType.disasterType)
? 'selected-disaster-' + disasterType.disasterType
: ''
"
>
<ion-icon
*ngIf="!isLoading()"
(click)="!isLoading() && switchDisasterType(disasterType)"
(click)="switchDisasterType(disasterType)"
class="disaster-type-button"
data-test="disaster-type-button"
[src]="
getButtonSvg(disasterType.disasterType, disasterType.activeTrigger)
"
slot="start"
[attr.data-test]="
[attr.data-test-selected]="
isSelectedDisaster(disasterType.disasterType) ? 'selected-disaster' : ''
"
>
</ion-icon>
<ion-spinner
*ngIf="isLoading()"
class="disaster-type-button"
name="circles"
[color]="
disasterType.activeTrigger
? 'ibf-trigger-alert-primary'
: 'ibf-no-alert-primary'
"
></ion-spinner>
</div>
</ion-row>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { EventService } from 'src/app/services/event.service';
import { DisasterTypeKey } from 'src/app/types/disaster-type-key';
import { Country, DisasterType } from '../../models/country.model';
import { CountryService } from '../../services/country.service';
import { LoaderService } from '../../services/loader.service';
import { PlaceCodeService } from '../../services/place-code.service';

@Component({
Expand All @@ -18,30 +17,24 @@ export class DisasterTypeComponent implements OnInit, OnDestroy {
public disasterTypesCounter = 0;
public disasterTypes: DisasterType[] = [];
private selectedDisasterType: DisasterTypeKey;
private loading = false;

private countrySubscription: Subscription;
private loaderSubscription: Subscription;

constructor(
public disasterTypeService: DisasterTypeService,
private countryService: CountryService,
public eventService: EventService,
private placeCodeService: PlaceCodeService,
private loaderService: LoaderService,
) {}

ngOnInit() {
this.countrySubscription = this.countryService
.getCountrySubscription()
.subscribe(this.onCountryChange);

this.loaderService.getLoaderSubscription().subscribe(this.onLoaderChange);
}

ngOnDestroy() {
this.countrySubscription.unsubscribe();
this.loaderSubscription.unsubscribe();
}

private onGetDisasterTypeActiveTrigger = (country) => () => {
Expand Down Expand Up @@ -76,21 +69,13 @@ export class DisasterTypeComponent implements OnInit, OnDestroy {
}
};

private onLoaderChange = (loading: boolean) => {
this.loading = loading;
};

public switchDisasterType(disasterType: DisasterType): void {
this.placeCodeService.clearPlaceCode();
this.placeCodeService.clearPlaceCodeHover();
this.disasterTypeService.setDisasterType(disasterType);
this.selectedDisasterType = disasterType.disasterType;
}

public isLoading(): boolean {
return this.loading;
}

public isSelectedDisaster(disasterType: string): boolean {
return this.selectedDisasterType === disasterType;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/support/selectors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
disasterType: {
selected: "[data-test='selected-disaster']",
selected: "[data-test-selected='selected-disaster']",
disasterTypeButtons: '[data-test=disaster-type-button]',
},
timeline: {
Expand Down

0 comments on commit c298635

Please sign in to comment.