Fix frontend tests (#436)

* Update CONTRIBUTING.md

* Fix tests
This commit is contained in:
Jean Fernandez 2024-02-29 23:50:58 -05:00 committed by GitHub
parent 3b52e9f8a2
commit 05a68408fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 47 additions and 7 deletions

View File

@ -30,6 +30,9 @@ brew install go
brew install docker brew install docker
# Frontend tests run with ChromeHeadless browser.
brew install --cask google-chrome
# Go specific tools # Go specific tools
go install github.com/gzuidhof/tygo@latest go install github.com/gzuidhof/tygo@latest
``` ```
@ -48,6 +51,8 @@ make test-frontend
make test-backend make test-backend
``` ```
**Note**: Running backend tests may take awhile to complete the first time you run
# Start Development Environment # Start Development Environment
To run Fasten from source, you'll need to create 2 separate processes: To run Fasten from source, you'll need to create 2 separate processes:
@ -211,9 +216,12 @@ a CDN or minimal Nginx deployment.
### How do I run individual frontend tests? ### How do I run individual frontend tests?
- ng test --include='**/base_client.spec.ts' From the `frontend` directory, you can run `ng test` with the `--include` argument.
- ng test --include='lib/**/*.spec.ts'
```bash
ng test --include='**/badge.component.spec.ts'
ng test --include='lib/**/*.spec.ts'
```
### How do I change the default encryption key and admin credentials ### How do I change the default encryption key and admin credentials
- FASTEN_ISSUER_JWT_KEY - FASTEN_ISSUER_JWT_KEY

View File

@ -1,19 +1,24 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RtfComponent } from './rtf.component'; import { RtfComponent } from './rtf.component';
import { BinaryModel } from 'src/lib/models/resources/binary-model';
describe('RtfComponent', () => { describe('RtfComponent', () => {
let component: RtfComponent; let component: RtfComponent;
let fixture: ComponentFixture<RtfComponent>; let fixture: ComponentFixture<RtfComponent>;
const rtf: string = "{\\rtf1\\ansi\\deff0 {\\fonttbl {\\f0 Times New Roman;}} \\f0\\fs60 Hello, World! }";
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ RtfComponent ] imports: [ RtfComponent ]
}) })
.compileComponents(); .compileComponents();
fixture = TestBed.createComponent(RtfComponent); fixture = TestBed.createComponent(RtfComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.displayModel = new BinaryModel({});
component.displayModel.content = rtf;
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -1,6 +1,10 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MedicalRecordWizardAddLabResultsComponent } from './medical-record-wizard-add-lab-results.component'; import { MedicalRecordWizardAddLabResultsComponent } from './medical-record-wizard-add-lab-results.component';
import { NlmClinicalTableSearchService } from 'src/app/services/nlm-clinical-table-search.service';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { HTTP_CLIENT_TOKEN } from '../../dependency-injection';
import { HttpHandler } from '@angular/common/http';
describe('MedicalRecordWizardAddLabResultsComponent', () => { describe('MedicalRecordWizardAddLabResultsComponent', () => {
let component: MedicalRecordWizardAddLabResultsComponent; let component: MedicalRecordWizardAddLabResultsComponent;
@ -8,7 +12,11 @@ describe('MedicalRecordWizardAddLabResultsComponent', () => {
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ MedicalRecordWizardAddLabResultsComponent ] imports: [ MedicalRecordWizardAddLabResultsComponent ],
providers: [NgbActiveModal, NlmClinicalTableSearchService, {
provide: HTTP_CLIENT_TOKEN,
useClass: HttpHandler,
}]
}) })
.compileComponents(); .compileComponents();

View File

@ -1,8 +1,9 @@
import { ElementRef } from '@angular/core';
import { ImageFallbackDirective } from './image-fallback.directive'; import { ImageFallbackDirective } from './image-fallback.directive';
describe('ImageFallbackDirective', () => { describe('ImageFallbackDirective', () => {
it('should create an instance', () => { it('should create an instance', () => {
const directive = new ImageFallbackDirective(); const directive = new ImageFallbackDirective(new ElementRef('img'));
expect(directive).toBeTruthy(); expect(directive).toBeTruthy();
}); });
}); });

View File

@ -1,6 +1,10 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AuthSignupWizardComponent } from './auth-signup-wizard.component'; import { AuthSignupWizardComponent } from './auth-signup-wizard.component';
import { HttpClient } from '@angular/common/http';
import { HTTP_CLIENT_TOKEN } from 'src/app/dependency-injection';
import { FormsModule } from '@angular/forms';
import { HttpClientTestingModule } from '@angular/common/http/testing';
describe('AuthSignupWizardComponent', () => { describe('AuthSignupWizardComponent', () => {
let component: AuthSignupWizardComponent; let component: AuthSignupWizardComponent;
@ -8,7 +12,14 @@ describe('AuthSignupWizardComponent', () => {
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ AuthSignupWizardComponent ] declarations: [ AuthSignupWizardComponent ],
imports: [HttpClientTestingModule, FormsModule],
providers: [
{
provide: HTTP_CLIENT_TOKEN,
useClass: HttpClient,
}
]
}) })
.compileComponents(); .compileComponents();

View File

@ -1,12 +1,19 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { PlatformService } from './platform.service'; import { PlatformService } from './platform.service';
import { HTTP_CLIENT_TOKEN } from '../dependency-injection';
import { HttpClient, HttpHandler } from '@angular/common/http';
describe('PlatformService', () => { describe('PlatformService', () => {
let service: PlatformService; let service: PlatformService;
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({}); TestBed.configureTestingModule({
providers: [HttpClient, HttpHandler, {
provide: HTTP_CLIENT_TOKEN,
useClass: HttpHandler,
}]
});
service = TestBed.inject(PlatformService); service = TestBed.inject(PlatformService);
}); });