Skip to content

Commit c7bc14b

Browse files
test: fix tests for github action (#1037)
* test: update tests for custom field dialog changes * build: run unit tests on new PR * build: bump node version in unit test workflow * build: run branding setup before testing * test: replace outdated references to the `API_URL` environment variable * build: remove minimum required coverage * build: add missing branding environment variables * refactor: remove test loggers * test: add missing import to QbdMappingTableComponent spec
1 parent c7ee43e commit c7bc14b

File tree

14 files changed

+77
-55
lines changed

14 files changed

+77
-55
lines changed

.github/workflows/unit-test.yml

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,42 @@
1-
# name: Unit Test
1+
name: Unit Test
22

3-
# on:
4-
# pull_request:
5-
# types: [assigned, opened, synchronize, reopened]
3+
on:
4+
pull_request:
5+
types: [assigned, opened, synchronize, reopened]
66

7-
# jobs:
8-
# unit-test:
9-
# permissions: write-all
10-
# runs-on: ubuntu-latest
11-
# steps:
12-
# - uses: actions/checkout@v1
13-
# - name: Setup GitHub Action
14-
# uses: actions/setup-node@v1
15-
# with:
16-
# node-version: 14.18
17-
# - name: Install dependencies
18-
# run: npm install
19-
# - name: Test
20-
# run: npm run unit_test:ci
21-
# env:
22-
# FYLE_CLIENT_ID: "lolo"
23-
# CALLBACK_URI: "http://lolo.fyle.tech/callback"
24-
# API_URL: "http://lolo.fyle.tech"
25-
# FYLE_APP_URL: "http://lolo.fyle.tech"
26-
# SI_API_URL: "http://lolo.fyle.tech"
27-
# SAGE300_API_URL: "http://lolo.fyle.tech"
28-
# - name: Unit Test Coverage
29-
# uses: fylein/comment-test-coverage@master
30-
# with:
31-
# token: ${{ secrets.GITHUB_TOKEN }}
32-
# path: coverage/coverage-summary.json
33-
# title: Unit Test Coverage
34-
# - name: Upload coverage to Codecov
35-
# uses: codecov/codecov-action@v3
7+
jobs:
8+
unit-test:
9+
permissions: write-all
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v1
13+
- name: Setup GitHub Action
14+
uses: actions/setup-node@v1
15+
with:
16+
node-version: 22.2.0
17+
- name: Install dependencies
18+
run: npm install
19+
- name: Test
20+
run: npm run unit_test:ci
21+
env:
22+
GH_UNIT_TEST_ENV: true
23+
BRAND_NAME: "Fyle"
24+
WEBPAGE_TITLE: "Fyle Integrations Settings"
25+
BRAND_ID: "fyle"
26+
SUPPORT_EMAIL: "staging-1-in"
27+
HELP_ARTICLE_DOMAIN: "[email protected]"
28+
ENV_ID: "https://help.manageexpenses.capitalone-fylehq.com"
29+
FYLE_CLIENT_ID: "lolo"
30+
CALLBACK_URI: "http://lolo.fyle.tech/callback"
31+
CLUSTER_DOMAIN_API_URL: "http://lolo.fyle.tech"
32+
FYLE_APP_URL: "http://lolo.fyle.tech"
33+
SI_API_URL: "http://lolo.fyle.tech"
34+
SAGE300_API_URL: "http://lolo.fyle.tech"
35+
- name: Unit Test Coverage
36+
uses: fylein/comment-test-coverage@master
37+
with:
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
path: coverage/coverage-summary.json
40+
title: Unit Test Coverage
41+
- name: Upload coverage to Codecov
42+
uses: codecov/codecov-action@v3

karma.conf.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,7 @@ module.exports = function (config) {
3232
{ type: 'text-summary' },
3333
{ type: 'lcovonly'},
3434
{ type: 'json-summary' }
35-
],
36-
check: {
37-
global: {
38-
statements: 50,
39-
branches: 50,
40-
functions: 50,
41-
lines: 50
42-
}
43-
}
35+
]
4436
},
4537
reporters: ['progress', 'kjhtml'],
4638
port: 9876,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": "npm run setup:env && npm run setup:branding && ng build && npm run sentry:sourcemaps",
88
"watch": "ng build --watch --configuration development",
99
"test": "ng test",
10-
"unit_test:ci": "npm run setup:env && ng test --watch=false --browsers=ChromeHeadlessCustom",
10+
"unit_test:ci": "npm run setup:env && npm run setup:branding && ng test --watch=false --browsers=ChromeHeadlessCustom",
1111
"setup:env": "node scripts/setup_env.js",
1212
"setup:branding": "node scripts/setup_branding_config.js",
1313
"lint": "ng lint",

