Fixed tests

This commit is contained in:
Erik Tiekstra
2021-11-15 08:29:13 +01:00
parent ce833b31bb
commit d0f64d6e14
28 changed files with 154 additions and 72 deletions

View File

@@ -33,6 +33,7 @@
[uiRequired]="true"
[uiInvalid]="emailsControl.invalid && emailsControl.dirty"
[uiValidationMessage]="emailsControl.errors?.required || emailsControl.errors?.invalid || 'Ogiltig e-postadress'"
ngDefaultControl
></ui-textarea>
<digi-notification-alert

View File

@@ -4,7 +4,6 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { EmployeeInviteComponent } from './employee-invite.component';
describe('EmployeeInviteComponent', () => {

View File

@@ -1,5 +1,5 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SlutredovisningViewDescriptionListComponent } from './slutredovisning-view-description-list.component';
describe('SlutredovisningViewDescriptionListComponent', () => {
@@ -8,14 +8,22 @@ describe('SlutredovisningViewDescriptionListComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ SlutredovisningViewDescriptionListComponent ]
})
.compileComponents();
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [SlutredovisningViewDescriptionListComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SlutredovisningViewDescriptionListComponent);
component = fixture.componentInstance;
component.slutredovisning = {
genomforandereferens: 123,
mainOccupation: null,
activities: [],
progressDescription: '',
nextStepDescription: '',
otherInformation: '',
};
fixture.detectChanges();
});

View File

@@ -9,6 +9,7 @@
[uiAnnounceIfOptional]="true"
[uiInvalid]="formControlIsInvalid(educationLevelFormControl)"
[uiValidationMessage]="educationLevelFormControl.errors?.required"
ngDefaultControl
></ui-radiobutton-group>
</digi-form-fieldset>
@@ -20,6 +21,7 @@
[uiAnnounceIfOptional]="false"
[uiMaxLength]="200"
[uiInvalid]="(otherExplanationFormControl?.touched || this.shouldValidate) && formGroup.errors?.needDescriptionOfOther"
ngDefaultControl
></ui-textarea>
</div>
@@ -32,6 +34,7 @@
[uiAnnounceIfOptional]="true"
[uiInvalid]="formControlIsInvalid(educationLengthFormControl)"
[uiValidationMessage]="educationLengthFormControl.errors?.required"
ngDefaultControl
></ui-radiobutton-group>
</digi-form-fieldset>
@@ -42,5 +45,6 @@
[uiAnnounceIfOptional]="false"
[uiMaxLength]="200"
[uiInvalid]="(educationSpecificationFormControl?.touched || this.shouldValidate) && educationSpecificationFormControl.errors?.required"
ngDefaultControl
></ui-textarea>
</div>

View File

