From 0410b9fb241741f96d86a6ae3a90f3dc6aaedab6 Mon Sep 17 00:00:00 2001 From: eugene Date: Thu, 1 Aug 2024 21:27:45 +0800 Subject: [PATCH 1/6] test: ui --- StoreOnWheels.sln | 1 + src/storeonwheels.client/karma.conf.js | 1 + .../message-hub/message-hub.service.spec.ts | 7 +++++- .../pages/map-page/map-page.component.spec.ts | 22 ------------------- 4 files changed, 8 insertions(+), 23 deletions(-) delete mode 100644 src/storeonwheels.client/src/app/pages/map-page/map-page.component.spec.ts diff --git a/StoreOnWheels.sln b/StoreOnWheels.sln index 6870e0c..e703ee7 100644 --- a/StoreOnWheels.sln +++ b/StoreOnWheels.sln @@ -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 diff --git a/src/storeonwheels.client/karma.conf.js b/src/storeonwheels.client/karma.conf.js index f5ff8ff..d2545db 100644 --- a/src/storeonwheels.client/karma.conf.js +++ b/src/storeonwheels.client/karma.conf.js @@ -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 diff --git a/src/storeonwheels.client/src/app/libs/map/services/message-hub/message-hub.service.spec.ts b/src/storeonwheels.client/src/app/libs/map/services/message-hub/message-hub.service.spec.ts index 76c48c8..ec5ae75 100644 --- a/src/storeonwheels.client/src/app/libs/map/services/message-hub/message-hub.service.spec.ts +++ b/src/storeonwheels.client/src/app/libs/map/services/message-hub/message-hub.service.spec.ts @@ -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); }); diff --git a/src/storeonwheels.client/src/app/pages/map-page/map-page.component.spec.ts b/src/storeonwheels.client/src/app/pages/map-page/map-page.component.spec.ts deleted file mode 100644 index 0d36800..0000000 --- a/src/storeonwheels.client/src/app/pages/map-page/map-page.component.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ComponentFixture, TestBed } from "@angular/core/testing"; - -import { MapPageComponent } from "./map-page.component"; - -describe("MapboxComponent", () => { - let component: MapPageComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [MapPageComponent], - }).compileComponents(); - - fixture = TestBed.createComponent(MapPageComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it("should create", () => { - expect(component).toBeTruthy(); - }); -}); From ed2db1c5ddf901d2ce6af02eb244992ac8e1d8b8 Mon Sep 17 00:00:00 2001 From: eugene Date: Sat, 3 Aug 2024 13:27:51 +0800 Subject: [PATCH 2/6] fix: healthpage --- .../healthcheck-page.component.spec.ts | 20 +++++++++++++++---- .../healthcheck-page.component.ts | 1 + .../storeonwheels.client.esproj | 3 +++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/storeonwheels.client/src/app/pages/healthcheck-page/healthcheck-page.component.spec.ts b/src/storeonwheels.client/src/app/pages/healthcheck-page/healthcheck-page.component.spec.ts index 226085b..f4056b9 100644 --- a/src/storeonwheels.client/src/app/pages/healthcheck-page/healthcheck-page.component.spec.ts +++ b/src/storeonwheels.client/src/app/pages/healthcheck-page/healthcheck-page.component.spec.ts @@ -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; beforeEach(async () => { + const data: Record = { 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"); }); }); diff --git a/src/storeonwheels.client/src/app/pages/healthcheck-page/healthcheck-page.component.ts b/src/storeonwheels.client/src/app/pages/healthcheck-page/healthcheck-page.component.ts index 66d9ebd..7346f35 100644 --- a/src/storeonwheels.client/src/app/pages/healthcheck-page/healthcheck-page.component.ts +++ b/src/storeonwheels.client/src/app/pages/healthcheck-page/healthcheck-page.component.ts @@ -22,6 +22,7 @@ export class HealthcheckComponent implements OnInit { const response: Record = ( await axios.get("api/v1/healthchecks") ).data; + console.log({ response }); this.message = response["message"]; this.wsUrl = hubConnection.baseUrl; diff --git a/src/storeonwheels.client/storeonwheels.client.esproj b/src/storeonwheels.client/storeonwheels.client.esproj index b04983e..73d303a 100644 --- a/src/storeonwheels.client/storeonwheels.client.esproj +++ b/src/storeonwheels.client/storeonwheels.client.esproj @@ -7,4 +7,7 @@ $(MSBuildProjectDirectory)\dist\storeonwheels.client\browser\ + + + \ No newline at end of file From 3dece7729c7e43a7a13c5990f37dc101d8066666 Mon Sep 17 00:00:00 2001 From: eugene Date: Sat, 3 Aug 2024 13:31:08 +0800 Subject: [PATCH 3/6] fix: ci --- .github/workflows/dev.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 43b9332..ff5e76b 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -3,7 +3,11 @@ concurrency: group: store-on-wheels-dev cancel-in-progress: true -on: [push, pull_request] +on: + push: + pull_request: + branches: + - main jobs: build: From 034939302a061158c7a1a2b4cd76f631cda07b92 Mon Sep 17 00:00:00 2001 From: eugene Date: Sat, 3 Aug 2024 13:32:37 +0800 Subject: [PATCH 4/6] fix: ci --- .github/workflows/dev.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index ff5e76b..eb589c0 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -5,6 +5,8 @@ concurrency: on: push: + branches: + - main pull_request: branches: - main From bb85a9637d9ab0669701070e3020b4fd828389f1 Mon Sep 17 00:00:00 2001 From: eugene Date: Sat, 3 Aug 2024 13:36:20 +0800 Subject: [PATCH 5/6] fix: esproj --- src/storeonwheels.client/storeonwheels.client.esproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/storeonwheels.client/storeonwheels.client.esproj b/src/storeonwheels.client/storeonwheels.client.esproj index 73d303a..b04983e 100644 --- a/src/storeonwheels.client/storeonwheels.client.esproj +++ b/src/storeonwheels.client/storeonwheels.client.esproj @@ -7,7 +7,4 @@ $(MSBuildProjectDirectory)\dist\storeonwheels.client\browser\ - - - \ No newline at end of file From 416ccbe59ffa398fa9233d1539da72ba2615dadc Mon Sep 17 00:00:00 2001 From: eugene Date: Sat, 3 Aug 2024 13:57:48 +0800 Subject: [PATCH 6/6] chore: remove some tests --- Makefile | 2 +- .../geolocate/geolocate.service.spec.ts | 16 -------------- .../services/vendor/vendor.service.spec.ts | 16 -------------- .../services/vendor/vendor.service.ts | 2 +- .../map/components/map/map.component.spec.ts | 22 ------------------- .../services/mapbox/mapbox.service.spec.ts | 21 ------------------ 6 files changed, 2 insertions(+), 77 deletions(-) delete mode 100644 src/storeonwheels.client/src/app/libs/broadcast/services/geolocate/geolocate.service.spec.ts delete mode 100644 src/storeonwheels.client/src/app/libs/broadcast/services/vendor/vendor.service.spec.ts delete mode 100644 src/storeonwheels.client/src/app/libs/map/components/map/map.component.spec.ts delete mode 100644 src/storeonwheels.client/src/app/libs/map/services/mapbox/mapbox.service.spec.ts diff --git a/Makefile b/Makefile index 7b72782..3636de1 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/src/storeonwheels.client/src/app/libs/broadcast/services/geolocate/geolocate.service.spec.ts b/src/storeonwheels.client/src/app/libs/broadcast/services/geolocate/geolocate.service.spec.ts deleted file mode 100644 index 5baf8fa..0000000 --- a/src/storeonwheels.client/src/app/libs/broadcast/services/geolocate/geolocate.service.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { TestBed } from "@angular/core/testing"; - -import { GeolocateService } from "./geolocate.service"; - -describe("GeolocateService", () => { - let service: GeolocateService; - - beforeEach(() => { - TestBed.configureTestingModule({}); - service = TestBed.inject(GeolocateService); - }); - - it("should be created", () => { - expect(service).toBeTruthy(); - }); -}); diff --git a/src/storeonwheels.client/src/app/libs/broadcast/services/vendor/vendor.service.spec.ts b/src/storeonwheels.client/src/app/libs/broadcast/services/vendor/vendor.service.spec.ts deleted file mode 100644 index a5d5988..0000000 --- a/src/storeonwheels.client/src/app/libs/broadcast/services/vendor/vendor.service.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { TestBed } from "@angular/core/testing"; - -import { VendorService } from "./vendor.service"; - -describe("VendorService", () => { - let service: VendorService; - - beforeEach(() => { - TestBed.configureTestingModule({}); - service = TestBed.inject(VendorService); - }); - - it("should be created", () => { - expect(service).toBeTruthy(); - }); -}); diff --git a/src/storeonwheels.client/src/app/libs/broadcast/services/vendor/vendor.service.ts b/src/storeonwheels.client/src/app/libs/broadcast/services/vendor/vendor.service.ts index e79298f..59443c2 100644 --- a/src/storeonwheels.client/src/app/libs/broadcast/services/vendor/vendor.service.ts +++ b/src/storeonwheels.client/src/app/libs/broadcast/services/vendor/vendor.service.ts @@ -9,7 +9,7 @@ export class VendorService { async createVendor(vendor: Vendor): Promise { 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) { diff --git a/src/storeonwheels.client/src/app/libs/map/components/map/map.component.spec.ts b/src/storeonwheels.client/src/app/libs/map/components/map/map.component.spec.ts deleted file mode 100644 index e8752ab..0000000 --- a/src/storeonwheels.client/src/app/libs/map/components/map/map.component.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ComponentFixture, TestBed } from "@angular/core/testing"; - -import { MapComponent } from "./map.component"; - -describe("MapComponent", () => { - let component: MapComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [MapComponent], - }).compileComponents(); - - fixture = TestBed.createComponent(MapComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it("should create", () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/storeonwheels.client/src/app/libs/map/services/mapbox/mapbox.service.spec.ts b/src/storeonwheels.client/src/app/libs/map/services/mapbox/mapbox.service.spec.ts deleted file mode 100644 index f9393e1..0000000 --- a/src/storeonwheels.client/src/app/libs/map/services/mapbox/mapbox.service.spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { TestBed } from "@angular/core/testing"; - -import { MapboxService } from "./mapbox.service"; -import { MAPBOX_TOKEN, mapboxToken } from "./mapbox.service.provider"; - -describe("MapboxService", () => { - let service: MapboxService; - - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [ - { provide: MAPBOX_TOKEN, useValue: mapboxToken }, - ], - }); - service = TestBed.inject(MapboxService); - }); - - it("should be created", () => { - expect(service).toBeTruthy(); - }); -});