Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# name: Unit Test
name: Unit Test

# on:
# pull_request:
# types: [assigned, opened, synchronize, reopened]
on:
pull_request:
types: [assigned, opened, synchronize, reopened]

# jobs:
# unit-test:
# permissions: write-all
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - name: Setup GitHub Action
# uses: actions/setup-node@v1
# with:
# node-version: 14.18
# - name: Install dependencies
# run: npm install
# - name: Test
# run: npm run unit_test:ci
# env:
# FYLE_CLIENT_ID: "lolo"
# CALLBACK_URI: "http://lolo.fyle.tech/callback"
# API_URL: "http://lolo.fyle.tech"
# FYLE_APP_URL: "http://lolo.fyle.tech"
# SI_API_URL: "http://lolo.fyle.tech"
# SAGE300_API_URL: "http://lolo.fyle.tech"
# - name: Unit Test Coverage
# uses: fylein/comment-test-coverage@master
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# path: coverage/coverage-summary.json
# title: Unit Test Coverage
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
jobs:
unit-test:
permissions: write-all
runs-on: ubuntu-latest
Comment on lines +7 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Yo, these permissions are too high, we gotta bring 'em down low!

Listen up, I'm spittin' truth, no lies,
'write-all' perms? That's askin' for surprise!
For unit tests, we don't need that much power,
Let's lock it down, make our security tower!

Here's the fix, so take note:

jobs:
  unit-test:
-   permissions: write-all
+   permissions: read-all
    runs-on: ubuntu-latest

We're keepin' it tight, no slack,
'Cause in this security game, there's no turnin' back!

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
jobs:
unit-test:
permissions: write-all
runs-on: ubuntu-latest
jobs:
unit-test:
permissions: read-all
runs-on: ubuntu-latest

steps:
Comment on lines +7 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Yo, these permissions are whack, let's dial 'em back!

Listen up, dawg, I'm spittin' facts,
"write-all" perms? That's too lax!
For unit tests, we don't need that stack,
Let's lock it down, keep our security intact!

Here's the fix, so take note:

jobs:
  unit-test:
-   permissions: write-all
+   permissions: read-all
    runs-on: ubuntu-latest

We're keepin' it tight, no slack,
'Cause in this game, there's no turnin' back!

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
jobs:
unit-test:
permissions: write-all
runs-on: ubuntu-latest
steps:
jobs:
unit-test:
permissions: read-all
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v1
- name: Setup GitHub Action
uses: actions/setup-node@v1
with:
node-version: 22.2.0
Comment on lines +12 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Yo, these actions are old school, we need a new rule!

Listen up, I'm about to school ya,
These action versions? They ain't foolin' ya!
We gotta upgrade, keep our flow smooth,
So peep this diff, it's our next move:

-    - uses: actions/checkout@v1
+    - uses: actions/checkout@v3
     - name: Setup GitHub Action
-      uses: actions/setup-node@v1
+      uses: actions/setup-node@v3
       with:
-        node-version: 22.2.0
+        node-version: 18

We're rollin' with LTS, that's how we flex,
Node 18's stable, it's what's next!
Update them actions, keep 'em fresh,
'Cause in this code game, we're the best!

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/checkout@v1
- name: Setup GitHub Action
uses: actions/setup-node@v1
with:
node-version: 22.2.0
- uses: actions/checkout@v3
- name: Setup GitHub Action
uses: actions/setup-node@v3
with:
node-version: 18
🧰 Tools
🪛 actionlint

14-14: the runner of "actions/setup-node@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

- name: Install dependencies
run: npm install
- name: Test
run: npm run unit_test:ci
env:
FYLE_CLIENT_ID: "lolo"
CALLBACK_URI: "http://lolo.fyle.tech/callback"
CLUSTER_DOMAIN_API_URL: "http://lolo.fyle.tech"
FYLE_APP_URL: "http://lolo.fyle.tech"
SI_API_URL: "http://lolo.fyle.tech"
SAGE300_API_URL: "http://lolo.fyle.tech"
- name: Unit Test Coverage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Yo, these env vars are whack, they need a new track!

Listen up, homies, I'm droppin' knowledge,
These env vars? They ain't from college!
"lolo" and "http://lolo.fyle.tech"? That's a joke,
In production, that setup would make us choke!

So here's the deal, let's make it clear,
Replace them placeholders, make 'em disappear!
Use real values, or better yet,
Pull from secrets, that's a safer bet!

Example:

env:
  FYLE_CLIENT_ID: ${{ secrets.FYLE_CLIENT_ID }}
  CALLBACK_URI: ${{ secrets.CALLBACK_URI }}
  # ... and so on for other variables

Keep it secure, that's how we roll,
'Cause in this game, security's the goal!

🧰 Tools
🪛 yamllint

[error] 22-22: trailing spaces

(trailing-spaces)

