From 3ff9624565982b406fcbfd8f1e2d758add7cd181 Mon Sep 17 00:00:00 2001 From: Alex Graf Date: Tue, 20 Feb 2024 15:48:34 +0100 Subject: [PATCH] clean unit-tests and fix lint errors --- .github/workflows/ci.yml | 15 +++++---- README.md | 33 ++++++++++++------- apps/client-asset-sg-e2e/cypress.config.ts | 2 +- .../src/app/app.component.spec.ts | 31 ----------------- .../src/app/app.controller.spec.ts | 22 ------------- .../src/app/app.service.spec.ts | 21 ------------ .../src/lib/models/all-study-dto.ts | 2 +- .../lib/models/client-asset-search-params.ts | 2 +- 8 files changed, 32 insertions(+), 96 deletions(-) delete mode 100644 apps/client-asset-sg/src/app/app.component.spec.ts delete mode 100644 apps/server-asset-sg/src/app/app.controller.spec.ts delete mode 100644 apps/server-asset-sg/src/app/app.service.spec.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5ff10dff..230bfe31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,7 @@ name: CI on: + push: workflow_dispatch: jobs: @@ -16,10 +17,10 @@ jobs: with: node-version: 20 cache: 'npm' - - - name: npm install, build, test, lint - run: | - npm ci - npm run build - npm run test - npm run lint \ No newline at end of file + + - run: npm ci + - run: npm run build + - run: npm run test + - run: npm run lint + + diff --git a/README.md b/README.md index d52c6959..92beb409 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ The following steps must be carried out once: 3. Set environment variables for dockers in `web-asset-swissgeol\development\.env` 4. Set environment variables for assets-server in `web-asset-swissgeol\apps\server-asset-sg\.env.local` 5. Create local postgis-gotrue docker-image `development\images\db> docker build -t postgis-gotrue .` +6. Creating elastic-search index. Execute in Kibana (`http://localhost:5601/app/dev_tools#/console`) the commands fro file `web-asset-swissgeol\development\init\elasticsearch\index`. --> docker must be started (see below) ### Starting the development environment @@ -24,18 +25,26 @@ The following steps must be carried out once: **The following services/applications are then available** -| 🔖 Dienst/Anwendung | 🔗Adresse | 🧞Benutzername | 🔐Passwort | -| :----------------------| :------------------------------------------------| :---------------------| :---------------------- | -| Assets | [localhost:4200](http://localhost:4200/) | `admin@assets.sg` | `adminAssets` | -| Assets REST API | [localhost:3333/api/](http://localhost:3333/api) | n/a | n/a | -| postgresSQL (docker) | localhost:5432 | .env `$DB_USER` |.env `$DB_PASSWORD` | -| Elasticsearch (docker) | [localhost:9200](http://localhost:9200) | n/a | n/a | -| Kibana (docker) | [localhost:5601](http://localhost:5601) | n/a | n/a | -| pgAdmin (docker) | [localhost:5051](http://localhost:5051/) | .env `$PGADMIN_EMAIL` |.env `$PGADMIN_PASSWORD` | -| MinIO (docker) | [localhost:9001](http://localhost:9001/) | .env `$STORAGE_USER` |.env `$STORAGE_PASSWORD` | -| smtp4dev (docker) | [localhost:5000](http://localhost:5000/) | n/a | n/a | +| 🔖 App/Service | 🔗Link | 🧞User | 🔐Password | +| :---------------------- --| :------------------------------------------------| :---------------------| :---------------------- | +| Assets (client) | [localhost:4200](http://localhost:4200/) | `admin@assets.sg` | `adminAssets` | +| Assets REST API (server) | [localhost:3333/api/](http://localhost:3333/api) | n/a | n/a | +| postgresSQL (docker) | localhost:5432 | .env `$DB_USER` |.env `$DB_PASSWORD` | +| Elasticsearch (docker) | [localhost:9200](http://localhost:9200) | n/a | n/a | +| Kibana (docker) | [localhost:5601](http://localhost:5601) | n/a | n/a | +| pgAdmin (docker) | [localhost:5051](http://localhost:5051/) | .env `$PGADMIN_EMAIL` |.env `$PGADMIN_PASSWORD` | +| MinIO (docker) | [localhost:9001](http://localhost:9001/) | .env `$STORAGE_USER` |.env `$STORAGE_PASSWORD` | +| smtp4dev (docker) | [localhost:5000](http://localhost:5000/) | n/a | n/a | ### Creating elastic-search index -1. Execute in Kibana (`http://localhost:5601/app/dev_tools#/console`) the commands fro file `web-asset-swissgeol\development\init\elasticsearch\index`. - \ No newline at end of file + + +### Commands in development environment + +| Action | Command | Description | +| :------| :------------------------------------| :-----------------------------------------| +| start | `web-asset-swissgeol> npm run start` | Starts asset-client and asset-api. | +| build | `web-asset-swissgeol> npm run build` | Builds asset-client and asset-api. | +| test | `web-asset-swissgeol> npm run test` | Executes tests all apps and libs. | +| lint | `web-asset-swissgeol> npm run lint` | Analyzes the code from all apps and libs. | diff --git a/apps/client-asset-sg-e2e/cypress.config.ts b/apps/client-asset-sg-e2e/cypress.config.ts index ec4ed885..39337d99 100644 --- a/apps/client-asset-sg-e2e/cypress.config.ts +++ b/apps/client-asset-sg-e2e/cypress.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'cypress'; import { nxE2EPreset } from '@nrwl/cypress/plugins/cypress-preset'; +import { defineConfig } from 'cypress'; export default defineConfig({ e2e: nxE2EPreset(__dirname), diff --git a/apps/client-asset-sg/src/app/app.component.spec.ts b/apps/client-asset-sg/src/app/app.component.spec.ts deleted file mode 100644 index 5c44f3d5..00000000 --- a/apps/client-asset-sg/src/app/app.component.spec.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { TestBed } from '@angular/core/testing'; - -import { AppComponent } from './app.component'; -import { NxWelcomeComponent } from './nx-welcome.component'; - -describe('AppComponent', () => { - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [AppComponent, NxWelcomeComponent], - }).compileComponents(); - }); - - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - }); - - it(`should have as title 'client-asset-sg'`, () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('client-asset-sg'); - }); - - it('should render title', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.nativeElement as HTMLElement; - expect(compiled.querySelector('h1')?.textContent).toContain('Welcome client-asset-sg'); - }); -}); diff --git a/apps/server-asset-sg/src/app/app.controller.spec.ts b/apps/server-asset-sg/src/app/app.controller.spec.ts deleted file mode 100644 index e487446f..00000000 --- a/apps/server-asset-sg/src/app/app.controller.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; - -import { AppController } from './app.controller'; -import { AppService } from './app.service'; - -describe('AppController', () => { - let app: TestingModule; - - beforeAll(async () => { - app = await Test.createTestingModule({ - controllers: [AppController], - providers: [AppService], - }).compile(); - }); - - describe('getData', () => { - it('should return "Welcome to api!"', () => { - const appController = app.get(AppController); - expect(appController.getData()).toEqual({ message: 'Welcome to api!' }); - }); - }); -}); diff --git a/apps/server-asset-sg/src/app/app.service.spec.ts b/apps/server-asset-sg/src/app/app.service.spec.ts deleted file mode 100644 index 063c2830..00000000 --- a/apps/server-asset-sg/src/app/app.service.spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Test } from '@nestjs/testing'; - -import { AppService } from './app.service'; - -describe('AppService', () => { - let service: AppService; - - beforeAll(async () => { - const app = await Test.createTestingModule({ - providers: [AppService], - }).compile(); - - service = app.get(AppService); - }); - - describe('getData', () => { - it('should return "Welcome to api!"', () => { - expect(service.getData()).toEqual({ message: 'Welcome to api!' }); - }); - }); -}); diff --git a/libs/asset-viewer/src/lib/models/all-study-dto.ts b/libs/asset-viewer/src/lib/models/all-study-dto.ts index 438a6db7..fd6b9f66 100644 --- a/libs/asset-viewer/src/lib/models/all-study-dto.ts +++ b/libs/asset-viewer/src/lib/models/all-study-dto.ts @@ -2,7 +2,7 @@ import * as D from 'io-ts/Decoder'; import * as TEq from 'io-ts/Eq'; import { Equals, assert } from 'tsafe'; -import { AllStudyDTOFromAPI, eqLV95, LV95 } from '@asset-sg/shared'; +import { AllStudyDTOFromAPI, LV95, eqLV95 } from '@asset-sg/shared'; export const AllStudyDTO = D.struct({ studyId: D.string, diff --git a/libs/asset-viewer/src/lib/models/client-asset-search-params.ts b/libs/asset-viewer/src/lib/models/client-asset-search-params.ts index f1a9e679..a5cabc5f 100644 --- a/libs/asset-viewer/src/lib/models/client-asset-search-params.ts +++ b/libs/asset-viewer/src/lib/models/client-asset-search-params.ts @@ -9,7 +9,7 @@ import * as C from 'io-ts/Codec'; import * as D from 'io-ts/Decoder'; import { CT } from '@asset-sg/core'; -import { DateId, eqLV95, LV95 } from '@asset-sg/shared'; +import { DateId, LV95, eqLV95 } from '@asset-sg/shared'; export const RefinementGeomCode = C.fromDecoder( D.union(D.literal('Point'), D.literal('Polygon'), D.literal('LineString'), D.literal('None')),