scripts/setup_branding_config.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
const fs = require('fs');
22

3-
const config = fs.readFileSync(`./src/app/branding/config-template.json`, 'utf8');
4-
3+
let config;
54
const targetPath = './src/app/branding/config.json';
5+
6+
if (process.env.GH_UNIT_TEST_ENV) {
7+
const configObject = {
8+
brandName: process.env.BRAND_NAME ? process.env.BRAND_NAME : '{{BRAND_NAME}}',
9+
webpageTitle: process.env.WEBPAGE_TITLE ? process.env.WEBPAGE_TITLE : '{{WEBPAGE_TITLE}}',
10+
brandId: process.env.BRAND_ID ? process.env.BRAND_ID : '{{BRAND_ID}}',
11+
supportEmail: process.env.SUPPORT_EMAIL ? process.env.SUPPORT_EMAIL : '{{SUPPORT_EMAIL}}',
12+
helpArticleDomain: process.env.HELP_ARTICLE_DOMAIN ? process.env.HELP_ARTICLE_DOMAIN : '{{HELP_ARTICLE_DOMAIN}}',
13+
envId: process.env.ENV_ID ? process.env.ENV_ID : '{{ENV_ID}}',
14+
};
15+
16+
config = JSON.stringify(configObject);
17+
} else {
18+
config = fs.readFileSync(`./src/app/branding/config-template.json`, 'utf8');
19+
}
20+
621
fs.writeFile(targetPath, config, 'utf8', (err) => {
722
if (err) {
823
return console.error(err);

src/app/core/interceptor/jwt.interceptor.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ xdescribe('JwtInterceptor', () => {
1717
let interceptor: JwtInterceptor;
1818
let authService: AuthService;
1919
let jwtHelperService: JwtHelperService;
20-
const API_BASE_URL = environment.api_url;
20+
const API_BASE_URL = environment.cluster_domain_api_url;
2121

2222
beforeEach(() => {
2323
const service1 = {

src/app/core/services/bamboo-hr/bamboo-hr.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ xdescribe('BambooHrService', () => {
1111
let injector: TestBed;
1212
let httpMock: HttpTestingController;
1313
let orgService: OrgService;
14-
const API_BASE_URL = environment.api_url;
14+
const API_BASE_URL = environment.cluster_domain_api_url;
1515
const service1 = {
1616
getOrgId: () => 1
1717
};

src/app/core/services/common/api.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ xdescribe('ApiService', () => {
1515
statusText: 'Bad request'
1616
};
1717

18-
const API_BASE_URL = environment.api_url;
18+
const API_BASE_URL = environment.cluster_domain_api_url;
1919

2020
beforeEach(() => {
2121
TestBed.configureTestingModule({

src/app/core/services/common/auth.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ xdescribe('AuthService', () => {
1111
let injector: TestBed;
1212
let httpMock: HttpTestingController;
1313
let userService: UserService;
14-
const API_BASE_URL = environment.api_url;
14+
const API_BASE_URL = environment.cluster_domain_api_url;
1515
const routerSpy = { navigate: jasmine.createSpy('navigate'), url: '/auth/login' };
1616

1717
const service1 = {

src/app/core/services/common/clone-setting.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ xdescribe('CloneSettingService', () => {
88
let service: CloneSettingService;
99
let injector: TestBed;
1010
let httpMock: HttpTestingController;
11-
const API_BASE_URL = environment.api_url;
11+
const API_BASE_URL = environment.cluster_domain_api_url;
1212
const workspace_id = 1;
1313

1414
beforeEach(() => {

src/app/core/services/org/org.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ xdescribe('OrgService', () => {
1313
let injector: TestBed;
1414
let httpMock: HttpTestingController;
1515
let storageService: StorageService;
16-
const API_BASE_URL = environment.api_url;
16+
const API_BASE_URL = environment.cluster_domain_api_url;
1717

1818
const service1 = {
1919
get: () => '1'

0 commit comments

Comments
 (0)