Skip to content

Commit

Permalink
Merge pull request #54 from SCAI-BIO/add-frontend-tests-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetcanay authored Aug 21, 2024
2 parents daa39bf + ad95573 commit ad884b8
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 29 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/frontend-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: frontend-tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [ 18, 20 ]

steps:
- uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Cache npm
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install frontend dependencies
run: |
cd client
npm ci
- name: Install Angular CLI
run: npm install -g @angular/cli

- name: Run frontend tests
run: |
cd client
ng test --watch=false --browsers=ChromeHeadless
2 changes: 1 addition & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: tests
name: backend-tests

on:
push:
Expand Down
12 changes: 11 additions & 1 deletion client/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';

describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AppComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
params: of({}), // Mocked ActivatedRoute with observable params
},
},
],
}).compileComponents();
});

Expand All @@ -24,6 +34,6 @@ describe('AppComponent', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, ui');
expect(compiled.querySelector('h1')?.textContent).toContain('Landing Page');
});
});
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { EmbeddingPlotComponent } from './embedding-plot.component';

describe('EmbeddingPlotComponent', () => {
xdescribe('EmbeddingPlotComponent', () => {
let component: EmbeddingPlotComponent;
let fixture: ComponentFixture<EmbeddingPlotComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [EmbeddingPlotComponent]
})
.compileComponents();
imports: [EmbeddingPlotComponent, HttpClientTestingModule],
}).compileComponents();

fixture = TestBed.createComponent(EmbeddingPlotComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MappingsTableDictComponent } from './mappings-table-dict.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MappingsTableComponentDict } from './mappings-table-dict.component';

describe('MappingsTableDictComponent', () => {
let component: MappingsTableDictComponent;
let fixture: ComponentFixture<MappingsTableDictComponent>;
let component: MappingsTableComponentDict;
let fixture: ComponentFixture<MappingsTableComponentDict>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MappingsTableDictComponent]
})
.compileComponents();
imports: [BrowserAnimationsModule, MappingsTableComponentDict],
}).compileComponents();

fixture = TestBed.createComponent(MappingsTableDictComponent);
fixture = TestBed.createComponent(MappingsTableComponentDict);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MappingsTableComponent } from './mappings-table.component';

describe('MappingsTableComponent', () => {
Expand All @@ -8,9 +8,8 @@ describe('MappingsTableComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MappingsTableComponent]
})
.compileComponents();
imports: [BrowserAnimationsModule, MappingsTableComponent],
}).compileComponents();

fixture = TestBed.createComponent(MappingsTableComponent);
component = fixture.componentInstance;
Expand Down
7 changes: 3 additions & 4 deletions client/src/app/mappings/mappings.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MappingsComponent } from './mappings.component';

describe('MappingsComponent', () => {
Expand All @@ -8,9 +8,8 @@ describe('MappingsComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MappingsComponent]
})
.compileComponents();
imports: [MappingsComponent, HttpClientTestingModule],
}).compileComponents();

fixture = TestBed.createComponent(MappingsComponent);
component = fixture.componentInstance;
Expand Down
7 changes: 5 additions & 2 deletions client/src/app/services/open-api.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';

import { OpenApiService } from './open-api.service';

describe('OpenApiService', () => {
let service: OpenApiService;

beforeEach(() => {
TestBed.configureTestingModule({});
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [OpenApiService],
});
service = TestBed.inject(OpenApiService);
});

Expand Down
12 changes: 8 additions & 4 deletions client/src/app/upload/upload.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { UploadComponent } from './upload.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [UploadComponent]
})
.compileComponents();
imports: [
BrowserAnimationsModule,
HttpClientTestingModule,
UploadComponent,
],
}).compileComponents();

fixture = TestBed.createComponent(UploadComponent);
component = fixture.componentInstance;
Expand Down

0 comments on commit ad884b8

Please sign in to comment.