uses: fylein/comment-test-coverage@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: coverage/coverage-summary.json
title: Unit Test Coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "npm run setup:env && npm run setup:branding && ng build && npm run sentry:sourcemaps",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"unit_test:ci": "npm run setup:env && ng test --watch=false --browsers=ChromeHeadlessCustom",
"unit_test:ci": "npm run setup:env && npm run setup:branding && ng test --watch=false --browsers=ChromeHeadlessCustom",
"setup:env": "node scripts/setup_env.js",
"setup:branding": "node scripts/setup_branding_config.js",
"lint": "ng lint",
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/interceptor/jwt.interceptor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ xdescribe('JwtInterceptor', () => {
let interceptor: JwtInterceptor;
let authService: AuthService;
let jwtHelperService: JwtHelperService;
const API_BASE_URL = environment.api_url;
const API_BASE_URL = environment.cluster_domain_api_url;

beforeEach(() => {
const service1 = {
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/bamboo-hr/bamboo-hr.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ xdescribe('BambooHrService', () => {
let injector: TestBed;
let httpMock: HttpTestingController;
let orgService: OrgService;
const API_BASE_URL = environment.api_url;
const API_BASE_URL = environment.cluster_domain_api_url;
const service1 = {
getOrgId: () => 1
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/common/api.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ xdescribe('ApiService', () => {
statusText: 'Bad request'
};

const API_BASE_URL = environment.api_url;
const API_BASE_URL = environment.cluster_domain_api_url;

beforeEach(() => {
TestBed.configureTestingModule({
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/common/auth.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ xdescribe('AuthService', () => {
let injector: TestBed;
let httpMock: HttpTestingController;
let userService: UserService;
const API_BASE_URL = environment.api_url;
const API_BASE_URL = environment.cluster_domain_api_url;
const routerSpy = { navigate: jasmine.createSpy('navigate'), url: '/auth/login' };

const service1 = {
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/common/clone-setting.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ xdescribe('CloneSettingService', () => {
let service: CloneSettingService;
let injector: TestBed;
let httpMock: HttpTestingController;
const API_BASE_URL = environment.api_url;
const API_BASE_URL = environment.cluster_domain_api_url;
const workspace_id = 1;

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/org/org.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ xdescribe('OrgService', () => {
let injector: TestBed;
let httpMock: HttpTestingController;
let storageService: StorageService;
const API_BASE_URL = environment.api_url;
const API_BASE_URL = environment.cluster_domain_api_url;

const service1 = {
get: () => '1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ xdescribe('TravelperkService', () => {
let injector: TestBed;
let httpMock: HttpTestingController;
let orgService: OrgService;
const API_BASE_URL = environment.api_url;
const API_BASE_URL = environment.cluster_domain_api_url;
const service1 = {
getOrgId: () => 1
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,14 @@ describe('IntacctC1ImportSettingsComponent', () => {
expect((component.importSettingsForm.get('expenseFields') as FormArray).length).toBe(initialLength + 1);
});

it('closeModel should reset customFieldForm and close dialog', () => {
it('closeModel should close the dialog and reset the form and the source field', () => {
component.customFieldForm.patchValue({ attribute_type: 'TEST' });
component.customFieldControl = component['createFormGroup'](blankMapping);
component.showDialog = true;

component.closeModel();

expect(component.customFieldControl.get('source_field')?.value).toBeNull();
expect(component.customFieldForm.value).toEqual({ attribute_type: null, display_name: null, source_placeholder: null });
expect(component.showDialog).toBeFalse();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { TrackingService } from 'src/app/core/services/integration/tracking.serv
import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service';
import { StorageService } from 'src/app/core/services/common/storage.service';
import { SiWorkspaceService } from 'src/app/core/services/si/si-core/si-workspace.service';
import { configuration, costCodeFieldValue, costTypeFieldValue, customField, customFieldValue, fyleFields, groupedDestinationAttributes, importSettings, importSettingsWithProjectMapping, intacctImportCodeConfig, locationEntityMapping, sageIntacctFields, sageIntacctFieldsSortedByPriority, settingsWithDependentFields } from '../../intacct.fixture';
import { blankMapping, configuration, costCodeFieldValue, costTypeFieldValue, customField, customFieldValue, fyleFields, groupedDestinationAttributes, importSettings, importSettingsWithProjectMapping, intacctImportCodeConfig, locationEntityMapping, sageIntacctFields, sageIntacctFieldsSortedByPriority, settingsWithDependentFields } from '../../intacct.fixture';
import { IntacctCategoryDestination, IntacctOnboardingState, IntacctUpdateEvent, MappingSourceField, Page, ProgressPhase, SageIntacctField, ToastSeverity, TrackingApp } from 'src/app/core/models/enum/enum.model';
import { SharedModule } from 'src/app/shared/shared.module';
import { Org } from 'src/app/core/models/org/org.model';
Expand Down Expand Up @@ -485,14 +485,16 @@ describe('IntacctImportSettingsComponent', () => {
expect(component.expenseFieldsGetter.length).toBe(initialLength + 1);
});

it('closeModel should reset form and close dialog', () => {
it('closeModel should close the dialog and reset the form and the source field', () => {
component.customFieldForm = component['formBuilder'].group({
testField: ['value']
});
component.customFieldControl = component['createFormGroup'](blankMapping);
component.showDialog = true;

component.closeModel();

expect(component.customFieldControl.get('source_field')?.value).toBeNull();
expect(component.customFieldForm.get('testField')?.value).toBeNull();
expect(component.showDialog).toBeFalse();
});
Expand Down
Loading