|
4 | 4 | /* eslint-disable @typescript-eslint/no-unsafe-call */ |
5 | 5 | /* eslint-disable camelcase */ |
6 | 6 | import * as fs from 'fs'; |
| 7 | +import * as path from 'path'; |
7 | 8 | import { expect } from '@salesforce/command/lib/test'; |
8 | 9 | import { Connection, Messages, Org } from '@salesforce/core'; |
9 | 10 | import { UX } from '@salesforce/command'; |
@@ -124,6 +125,14 @@ describe('PostMigrate', () => { |
124 | 125 | getMessageStub |
125 | 126 | .withArgs('deploymentNonRetryableError') |
126 | 127 | .returns('Deployment failed with non-retryable error: %s. Please review and fix the issue manually.'); |
| 128 | + getMessageStub |
| 129 | + .withArgs('omniscriptPackageDeploymentFailedReturnedFalse') |
| 130 | + .returns( |
| 131 | + 'Omniscript package deployment failed - deployment returned false. This may be due to missing package, permissions, or deployment timeout.' |
| 132 | + ); |
| 133 | + getMessageStub |
| 134 | + .withArgs('omniscriptPackageDeploymentFailedWithMessage') |
| 135 | + .callsFake((key: string, args: string[]) => `Omniscript package deployment failed: ${args[0]}`); |
127 | 136 | // Other messages referenced by implementation |
128 | 137 | getMessageStub.withArgs('checkingStandardDesignerStatus', [testNamespace]).returns('Checking designer status'); |
129 | 138 | getMessageStub.withArgs('standardDesignerAlreadyEnabled', [testNamespace]).returns('Designer already enabled'); |
@@ -199,16 +208,31 @@ describe('PostMigrate', () => { |
199 | 208 | // Use existing stubs from beforeEach setup |
200 | 209 | const deployLogVerboseStub = Logger.logVerbose as sinon.SinonStub; |
201 | 210 | const actionItems: string[] = []; |
| 211 | + // Create a temporary package.xml file to ensure fs.existsSync returns true |
| 212 | + const tempPackageXml = path.join(process.cwd(), 'package.xml'); |
| 213 | + fs.writeFileSync(tempPackageXml, '<?xml version="1.0" encoding="UTF-8"?><Package></Package>'); |
| 214 | + |
| 215 | + // Clean up after test |
| 216 | + const cleanup = () => { |
| 217 | + if (fs.existsSync(tempPackageXml)) { |
| 218 | + fs.unlinkSync(tempPackageXml); |
| 219 | + } |
| 220 | + }; |
202 | 221 |
|
203 | 222 | // Act |
204 | 223 | await postMigrate.deploy(actionItems); |
205 | 224 |
|
206 | | - // Assert |
207 | | - expect(deployerStub.called).to.be.true; |
208 | | - expect(logErrorStub.called).to.be.true; |
209 | | - expect(deployLogVerboseStub.called).to.be.true; |
210 | | - expect(actionItems.length).to.be.greaterThan(0); |
211 | | - expect(actionItems[0]).to.include('Omniscript customization package deployment failed'); |
| 225 | + try { |
| 226 | + // Assert |
| 227 | + expect(deployerStub.called).to.be.true; |
| 228 | + expect(logErrorStub.called).to.be.true; |
| 229 | + expect(deployLogVerboseStub.called).to.be.true; |
| 230 | + expect(actionItems.length).to.be.greaterThan(0); |
| 231 | + expect(actionItems[0]).to.include('Omniscript customization package deployment failed'); |
| 232 | + } finally { |
| 233 | + // Always clean up the temporary file |
| 234 | + cleanup(); |
| 235 | + } |
212 | 236 | }); |
213 | 237 |
|
214 | 238 | it('should create Deployer with correct parameters', () => { |
|
0 commit comments