From 3650a073c3a95d5066f1bf9765574329860ce80e Mon Sep 17 00:00:00 2001 From: Cristian Dominguez Date: Fri, 30 Aug 2024 17:32:47 -0300 Subject: [PATCH] test: fix UTs --- package.json | 2 +- src/shared/remoteSourceTrackingService.ts | 2 +- test/unit/remoteSourceTracking.test.ts | 7 ++-- tsconfig.json | 5 ++- yarn.lock | 42 ++++++++++++++--------- 5 files changed, 35 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index f441f971..de55f8c0 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ }, "dependencies": { "@oclif/core": "^4.0.18", - "@salesforce/core": "^8.4.0", + "@salesforce/core": "8.5.2-dev.0", "@salesforce/kit": "^3.2.1", "@salesforce/source-deploy-retrieve": "^12.6.0", "@salesforce/ts-types": "^2.0.12", diff --git a/src/shared/remoteSourceTrackingService.ts b/src/shared/remoteSourceTrackingService.ts index 438ee53a..ff9a8c4e 100644 --- a/src/shared/remoteSourceTrackingService.ts +++ b/src/shared/remoteSourceTrackingService.ts @@ -572,7 +572,7 @@ const readFileContents = async (filePath: string): Promise (memberCount: number): Duration => { - const overriddenTimeout = envVars.getNumber('SF_SOURCE_MEMBER_POLLING_TIMEOUT', 0); + const overriddenTimeout = envVars.getNumber('SFDX_SOURCE_MEMBER_POLLING_TIMEOUT', 0); if (overriddenTimeout > 0) { logger.debug(`Overriding SourceMember polling timeout to ${overriddenTimeout}`); return Duration.seconds(overriddenTimeout); diff --git a/test/unit/remoteSourceTracking.test.ts b/test/unit/remoteSourceTracking.test.ts index 05b08256..1e1f2529 100644 --- a/test/unit/remoteSourceTracking.test.ts +++ b/test/unit/remoteSourceTracking.test.ts @@ -11,9 +11,8 @@ import { writeFile, mkdir, readFile } from 'node:fs/promises'; import { existsSync } from 'node:fs'; import { sep, dirname } from 'node:path'; import { MockTestOrgData, instantiateContext, stubContext, restoreContext } from '@salesforce/core/testSetup'; -import { Logger, Messages, Org } from '@salesforce/core'; +import { envVars, Logger, Messages, Org } from '@salesforce/core'; // eslint-disable-next-line no-restricted-imports -import * as kit from '@salesforce/kit'; import { expect } from 'chai'; import { ComponentStatus } from '@salesforce/source-deploy-retrieve'; import { RemoteSourceTrackingService, calculateTimeout, Contents } from '../../src/shared/remoteSourceTrackingService'; @@ -469,7 +468,7 @@ describe('remoteSourceTrackingService', () => { }); }); it('should not poll when SFDX_DISABLE_SOURCE_MEMBER_POLLING=true', async () => { - const getBooleanStub = $$.SANDBOX.stub(kit.env, 'getBoolean').callsFake(() => true); + const getBooleanStub = $$.SANDBOX.stub(envVars, 'getBoolean').callsFake(() => true); // @ts-ignore const trackSpy = $$.SANDBOX.stub(remoteSourceTrackingService, 'trackSourceMembers'); @@ -512,7 +511,7 @@ describe('remoteSourceTrackingService', () => { it('should stop if SFDX_SOURCE_MEMBER_POLLING_TIMEOUT is exceeded', async () => { // @ts-ignore - $$.SANDBOX.stub(kit.env, 'getString').callsFake(() => '3'); + $$.SANDBOX.stub(envVars, 'getString').callsFake(() => '3'); // @ts-ignore const queryStub = $$.SANDBOX.stub(remoteSourceTrackingService, 'querySourceMembersFrom').resolves([]); diff --git a/tsconfig.json b/tsconfig.json index 4c872ef4..0f181876 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,10 @@ "skipLibCheck": true, "plugins": [{ "transform": "@salesforce/core/messageTransformer", "import": "messageTransformer" }], "moduleResolution": "Node16", - "module": "Node16" + "module": "Node16", + "paths": { + "@salesforce/core": ["./node_modules/@salesforce/core"] + } }, "include": ["src/**/*.ts"] } diff --git a/yarn.lock b/yarn.lock index b29fefda..861ac82f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -546,6 +546,30 @@ strip-ansi "6.0.1" ts-retry-promise "^0.8.1" +"@salesforce/core@8.5.2-dev.0": + version "8.5.2-dev.0" + resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-8.5.2-dev.0.tgz#052869d7cac7e7aed655371b35f8da4893af36d8" + integrity sha512-XOYDx5DvXGhCRMhKBNzpZdpLta993tru1t+Lps/ipc4YMeYvjpXuFUdDU22sYCsMOyHgGgB8WkBYkr6SxU71dA== + dependencies: + "@jsforce/jsforce-node" "^3.4.0" + "@salesforce/kit" "^3.1.6" + "@salesforce/schemas" "^1.9.0" + "@salesforce/ts-types" "^2.0.10" + ajv "^8.17.1" + change-case "^4.1.2" + fast-levenshtein "^3.0.0" + faye "^1.4.0" + form-data "^4.0.0" + js2xmlparser "^4.0.1" + jsonwebtoken "9.0.2" + jszip "3.10.1" + pino "^9.3.2" + pino-abstract-transport "^1.2.0" + pino-pretty "^11.2.2" + proper-lockfile "^4.1.2" + semver "^7.6.3" + ts-retry-promise "^0.8.1" + "@salesforce/core@^8.3.0", "@salesforce/core@^8.4.0": version "8.4.0" resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-8.4.0.tgz#d2ddfe07994c42b1e917e581e9cf47ad27b97a93" @@ -1340,20 +1364,13 @@ brace-expansion@^4.0.0: dependencies: balanced-match "^3.0.0" -braces@^3.0.3: +braces@^3.0.3, braces@~3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== dependencies: fill-range "^7.1.1" -braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - browser-stdout@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" @@ -2500,14 +2517,7 @@ filelist@^1.0.4: dependencies: minimatch "^5.0.1" -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -fill-range@^7.1.1: +fill-range@^7.0.1, fill-range@^7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==