Skip to content

Commit

Permalink
test: ui (#31)
Browse files Browse the repository at this point in the history
* test: ui

* fix: healthpage

* fix: ci

* fix: ci

* fix: esproj

* chore: remove some tests
  • Loading branch information
eugbyte committed Aug 3, 2024
1 parent eeee568 commit 6c5e913
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 105 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ concurrency:
group: store-on-wheels-dev
cancel-in-progress: true

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ install:
cd src/storeonwheels.client && npm i

start:
dotnet run --project=StoreOnWheels.Server/StoreOnWheels.Server.csproj
dotnet run --project=src/StoreOnWheels.Server/StoreOnWheels.Server.csproj

test:
dotnet test
Expand Down
1 change: 1 addition & 0 deletions StoreOnWheels.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
src\StoreOnWheels.Server\.editorconfig = src\StoreOnWheels.Server\.editorconfig
.gitignore = .gitignore
Makefile = Makefile
README.md = README.md
store_on_wheels_preview.gif = store_on_wheels_preview.gif
EndProjectSection
Expand Down
1 change: 1 addition & 0 deletions src/storeonwheels.client/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = function (config) {
// or set a specific seed with `seed: 4321`
},
clearContext: false, // leave Jasmine Spec Runner output visible in browser
random: false,
},
jasmineHtmlReporter: {
suppressAll: true, // removes the duplicated traces
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class VendorService {
async createVendor(vendor: Vendor): Promise<Vendor> {
try {
const response = await axios.post("/api/v1/vendors", vendor);
const updatedVendor = response.data;
const updatedVendor: Vendor = response.data;
return updatedVendor;
} catch (error) {
if (error instanceof AxiosError) {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { TestBed } from "@angular/core/testing";

import { MessageHubService } from "./message-hub.service";
import { HUB_CONNECTION, hubConnection } from "./message-hub.provider";

describe("MessageHubService", () => {
let service: MessageHubService;

beforeEach(() => {
TestBed.configureTestingModule({});
TestBed.configureTestingModule({
providers: [
{ provide: HUB_CONNECTION, useValue: hubConnection },
]
});
service = TestBed.inject(MessageHubService);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
import { ComponentFixture, TestBed } from "@angular/core/testing";

import axios from "axios";
import { HealthcheckComponent } from "./healthcheck-page.component";
import { HUB_CONNECTION, MessageHubService, hubConnection } from "~/app/libs/map/services";

describe("HealthcheckComponent", () => {
let component: HealthcheckComponent;
let fixture: ComponentFixture<HealthcheckComponent>;

beforeEach(async () => {
const data: Record<string, string> = { message: 'Server is running' };
spyOn(axios, 'get').and.resolveTo({ data });

await TestBed.configureTestingModule({
imports: [HealthcheckComponent],
providers: [
{ provide: HUB_CONNECTION, useValue: hubConnection },
MessageHubService,
]
}).compileComponents();

fixture = TestBed.createComponent(HealthcheckComponent);
component = fixture.componentInstance;
fixture.detectChanges();
fixture.autoDetectChanges();
});

it("should create", () => {
expect(component).toBeTruthy();
it("should create", () => expect(component).toBeTruthy());

it("should display health status", async() => {
const root: HTMLElement = fixture.nativeElement;
fixture.detectChanges();
expect(root.innerText).toContain("Server is running");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class HealthcheckComponent implements OnInit {
const response: Record<string, string> = (
await axios.get("api/v1/healthchecks")
).data;
console.log({ response });
this.message = response["message"];
this.wsUrl = hubConnection.baseUrl;

Expand Down

This file was deleted.

0 comments on commit 6c5e913

Please sign in to comment.