diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..5c33c2a --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,23 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '16' + registry-url: 'https://npm.pkg.github.com' + scope: '@insight-platform' + - name: Build the Docker image + run: docker build . --file projects/savant-lib/Dockerfile --tag savant-image + - name: Publish from image + run: docker run savant-image bash -c "npm config set @insight-platform:registry=https://npm.pkg.github.com; npm config set -- '//npm.pkg.github.com/:_authToken' '${{ secrets.GITHUB_TOKEN }}'; npm version patch; npm publish" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..199f31c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,37 @@ +name: savant-github-actions +on: [push] +jobs: + check-packages: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: '16' + - run: npm install + lint: + runs-on: ubuntu-latest + steps: + - name: Base checkout + uses: actions/checkout@v4 + - name: Base node + uses: actions/setup-node@v3 + with: + node-version: '16' + - name: Install dependencies + run: npm install + - name: Linting + run: npm run lint + test: + runs-on: ubuntu-latest + steps: + - name: Base checkout + uses: actions/checkout@v4 + - name: Base node + uses: actions/setup-node@v3 + with: + node-version: '16' + - name: Install dependencies + run: npm install + - name: Testing + run: npm run test \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..b0fb8d5 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +@savant:registry=https://npm.pkg.github.com +//npm.pkg.github.com/:_authToken=${TOKEN} \ No newline at end of file diff --git a/angular.json b/angular.json index 68815cc..68639cb 100644 --- a/angular.json +++ b/angular.json @@ -95,6 +95,7 @@ "zone.js/testing" ], "tsConfig": "tsconfig.spec.json", + "karmaConfig": "karma.conf.js", "inlineStyleLanguage": "scss", "assets": [ "src/favicon.ico", @@ -142,11 +143,9 @@ "test": { "builder": "@angular-devkit/build-angular:karma", "options": { + "main": "projects/savant-lib/src/test.ts", "tsConfig": "projects/savant-lib/tsconfig.spec.json", - "polyfills": [ - "zone.js", - "zone.js/testing" - ] + "karmaConfig": "projects/savant-lib/karma.conf.js" } }, "lint": { diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000..9817b4a --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,58 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: 'src', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-spec-reporter'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage'), + require('@angular-devkit/build-angular/plugins/karma') + ], + browsers: ['ChromeHeadlessNoSandbox'], + client: { + jasmine: { + // you can add configuration options for Jasmine here + // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html + // for example, you can disable the random execution with `random: false` + // or set a specific seed with `seed: 4321` + }, + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + jasmineHtmlReporter: { + suppressAll: true // removes the duplicated traces + }, + coverageReporter: { + dir: require('path').join(__dirname, '../../coverage/savant'), + subdir: '.', + reporters: [ + { type: 'html' }, + { type: 'text-summary' } + ] + }, + customLaunchers: { + ChromeHeadlessNoSandbox: { + base: 'ChromeHeadless', + flags: [ + '--headless', + '--disable-gpu', + '--no-sandbox' + ] + }, + }, + reporters: ['progress', 'spec', 'kjhtml'], + specReporter: { + suppressSkipped: true, + }, + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + singleRun: true, + restartOnFileChange: true + }); +}; diff --git a/package-lock.json b/package-lock.json index 03f552f..5d09e90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,6 +47,8 @@ "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.1.0", + "karma-spec-reporter": "^0.0.36", + "ng-mocks": "^14.11.0", "ng-packagr": "^16.2.0", "typescript": "~5.1.3" } @@ -6708,6 +6710,15 @@ "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", "dev": true }, + "node_modules/colors": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", + "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", + "dev": true, + "engines": { + "node": ">=0.1.90" + } + }, "node_modules/combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -10812,6 +10823,18 @@ "source-map-support": "^0.5.5" } }, + "node_modules/karma-spec-reporter": { + "version": "0.0.36", + "resolved": "https://registry.npmjs.org/karma-spec-reporter/-/karma-spec-reporter-0.0.36.tgz", + "integrity": "sha512-11bvOl1x6ryKZph7kmbmMpbi8vsngEGxGOoeTlIcDaH3ab3j8aPJnZ+r+K/SS0sBSGy5VGkGYO2+hLct7hw/6w==", + "dev": true, + "dependencies": { + "colors": "1.4.0" + }, + "peerDependencies": { + "karma": ">=0.9" + } + }, "node_modules/karma/node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -11778,6 +11801,21 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "node_modules/ng-mocks": { + "version": "14.11.0", + "resolved": "https://registry.npmjs.org/ng-mocks/-/ng-mocks-14.11.0.tgz", + "integrity": "sha512-6h0TafPogU7iEbWKGQt5npfEtI7IjThsqqnDboMIZ4AJyUY7VHUmhFa39Zkd2e4oOLDLb/6sVnfDIaWCp3oFgQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/satanTime" + }, + "peerDependencies": { + "@angular/common": "5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14 || 15.0.0-alpha - 15 || 16.0.0-alpha - 16", + "@angular/core": "5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14 || 15.0.0-alpha - 15 || 16.0.0-alpha - 16", + "@angular/forms": "5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14 || 15.0.0-alpha - 15 || 16.0.0-alpha - 16", + "@angular/platform-browser": "5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14 || 15.0.0-alpha - 15 || 16.0.0-alpha - 16" + } + }, "node_modules/ng-packagr": { "version": "16.2.3", "resolved": "https://registry.npmjs.org/ng-packagr/-/ng-packagr-16.2.3.tgz", diff --git a/package.json b/package.json index 88d94e0..bcb1df1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,13 @@ { "name": "savant-metadata-explorer", "version": "0.0.0", + "repository": { + "type": "git", + "url": "https://github.com/insight-platform/SavantMetadataExplorer.git" + }, + "publishConfig": { + "registry": "https://npm.pkg.github.com" + }, "scripts": { "ng": "ng", "start": "ng serve", @@ -52,6 +59,8 @@ "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.1.0", + "karma-spec-reporter": "^0.0.36", + "ng-mocks": "^14.11.0", "ng-packagr": "^16.2.0", "typescript": "~5.1.3" } diff --git a/projects/savant-lib/Dockerfile b/projects/savant-lib/Dockerfile new file mode 100644 index 0000000..cd72a3b --- /dev/null +++ b/projects/savant-lib/Dockerfile @@ -0,0 +1,8 @@ +FROM node:18.17.1 +WORKDIR /tmp/savant-lib +COPY package.json package-lock.json /tmp/savant-lib/ +RUN npm install +COPY . /tmp/savant-lib +RUN npm run build:savant-lib + +WORKDIR /tmp/savant-lib/dist/savant-lib diff --git a/projects/savant-lib/karma.conf.js b/projects/savant-lib/karma.conf.js new file mode 100644 index 0000000..b71adee --- /dev/null +++ b/projects/savant-lib/karma.conf.js @@ -0,0 +1,58 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-spec-reporter'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage'), + require('@angular-devkit/build-angular/plugins/karma') + ], + browsers: ['ChromeHeadlessNoSandbox'], + client: { + jasmine: { + // you can add configuration options for Jasmine here + // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html + // for example, you can disable the random execution with `random: false` + // or set a specific seed with `seed: 4321` + }, + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + jasmineHtmlReporter: { + suppressAll: true // removes the duplicated traces + }, + coverageReporter: { + dir: require('path').join(__dirname, '../../coverage/savant-lib'), + subdir: '.', + reporters: [ + { type: 'html' }, + { type: 'text-summary' } + ] + }, + customLaunchers: { + ChromeHeadlessNoSandbox: { + base: 'ChromeHeadless', + flags: [ + '--headless', + '--disable-gpu', + '--no-sandbox' + ] + }, + }, + reporters: ['progress', 'spec', 'kjhtml'], + specReporter: { + suppressSkipped: true, + }, + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + singleRun: true, + restartOnFileChange: true + }); +}; diff --git a/projects/savant-lib/package.json b/projects/savant-lib/package.json index 2c4f628..3cacc4e 100644 --- a/projects/savant-lib/package.json +++ b/projects/savant-lib/package.json @@ -1,6 +1,10 @@ { - "name": "@savant/savant-lib", + "name": "@insight-platform/savant-lib", "version": "0.0.1", + "repository": { + "type": "git", + "url": "https://github.com/insight-platform/SavantMetadataExplorer.git" + }, "exports": { "./theming": { "sass": [ diff --git a/projects/savant-lib/src/components/frame/frame-container/frame-container.component.spec.ts b/projects/savant-lib/src/components/frame/frame-container/frame-container.component.spec.ts index 6c4e72f..ec8c762 100644 --- a/projects/savant-lib/src/components/frame/frame-container/frame-container.component.spec.ts +++ b/projects/savant-lib/src/components/frame/frame-container/frame-container.component.spec.ts @@ -1,6 +1,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FrameContainerComponent } from './frame-container.component'; +import { MockComponent, MockModule } from 'ng-mocks'; +import { FrameTreeComponent } from '../frame-tree/frame-tree.component'; +import { SharedModule } from '../../../utils'; describe('FrameContainerComponent', () => { let component: FrameContainerComponent; @@ -8,7 +11,10 @@ describe('FrameContainerComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [FrameContainerComponent] + declarations: [FrameContainerComponent, MockComponent(FrameTreeComponent)], + imports: [ + MockModule(SharedModule), + ], }); fixture = TestBed.createComponent(FrameContainerComponent); component = fixture.componentInstance; diff --git a/projects/savant-lib/src/components/frame/frame-details/frame-details.component.spec.ts b/projects/savant-lib/src/components/frame/frame-details/frame-details.component.spec.ts index 263fd5b..ea091b4 100644 --- a/projects/savant-lib/src/components/frame/frame-details/frame-details.component.spec.ts +++ b/projects/savant-lib/src/components/frame/frame-details/frame-details.component.spec.ts @@ -1,6 +1,13 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FrameDetailsComponent } from './frame-details.component'; +import { MatSnackBarModule } from '@angular/material/snack-bar'; +import { MockComponent } from 'ng-mocks'; +import { FrameTreeComponent } from '../frame-tree/frame-tree.component'; +import { frame } from '../../../../../../src/app/api/models/data'; +import { SharedModule } from '../../../utils'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { MatExpansionModule } from '@angular/material/expansion'; describe('FrameDetailsComponent', () => { let component: FrameDetailsComponent; @@ -8,10 +15,17 @@ describe('FrameDetailsComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [FrameDetailsComponent] + declarations: [FrameDetailsComponent, MockComponent(FrameTreeComponent)], + imports: [ + MatSnackBarModule, + SharedModule, + BrowserAnimationsModule, + MatExpansionModule, + ] }); fixture = TestBed.createComponent(FrameDetailsComponent); component = fixture.componentInstance; + fixture.componentInstance.frame = frame fixture.detectChanges(); }); diff --git a/projects/savant-lib/src/components/frame/object-details/object-details.component.spec.ts b/projects/savant-lib/src/components/frame/object-details/object-details.component.spec.ts index c1b75fa..e76405e 100644 --- a/projects/savant-lib/src/components/frame/object-details/object-details.component.spec.ts +++ b/projects/savant-lib/src/components/frame/object-details/object-details.component.spec.ts @@ -1,6 +1,11 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ObjectDetailsComponent } from './object-details.component'; +import { MatSnackBarModule } from '@angular/material/snack-bar'; +import { object } from '../../../../../../src/app/api/models/data'; +import { SharedModule } from '../../../utils'; +import { MatExpansionModule } from '@angular/material/expansion'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('ObjectDetailsComponent', () => { let component: ObjectDetailsComponent; @@ -8,10 +13,17 @@ describe('ObjectDetailsComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [ObjectDetailsComponent] + declarations: [ObjectDetailsComponent], + imports: [ + MatSnackBarModule, + SharedModule, + MatExpansionModule, + BrowserAnimationsModule, + ], }); fixture = TestBed.createComponent(ObjectDetailsComponent); component = fixture.componentInstance; + fixture.componentInstance.frameObject = object; fixture.detectChanges(); }); diff --git a/projects/savant-lib/src/test.ts b/projects/savant-lib/src/test.ts new file mode 100644 index 0000000..4380836 --- /dev/null +++ b/projects/savant-lib/src/test.ts @@ -0,0 +1,15 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js'; +import 'zone.js/testing'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting(), +); diff --git a/projects/savant-lib/src/utils/components/log-filter/log-filter.component.spec.ts b/projects/savant-lib/src/utils/components/log-filter/log-filter.component.spec.ts index 195adf8..e43d476 100644 --- a/projects/savant-lib/src/utils/components/log-filter/log-filter.component.spec.ts +++ b/projects/savant-lib/src/utils/components/log-filter/log-filter.component.spec.ts @@ -1,6 +1,13 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { LogFilterComponent } from './log-filter.component'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatSelectModule } from '@angular/material/select'; +import { MatInputModule } from '@angular/material/input'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { MockComponent } from 'ng-mocks'; +import { SpanSelectorComponent } from '../span-selector/span-selector.component'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; describe('LogFilterComponent', () => { let component: LogFilterComponent; @@ -8,7 +15,15 @@ describe('LogFilterComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [LogFilterComponent] + declarations: [LogFilterComponent, MockComponent(SpanSelectorComponent)], + imports: [ + MatFormFieldModule, + MatSelectModule, + MatInputModule, + BrowserAnimationsModule, + FormsModule, + ReactiveFormsModule, + ] }); fixture = TestBed.createComponent(LogFilterComponent); component = fixture.componentInstance; diff --git a/projects/savant-lib/src/utils/components/object-filter/object-filter.component.spec.ts b/projects/savant-lib/src/utils/components/object-filter/object-filter.component.spec.ts index 12d71ad..bd3d6c2 100644 --- a/projects/savant-lib/src/utils/components/object-filter/object-filter.component.spec.ts +++ b/projects/savant-lib/src/utils/components/object-filter/object-filter.component.spec.ts @@ -1,6 +1,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ObjectFilterComponent } from './object-filter.component'; +import { MatSelectModule } from '@angular/material/select'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; describe('ObjectFilterComponent', () => { let component: ObjectFilterComponent; @@ -8,7 +12,14 @@ describe('ObjectFilterComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [ObjectFilterComponent] + declarations: [ObjectFilterComponent], + imports: [ + MatSelectModule, + MatFormFieldModule, + FormsModule, + ReactiveFormsModule, + BrowserAnimationsModule, + ], }); fixture = TestBed.createComponent(ObjectFilterComponent); component = fixture.componentInstance; diff --git a/projects/savant-lib/src/utils/components/property-list/property-list.component.spec.ts b/projects/savant-lib/src/utils/components/property-list/property-list.component.spec.ts index aabc691..2c25c06 100644 --- a/projects/savant-lib/src/utils/components/property-list/property-list.component.spec.ts +++ b/projects/savant-lib/src/utils/components/property-list/property-list.component.spec.ts @@ -1,6 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { PropertyListComponent } from './property-list.component'; +import { MatTableModule } from '@angular/material/table'; +import { MatExpansionModule } from '@angular/material/expansion'; describe('PropertyListComponent', () => { let component: PropertyListComponent; @@ -8,7 +10,11 @@ describe('PropertyListComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [PropertyListComponent] + declarations: [PropertyListComponent], + imports: [ + MatTableModule, + MatExpansionModule, + ], }); fixture = TestBed.createComponent(PropertyListComponent); component = fixture.componentInstance; diff --git a/projects/savant-lib/src/utils/components/side-actions/side-actions.component.spec.ts b/projects/savant-lib/src/utils/components/side-actions/side-actions.component.spec.ts index 98aeb8e..ac5a7cf 100644 --- a/projects/savant-lib/src/utils/components/side-actions/side-actions.component.spec.ts +++ b/projects/savant-lib/src/utils/components/side-actions/side-actions.component.spec.ts @@ -1,6 +1,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { SideActionsComponent } from './side-actions.component'; +import { MatIconModule } from '@angular/material/icon'; +import { MatButtonModule } from '@angular/material/button'; +import { MatTooltipModule } from '@angular/material/tooltip'; describe('SideActionsComponent', () => { let component: SideActionsComponent; @@ -8,7 +11,12 @@ describe('SideActionsComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [SideActionsComponent] + declarations: [SideActionsComponent], + imports: [ + MatIconModule, + MatButtonModule, + MatTooltipModule, + ], }); fixture = TestBed.createComponent(SideActionsComponent); component = fixture.componentInstance; diff --git a/projects/savant-lib/tsconfig.lib.json b/projects/savant-lib/tsconfig.lib.json index 543fd47..b77b13c 100644 --- a/projects/savant-lib/tsconfig.lib.json +++ b/projects/savant-lib/tsconfig.lib.json @@ -9,6 +9,7 @@ "types": [] }, "exclude": [ + "src/test.ts", "**/*.spec.ts" ] } diff --git a/projects/savant-lib/tsconfig.spec.json b/projects/savant-lib/tsconfig.spec.json index ce7048b..715dd0a 100644 --- a/projects/savant-lib/tsconfig.spec.json +++ b/projects/savant-lib/tsconfig.spec.json @@ -7,6 +7,9 @@ "jasmine" ] }, + "files": [ + "src/test.ts" + ], "include": [ "**/*.spec.ts", "**/*.d.ts" diff --git a/src/app/api/models/data.ts b/src/app/api/models/data.ts index bc43a1c..0d36760 100644 --- a/src/app/api/models/data.ts +++ b/src/app/api/models/data.ts @@ -1,4 +1,261 @@ -import { ITrace } from 'savant-lib'; +import { IFrameJson, IFrameJsonObject, ITrace } from '../../../../projects/savant-lib/src/models/model'; + +export const frame: IFrameJson = { + attributes: [ + { + hint: 'PlatformConfig', + is_persistent: true, + name: 'CamMode', + namespace: 'Configuration', + values: [ + { + confidence: null, + value: { + String: 'fisheye', + }, + }, + { + confidence: null, + value: { + IntegerVector: [ + 200, + 200, + ], + }, + }, + ], + }, + ], + codec: 'h264', + content: { + external: { + location: '1111', + method: 'redis', + }, + }, + creation_timestamp_ns: 1695888065807941620, + dts: 10000, + duration: 10, + framerate: '30/1', + height: 720, + keyframe: true, + pts: 10000, + source_id: 'test', + time_base: [ + 1, + 1000000, + ], + transcoding_method: 'Encoded', + transformations: [ + { + initial_size: [ + 1920, + 1080, + ], + }, + { + scale: [ + 1280, + 720, + ], + }, + { + padding: [ + 120, + 0, + 0, + 0, + ], + }, + { + resulting_size: [ + 1400, + 720, + ], + }, + ], + type: 'VideoFrame', + uuid: 'fb736fa2-86e9-4073-b88a-b8985ae8a00b', + version: '0.1.70', + width: 1400, + objects: [ + { + attributes: [], + bbox: { + angle: null, + height: 0, + width: 0, + xc: 0, + yc: 0, + }, + confidence: null, + draw_label: null, + frame: 'test1', + id: 0, + label: 'test2', + namespace: 'test', + parent: null, + pyobjects: 'not_implemented', + track_box: null, + track_id: null, + }, + { + attributes: [], + bbox: { + angle: null, + height: 0, + width: 0, + xc: 0, + yc: 0, + }, + confidence: null, + draw_label: null, + frame: 'test1', + id: 1, + label: 'test', + namespace: 'test2', + parent: 0, + pyobjects: 'not_implemented', + track_box: null, + track_id: null, + }, + { + attributes: [], + bbox: { + angle: null, + height: 0, + width: 0, + xc: 0, + yc: 0, + }, + confidence: null, + draw_label: null, + frame: 'test1', + id: 2, + label: 'test2', + namespace: 'test2', + parent: 0, + pyobjects: 'not_implemented', + track_box: null, + track_id: null, + }, + { + attributes: [ + { + hint: 'PlatformConfig', + is_persistent: true, + name: 'CamMode', + namespace: 'Configuration', + values: [ + { + confidence: null, + value: { + String: 'fisheye', + }, + }, + ], + }, + ], + bbox: { + angle: null, + height: 10, + width: 10, + xc: 0, + yc: 0, + }, + confidence: null, + draw_label: null, + frame: 'test1', + id: 3, + label: 'test2', + namespace: 'test2', + parent: 2, + pyobjects: 'not_implemented', + track_box: null, + track_id: null, + }, + { + attributes: [], + bbox: { + angle: null, + height: 40, + width: 40, + xc: 0, + yc: 0, + }, + confidence: null, + draw_label: null, + frame: 'test1', + id: 4, + label: 'test', + namespace: 'test2', + parent: 1, + pyobjects: 'not_implemented', + track_box: null, + track_id: null, + }, + { + attributes: [], + bbox: { + angle: null, + height: 0, + width: 0, + xc: 0, + yc: 0, + }, + confidence: null, + draw_label: null, + frame: 'test1', + id: 5, + label: 'test', + namespace: 'test2', + parent: 1, + pyobjects: 'not_implemented', + track_box: null, + track_id: null, + }, + { + attributes: [], + bbox: { + angle: null, + height: 0, + width: 0, + xc: 0, + yc: 0, + }, + confidence: null, + draw_label: null, + frame: 'test1', + id: 6, + label: 'test2', + namespace: 'test2', + parent: 3, + pyobjects: 'not_implemented', + track_box: null, + track_id: null, + }, + ], +}; +export const object: IFrameJsonObject = { + attributes: [], + bbox: { + angle: null, + height: 0, + width: 0, + xc: 0, + yc: 0, + }, + confidence: null, + draw_label: null, + frame: 'test1', + id: 0, + label: 'test2', + namespace: 'test', + parent: null, + pyobjects: 'not_implemented', + track_box: null, + track_id: null, +}; export const data: ITrace = { traceID: 'cb8b182cff2f87b73b5d1fcbe0bb846d', @@ -56,27 +313,27 @@ export const data: ITrace = { { confidence: null, value: { - String: 'fisheye' - } + String: 'fisheye', + }, }, { confidence: null, value: { IntegerVector: [ 200, - 200 - ] - } - } - ] - } + 200, + ], + }, + }, + ], + }, ], codec: 'h264', content: { external: { location: '1111', - method: 'redis' - } + method: 'redis', + }, }, creation_timestamp_ns: 1695888065807941620, dts: 10000, @@ -88,36 +345,36 @@ export const data: ITrace = { source_id: 'test', time_base: [ 1, - 1000000 + 1000000, ], transcoding_method: 'Encoded', transformations: [ { initial_size: [ 1920, - 1080 - ] + 1080, + ], }, { scale: [ 1280, - 720 - ] + 720, + ], }, { padding: [ 120, 0, 0, - 0 - ] + 0, + ], }, { resulting_size: [ 1400, - 720 - ] - } + 720, + ], + }, ], type: 'VideoFrame', uuid: 'fb736fa2-86e9-4073-b88a-b8985ae8a00b', @@ -195,11 +452,11 @@ export const data: ITrace = { { confidence: null, value: { - String: 'fisheye' - } + String: 'fisheye', + }, }, - ] - } + ], + }, ], bbox: { angle: null, @@ -326,24 +583,24 @@ export const data: ITrace = { { confidence: null, value: { - String: 'fisheye' - } + String: 'fisheye', + }, }, { confidence: null, value: { IntegerVector: [ 180, - 180 - ] - } - } - ] - } + 180, + ], + }, + }, + ], + }, ], codec: 'h264', content: { - internal: null + internal: null, }, creation_timestamp_ns: 1695888352201220391, dts: 10000, @@ -355,36 +612,36 @@ export const data: ITrace = { source_id: 'test', time_base: [ 1, - 1000000 + 1000000, ], transcoding_method: 'Encoded', transformations: [ { initial_size: [ 1920, - 1080 - ] + 1080, + ], }, { scale: [ 1280, - 720 - ] + 720, + ], }, { padding: [ 120, 0, 0, - 0 - ] + 0, + ], }, { resulting_size: [ 1400, - 720 - ] - } + 720, + ], + }, ], type: 'VideoFrame', uuid: '5b031cbc-ccd8-4e58-9f47-4d56b29c9c7c', diff --git a/src/app/api/services/trace.service.ts b/src/app/api/services/trace.service.ts index 465c2ac..83b3253 100644 --- a/src/app/api/services/trace.service.ts +++ b/src/app/api/services/trace.service.ts @@ -2,8 +2,8 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { catchError, map, Observable, of } from 'rxjs'; import { MatSnackBar } from '@angular/material/snack-bar'; -import { IData, ITrace } from 'savant-lib'; import { data } from '../models/data'; +import { IData, ITrace } from '../../../../projects/savant-lib/src/models/model'; @Injectable({ providedIn: 'root', diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 41bcf1a..0414dce 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,9 +1,12 @@ import { TestBed } from '@angular/core/testing'; import { AppComponent } from './app.component'; +import { TraceModule } from './trace/trace.module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('AppComponent', () => { beforeEach(() => TestBed.configureTestingModule({ - declarations: [AppComponent] + declarations: [AppComponent], + imports: [TraceModule, HttpClientTestingModule,], })); it('should create the app', () => { @@ -11,17 +14,4 @@ describe('AppComponent', () => { const app = fixture.componentInstance; expect(app).toBeTruthy(); }); - - it(`should have as title 'SavantMetadataExplorer'`, () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('SavantMetadataExplorer'); - }); - - it('should render title', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.nativeElement as HTMLElement; - expect(compiled.querySelector('.content span')?.textContent).toContain('SavantMetadataExplorer app is running!'); - }); }); diff --git a/src/app/trace/trace-container/trace-container.component.spec.ts b/src/app/trace/trace-container/trace-container.component.spec.ts index 0012ba2..6b4a50c 100644 --- a/src/app/trace/trace-container/trace-container.component.spec.ts +++ b/src/app/trace/trace-container/trace-container.component.spec.ts @@ -1,6 +1,19 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { TraceContainerComponent } from './trace-container.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { MatSnackBarModule } from '@angular/material/snack-bar'; +import { MatToolbarModule } from '@angular/material/toolbar'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatInputModule } from '@angular/material/input'; +import { MatIconModule } from '@angular/material/icon'; +import { MatButtonToggleModule } from '@angular/material/button-toggle'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { MatButtonModule } from '@angular/material/button'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { SharedModule } from '../../../../projects/savant-lib/src/utils'; +import { FrameModule, LogModule, SpanModule } from '../../../../projects/savant-lib/src/components'; describe('TraceContainerComponent', () => { let component: TraceContainerComponent; @@ -8,7 +21,25 @@ describe('TraceContainerComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [TraceContainerComponent] + declarations: [TraceContainerComponent], + imports: [ + HttpClientTestingModule, + MatToolbarModule, + MatFormFieldModule, + MatInputModule, + MatIconModule, + MatButtonToggleModule, + ReactiveFormsModule, + FormsModule, + MatSnackBarModule, + SharedModule, + SpanModule, + MatTooltipModule, + MatButtonModule, + FrameModule, + LogModule, + BrowserAnimationsModule, + ], }); fixture = TestBed.createComponent(TraceContainerComponent); component = fixture.componentInstance; diff --git a/src/app/trace/trace-container/trace-container.component.ts b/src/app/trace/trace-container/trace-container.component.ts index 51f2260..e6755bc 100644 --- a/src/app/trace/trace-container/trace-container.component.ts +++ b/src/app/trace/trace-container/trace-container.component.ts @@ -1,8 +1,15 @@ import { Component } from '@angular/core'; -import { IFrameJson, ILogFilter, ISpan, ITreeSpan, ReferenceType, Palette } from 'savant-lib'; import { isNil, uniq } from 'lodash'; import { FormControl } from '@angular/forms'; import { TraceService } from '../../api/services/trace.service'; +import { Palette } from '../../../../projects/savant-lib/src/utils'; +import { + IFrameJson, + ILogFilter, + ISpan, + ITreeSpan, + ReferenceType, +} from '../../../../projects/savant-lib/src/models/model'; @Component({ selector: 'savant-trace-container', diff --git a/src/app/trace/trace.module.ts b/src/app/trace/trace.module.ts index 48b6a86..95a6a2e 100644 --- a/src/app/trace/trace.module.ts +++ b/src/app/trace/trace.module.ts @@ -6,11 +6,12 @@ import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { MatIconModule } from '@angular/material/icon'; import { MatButtonToggleModule } from '@angular/material/button-toggle'; -import { FrameModule, LogModule, SharedModule, SpanModule } from 'savant-lib'; import { MatTooltipModule } from '@angular/material/tooltip'; import { MatButtonModule } from '@angular/material/button'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatSnackBarModule } from '@angular/material/snack-bar'; +import { SharedModule } from '../../../projects/savant-lib/src/utils'; +import { FrameModule, LogModule, SpanModule } from '../../../projects/savant-lib/src/components'; @NgModule({ declarations: [ diff --git a/src/test.ts b/src/test.ts new file mode 100644 index 0000000..51bb020 --- /dev/null +++ b/src/test.ts @@ -0,0 +1,14 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/testing'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting(), +); diff --git a/tsconfig.spec.json b/tsconfig.spec.json index be7e9da..79ed86e 100644 --- a/tsconfig.spec.json +++ b/tsconfig.spec.json @@ -2,11 +2,14 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "./out-tsc/spec", + "outDir": "../../out-tsc/spec", "types": [ "jasmine" ] }, + "files": [ + "src/test.ts" + ], "include": [ "src/**/*.spec.ts", "src/**/*.d.ts"