@@ -1,20 +1,26 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
import { SlutredovisningFormService } from '../../slutredovisning-form.service';
import { SlutredovisningFormStep0EducationComponent } from './slutredovisning-form-step0-education.component';
describe('SlutredovisningFormStep1Component', () => {
describe('SlutredovisningFormStep0EducationComponent', () => {
let component: SlutredovisningFormStep0EducationComponent;
let fixture: ComponentFixture<SlutredovisningFormStep0EducationComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [SlutredovisningFormStep0EducationComponent],
imports: [ReactiveFormsModule],
providers: [SlutredovisningFormService],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SlutredovisningFormStep0EducationComponent);
component = fixture.componentInstance;
component.formGroupRef = new FormGroup({});
fixture.detectChanges();
});

View File

@@ -8,6 +8,7 @@
[uiMaxLength]="200"
[uiRequired]="true"
[uiInvalid]="(otherExplanationFormControl?.touched || this.shouldValidate) && otherExplanationFormControl.errors?.required"
ngDefaultControl
></ui-textarea>
</div>
</div>

View File

@@ -1,20 +1,26 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
import { SlutredovisningFormService } from '../../slutredovisning-form.service';
import { SlutredovisningFormStep0OtherComponent } from './slutredovisning-form-step0-other.component';
describe('SlutredovisningFormStep1Component', () => {
describe('SlutredovisningFormStep0OtherComponent', () => {
let component: SlutredovisningFormStep0OtherComponent;
let fixture: ComponentFixture<SlutredovisningFormStep0OtherComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [SlutredovisningFormStep0OtherComponent],
imports: [ReactiveFormsModule],
providers: [SlutredovisningFormService],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SlutredovisningFormStep0OtherComponent);
component = fixture.componentInstance;
component.formGroupRef = new FormGroup({});
fixture.detectChanges();
});

View File

@@ -12,6 +12,7 @@
[formControl]="stillUnemployedReasonFormControl.get(stillUnemployedReasonOption.formControlName)"
[uiLabel]="stillUnemployedReasonOption.label"
[uiInvalid]="(stillUnemployedReasonFormControl?.touched || this.shouldValidate) && formGroup?.errors?.atLeastOneSelected"
ngDefaultControl
></ui-checkbox>
</digi-form-fieldset>
<div aria-atomic="true" role="alert">
@@ -31,6 +32,7 @@
[uiAnnounceIfOptional]="false"
[uiMaxLength]="200"
[uiInvalid]="(stillUnemployedReasonDescriptionFormControl?.touched || this.shouldValidate) && formGroup.errors?.needDescriptionOfOther"
ngDefaultControl
></ui-textarea>
</div>
</div>

View File

@@ -1,20 +1,26 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
import { SlutredovisningFormService } from '../../slutredovisning-form.service';
import { SlutredovisningFormStep0StillUnemployedComponent } from './slutredovisning-form-step0-still-unemployed.component';
describe('SlutredovisningFormStep1Component', () => {
describe('SlutredovisningFormStep0StillUnemployedComponent', () => {
let component: SlutredovisningFormStep0StillUnemployedComponent;
let fixture: ComponentFixture<SlutredovisningFormStep0StillUnemployedComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [SlutredovisningFormStep0StillUnemployedComponent],
imports: [ReactiveFormsModule],
providers: [SlutredovisningFormService],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SlutredovisningFormStep0StillUnemployedComponent);
component = fixture.componentInstance;
component.formGroupRef = new FormGroup({});
fixture.detectChanges();
});

View File

@@ -39,6 +39,7 @@
[uiAnnounceIfOptional]="true"
[uiInvalid]="formControlIsInvalid('yrkesomrade', index)"
[uiValidationMessage]="formControlError('yrkesomrade', index)"
ngDefaultControl
></ui-select>
<ui-select
*ngIf="getYrkesgruppSelectOptions$(index) | async as yrkesgruppSelectOptions"
@@ -51,6 +52,7 @@
[uiAnnounceIfOptional]="true"
[uiInvalid]="formControlIsInvalid('yrkesgrupp', index)"
[uiValidationMessage]="formControlError('yrkesgrupp', index)"
ngDefaultControl
></ui-select>
<digi-form-fieldset af-legend="Anställningsform">
@@ -63,6 +65,7 @@
[uiAnnounceIfOptional]="true"
[uiInvalid]="formControlIsInvalid('anstallningsform', index)"
[uiValidationMessage]="formControlError('anstallningsform', index)"
ngDefaultControl
></ui-radiobutton-group>
</digi-form-fieldset>
@@ -76,6 +79,7 @@
[uiMaxLength]="200"
[uiInvalid]="formControlIsInvalid('annatAnstallningComment', index)"
[uiValidationMessage]="formControlError('annatAnstallningComment', index)"
ngDefaultControl
></ui-textarea>
<digi-form-fieldset af-legend="Omfattning">
@@ -90,6 +94,7 @@
[uiAnnounceIfOptional]="true"
[uiInvalid]="formControlIsInvalid('omfattning', index)"
[uiValidationMessage]="formControlError('omfattning', index)"
ngDefaultControl
></ui-radiobutton-group>
<ui-input
*ngIf="formArray.controls[index].get('omfattning').value === Omfattning.Deltid"
@@ -103,6 +108,7 @@
[uiAnnounceIfOptional]="true"
[uiInvalid]="formControlIsInvalid('omfattningPercent', index)"
[uiValidationMessage]="formControlError('omfattningPercent', index)"
ngDefaultControl
></ui-input>
</div>
</digi-form-fieldset>

View File

@@ -1,4 +1,8 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
import { SlutredovisningFormService } from '../../slutredovisning-form.service';
import { SlutredovisningFormStep0WorkComponent } from './slutredovisning-form-step0-work.component';
describe('SlutredovisningFormStep0WorkComponent', () => {
@@ -7,13 +11,17 @@ describe('SlutredovisningFormStep0WorkComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [SlutredovisningFormStep0WorkComponent],
imports: [ReactiveFormsModule, HttpClientTestingModule],
providers: [SlutredovisningFormService],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SlutredovisningFormStep0WorkComponent);
component = fixture.componentInstance;
component.formGroupRef = new FormGroup({});
fixture.detectChanges();
});

View File

@@ -20,6 +20,7 @@
[uiAnnounceIfOptional]="true"
[uiInvalid]="formControlIsInvalid(mainOccupationFormControl)"
[uiValidationMessage]="mainOccupationFormControl.errors?.required"
ngDefaultControl
></ui-radiobutton-group>
</digi-form-fieldset>

View File

@@ -1,20 +1,27 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
import { SlutredovisningFormService } from '../slutredovisning-form.service';
import { SlutredovisningFormStep0Component } from './slutredovisning-form-step0.component';
describe('SlutredovisningFormStep1Component', () => {
describe('SlutredovisningFormStep0Component', () => {
let component: SlutredovisningFormStep0Component;
let fixture: ComponentFixture<SlutredovisningFormStep0Component>;
beforeEach(async () => {
await TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [SlutredovisningFormStep0Component],
imports: [ReactiveFormsModule, HttpClientTestingModule],
providers: [SlutredovisningFormService],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SlutredovisningFormStep0Component);
component = fixture.componentInstance;
component.formGroup = new FormGroup({});
fixture.detectChanges();
});

View File

@@ -1,5 +1,8 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
import { SlutredovisningFormService } from '../slutredovisning-form.service';
import { SlutredovisningFormStep1Component } from './slutredovisning-form-step1.component';
describe('SlutredovisningFormStep1Component', () => {
@@ -8,13 +11,17 @@ describe('SlutredovisningFormStep1Component', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [SlutredovisningFormStep1Component],
imports: [ReactiveFormsModule, HttpClientTestingModule],
providers: [SlutredovisningFormService],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SlutredovisningFormStep1Component);
component = fixture.componentInstance;
component.formGroup = new FormGroup({});
fixture.detectChanges();
});

View File

@@ -15,6 +15,7 @@
[uiRequired]="true"
[uiValidationMessage]="framstegFormControl.errors?.required"
[uiInvalid]="framstegFormControl?.touched && !!framstegFormControl?.errors?.required"
ngDefaultControl
></ui-textarea>
<ui-textarea
@@ -26,6 +27,7 @@
[uiRequired]="true"
[uiValidationMessage]="nastaStegFormControl.errors?.required"
[uiInvalid]="nastaStegFormControl?.touched && !!nastaStegFormControl?.errors?.required"
ngDefaultControl
></ui-textarea>
<ui-textarea
@@ -37,6 +39,7 @@
[uiRequired]="true"
[uiValidationMessage]="ovrigtFormControl.errors?.required"
[uiInvalid]="ovrigtFormControl?.touched && !!ovrigtFormControl?.errors?.required"
ngDefaultControl
></ui-textarea>
<footer class="slutredovisning-form-step2__footer">

View File

@@ -1,20 +1,26 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
import { SlutredovisningFormService } from '../slutredovisning-form.service';
import { SlutredovisningFormStep2Component } from './slutredovisning-form-step2.component';
describe('SlutredovisningFormStep1Component', () => {
describe('SlutredovisningFormStep2Component', () => {
let component: SlutredovisningFormStep2Component;
let fixture: ComponentFixture<SlutredovisningFormStep2Component>;
beforeEach(async () => {
await TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [SlutredovisningFormStep2Component],
imports: [ReactiveFormsModule],
providers: [SlutredovisningFormService],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SlutredovisningFormStep2Component);
component = fixture.componentInstance;
component.formGroup = new FormGroup({});
fixture.detectChanges();
});

View File

@@ -1,5 +1,7 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SlutredovisningFormService } from '../slutredovisning-form.service';
import { SlutredovisningFormStep3Component } from './slutredovisning-form-step3.component';
describe('SlutredovisningFormStep3Component', () => {
@@ -8,9 +10,11 @@ describe('SlutredovisningFormStep3Component', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ SlutredovisningFormStep3Component ]
})
.compileComponents();
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [SlutredovisningFormStep3Component],
imports: [HttpClientTestingModule],
providers: [SlutredovisningFormService],
}).compileComponents();
});
beforeEach(() => {

View File

@@ -3,6 +3,7 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { StartComponent } from './start.component';
import { StartService } from './start.service';
describe('StartComponent', () => {
let component: StartComponent;
@@ -14,6 +15,7 @@ describe('StartComponent', () => {
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [StartComponent],
imports: [RouterTestingModule, HttpClientTestingModule],
providers: [StartService],
}).compileComponents();
})
);

View File

@@ -41,7 +41,7 @@ export class AuthGuard implements CanActivate {
this.authenticationService.removeLocalStorageData();
if (environment.ciam.clientId) {
document.location.href = `${environment.ciam.loginUrl}&client_id=${environment.ciam.clientId}&redirect_uri=${window.location.origin}`;
window.location.href = `${environment.ciam.loginUrl}&client_id=${environment.ciam.clientId}&redirect_uri=${window.location.origin}`;
} else {
void this.router.navigateByUrl(environment.ciam.loginUrl);
}

View File

@@ -154,7 +154,7 @@ export class AuthenticationService {
this.removeLocalStorageData();
if (environment.ciam.clientId) {
document.location.href = environment.ciam.logoutUrl;
window.location.href = environment.ciam.logoutUrl;
} else {
void this.router.navigateByUrl(environment.ciam.logoutUrl);
}