From 73fc8252fd5b1fe99ba8dbb01962c2193b974f0b Mon Sep 17 00:00:00 2001 From: Nikhil Mittal Date: Fri, 10 Jul 2026 14:51:50 +0530 Subject: [PATCH] bug fix on org and alias --- src/lib/actions/RunAction.ts | 4 ++-- test/lib/actions/RunAction.test.ts | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lib/actions/RunAction.ts b/src/lib/actions/RunAction.ts index ccb27e48f..f36013405 100644 --- a/src/lib/actions/RunAction.ts +++ b/src/lib/actions/RunAction.ts @@ -1,4 +1,4 @@ -import {AuthInfo, SfError} from '@salesforce/core'; +import {Org, SfError} from '@salesforce/core'; import { CodeAnalyzer, CodeAnalyzerConfig, @@ -120,7 +120,7 @@ export class RunAction { private async validateTargetOrg(orgNameOrAlias: string): Promise { try { - await AuthInfo.create({ username: orgNameOrAlias }); + await Org.create({ aliasOrUsername: orgNameOrAlias }); } catch (error) { if (error instanceof Error) { const errorMessage = [ diff --git a/test/lib/actions/RunAction.test.ts b/test/lib/actions/RunAction.test.ts index ab23db271..ac6744866 100644 --- a/test/lib/actions/RunAction.test.ts +++ b/test/lib/actions/RunAction.test.ts @@ -1,7 +1,7 @@ import * as path from 'node:path'; import * as fs from 'node:fs'; import ansis from 'ansis'; -import {AuthInfo, SfError} from '@salesforce/core'; +import {Org, SfError} from '@salesforce/core'; import {SeverityLevel} from '@salesforce/code-analyzer-core'; import {SpyResultsViewer} from '../../stubs/SpyResultsViewer.js'; import {SpyResultsWriter} from '../../stubs/SpyResultsWriter.js'; @@ -482,8 +482,8 @@ describe('RunAction tests', () => { describe('target-org', () => { it('RunInput accepts target-org field', async () => { - // Mock AuthInfo.create to succeed - vi.spyOn(AuthInfo, 'create').mockResolvedValue({} as AuthInfo); + // Mock Org.create to succeed + vi.spyOn(Org, 'create').mockResolvedValue({} as Org); const input: RunInput = { 'rule-selector': ['all'], @@ -499,8 +499,8 @@ describe('RunAction tests', () => { }); it('target-org is passed through to engine config', async () => { - // Mock AuthInfo.create to succeed - vi.spyOn(AuthInfo, 'create').mockResolvedValue({} as AuthInfo); + // Mock Org.create to succeed + vi.spyOn(Org, 'create').mockResolvedValue({} as Org); const targetOrg = 'my-test-org'; const configFactorySpy = vi.spyOn(dependencies.configFactory, 'create'); @@ -525,7 +525,7 @@ describe('RunAction tests', () => { it('validates org authentication before config creation', async () => { const targetOrg = 'test-org'; - const authInfoSpy = vi.spyOn(AuthInfo, 'create').mockResolvedValue({} as AuthInfo); + const orgSpy = vi.spyOn(Org, 'create').mockResolvedValue({} as Org); const input: RunInput = { 'rule-selector': ['all'], @@ -536,14 +536,14 @@ describe('RunAction tests', () => { await action.execute(input); - // Verify AuthInfo.create was called with the org name - expect(authInfoSpy).toHaveBeenCalledWith({ username: targetOrg }); + // Verify Org.create was called with the org alias/username + expect(orgSpy).toHaveBeenCalledWith({ aliasOrUsername: targetOrg }); }); it('throws clear error when org is not authenticated', async () => { const targetOrg = 'unauthenticated-org'; - // Mock AuthInfo.create to throw an error (org not found/authenticated) - vi.spyOn(AuthInfo, 'create').mockRejectedValue(new Error('No authorization information found')); + // Mock Org.create to throw an error (org not found/authenticated) + vi.spyOn(Org, 'create').mockRejectedValue(new Error('No authorization information found')); const input: RunInput = { 'rule-selector': ['all'], @@ -569,7 +569,7 @@ describe('RunAction tests', () => { }); it('does not validate org when target-org is not provided', async () => { - const authInfoSpy = vi.spyOn(AuthInfo, 'create'); + const orgSpy = vi.spyOn(Org, 'create'); const input: RunInput = { 'rule-selector': ['all'], @@ -580,8 +580,8 @@ describe('RunAction tests', () => { await action.execute(input); - // Verify AuthInfo.create was NOT called - expect(authInfoSpy).not.toHaveBeenCalled(); + // Verify Org.create was NOT called + expect(orgSpy).not.toHaveBeenCalled(); }); }); });