Skip to content

Commit 88e86e6

Browse files
committed
Fixed unit test
1 parent e14c001 commit 88e86e6

File tree

8 files changed

+93
-9
lines changed

8 files changed

+93
-9
lines changed

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ FROM node:22-alpine AS build
55
WORKDIR /ng-app
66
# Add project into container, install dependencies
77

8-
ADD .yarn yarn.lock package.json angular.json tsconfig.json tsconfig.app.json /ng-app/
9-
ADD src/ /ng-app/src/
8+
COPY .yarn yarn.lock package.json angular.json tsconfig.json tsconfig.app.json /ng-app/
9+
COPY src/ /ng-app/src/
1010
RUN yarn install --update-checksums --no-progress --non-interactive --ignore-scripts
1111

12+
1213
# Build application
1314
RUN yarn --ignore-scripts build:prod
1415

Dockerfile-lint

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Dockerfile.test
2+
FROM node:22-alpine
3+
4+
WORKDIR /app
5+
6+
# Copy necessary files and install dependencies
7+
# COPY package.json yarn.lock eslint.config.js angular.json cypress.config.ts jest.config.ts tsconfig.app.json tsconfig.json tsconfig.spec.json ./src ./
8+
9+
COPY package.json yarn.lock ./
10+
11+
12+
RUN yarn install
13+
14+
# Copy the rest of the application files
15+
COPY . .
16+
17+
# Run the tests
18+
CMD ["yarn", "lint"]

Dockerfile-test

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Dockerfile.test
2+
FROM node:22-alpine
3+
4+
WORKDIR /app
5+
6+
# Copy necessary files and install dependencies
7+
# COPY package.json yarn.lock eslint.config.js angular.json cypress.config.ts jest.config.ts tsconfig.app.json tsconfig.json tsconfig.spec.json ./src ./
8+
9+
COPY package.json yarn.lock ./
10+
11+
12+
RUN yarn install
13+
14+
# Copy the rest of the application files
15+
COPY . .
16+
17+
# Run the tests
18+
CMD ["yarn", "test"]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ docker image build --progress=plain --tag das-ui:develop
107107
docker container run -d -p 4201:80 --rm das-ui:develop
108108
```
109109

110+
### Run test and lint with Docker cli
111+
```
112+
docker compose -f docker-compose.test.yml up test --build
113+
114+
docker compose -f docker-compose.test.yml up lint --build
115+
```
110116

111117
# GitLab CI/CD
112118
https://gitlab.com/j1032w/dashboard-starter/-/pipelines

docker-compose.test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: '3.8'
2+
3+
services:
4+
test:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile-test
8+
volumes:
9+
- .:/app
10+
environment:
11+
- NODE_ENV=test
12+
13+
lint:
14+
build:
15+
context: .
16+
dockerfile: Dockerfile-lint
17+
volumes:
18+
- .:/app
19+
environment:
20+
- NODE_ENV=test

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ services:
1616
ports:
1717
- "4201:80"
1818

19-
20-
2119
volumes:
2220
nginx_config:
2321
nginx_html:

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
"build:prod": "ng build --aot --configuration production",
1717
"build:analyze": "ng build --configuration production --stats-json && ng analyze",
1818
"analyze": "webpack-bundle-analyzer ./dist/analyze-result.json",
19-
"clean": "rimraf dist node_modules .angular/cache .sonar",
19+
"clean": "rimraf dist node_modules .angular/cache .sonar && yarn cache clean && jest --clearCache",
2020
"cypr": "cross-env CYPRESS_REMOTE_DEBUGGING_PORT=9299 cypress open",
21-
"lint": "ng lint"
21+
"lint": "ng lint",
22+
"docker:test": "docker compose -f docker-compose.test.yml up test --build",
23+
"docker:lint": "docker compose -f docker-compose.test.yml up lint --build"
24+
2225
},
2326
"dependencies": {
2427
"@angular/animations": "^18.2.0",

src/app/views/dashboard/housing-market-widget/housing-market-widget-pie/dv-housing-market-widget-pie.component.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
import { Component, ElementRef, Input, ViewChild } from '@angular/core';
2-
import { BubbleDataPoint, ChartConfiguration, ChartData, ChartType, Point } from 'chart.js';
1+
import {
2+
Component,
3+
ElementRef,
4+
Input,
5+
OnInit,
6+
ViewChild
7+
} from '@angular/core';
8+
import {
9+
BubbleDataPoint,
10+
Chart,
11+
ChartConfiguration,
12+
ChartData,
13+
ChartType,
14+
Point
15+
} from 'chart.js';
16+
import DataLabelsPlugin from 'chartjs-plugin-datalabels';
317
import {BaseChartDirective} from 'ng2-charts';
418

519
import { ElementSizeInterface } from '../../../../common/components/das-auto-size/das-auto-size.component';
@@ -11,7 +25,7 @@ import { DasWidgetContentBaseComponent } from '../../../../common/components/das
1125
templateUrl: './dv-housing-market-widget-pie.component.html',
1226
styleUrls: ['./dv-housing-market-widget-pie.component.scss']
1327
})
14-
export class DvHousingMarketWidgetPieComponent extends DasWidgetContentBaseComponent {
28+
export class DvHousingMarketWidgetPieComponent extends DasWidgetContentBaseComponent implements OnInit {
1529
@ViewChild('pieChart') pieChartComponent: BaseChartDirective | undefined;
1630

1731
@Input() pieChartData: ChartData<'pie', number[], string>;
@@ -65,6 +79,12 @@ export class DvHousingMarketWidgetPieComponent extends DasWidgetContentBaseCompo
6579
super(elementRef, dashboardCoreService);
6680
}
6781

82+
83+
override ngOnInit() {
84+
super.ngOnInit();
85+
Chart.register(DataLabelsPlugin);
86+
}
87+
6888
protected override readonly repaintComponent = () => {
6989
this.pieChartComponent?.render();
7090
};

0 commit comments

Comments
 (0)