-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: warn when a flow is deleted (#894)
Co-authored-by: Matthias Rolke <[email protected]>
- Loading branch information
Showing
9 changed files
with
484 additions
and
455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict' | ||
import { expect, jest, describe, it } from '@jest/globals' | ||
|
||
import { DELETION } from '../../../../src/constant/gitConstants' | ||
import { MetadataRepository } from '../../../../src/metadata/MetadataRepository' | ||
import FlowHandler from '../../../../src/service/flowHandler' | ||
import type { Work } from '../../../../src/types/work' | ||
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper' | ||
|
||
jest.mock('../../../../src/utils/fsHelper') | ||
|
||
const objectType = { | ||
directoryName: 'flows', | ||
inFolder: false, | ||
metaFile: false, | ||
suffix: 'flow', | ||
xmlName: 'Flow', | ||
} | ||
const basePath = `force-app/main/default/${objectType.directoryName}` | ||
let work: Work | ||
beforeEach(() => { | ||
jest.clearAllMocks() | ||
work = getWork() | ||
}) | ||
|
||
describe('flowHandler', () => { | ||
let globalMetadata: MetadataRepository | ||
beforeAll(async () => { | ||
globalMetadata = await getGlobalMetadata() | ||
}) | ||
describe('when a flow is deleted', () => { | ||
it('warns the user not to', async () => { | ||
// Arrange | ||
const sut = new FlowHandler( | ||
`${DELETION} ${basePath}/MyFlow.${objectType.suffix}-meta.xml`, | ||
objectType, | ||
work, | ||
globalMetadata | ||
) | ||
expect(work.warnings.length).toBe(0) | ||
|
||
// Act | ||
await sut.handle() | ||
|
||
// Assert | ||
expect(work.warnings.length).toBe(1) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,12 +26,12 @@ | |
"author": "Sebastien Colladon <[email protected]>", | ||
"dependencies": { | ||
"@salesforce/command": "^5.3.9", | ||
"@salesforce/core": "^8.1.1", | ||
"@salesforce/core": "^8.2.6", | ||
"async": "^3.2.5", | ||
"fast-xml-parser": "^4.4.0", | ||
"fast-xml-parser": "^4.4.1", | ||
"fs-extra": "^11.2.0", | ||
"ignore": "^5.3.1", | ||
"isomorphic-git": "^1.27.0", | ||
"isomorphic-git": "^1.27.1", | ||
"lodash": "^4.17.21", | ||
"simple-git": "^3.25.0", | ||
"xmlbuilder2": "^3.1.1" | ||
|
@@ -224,38 +224,38 @@ | |
"@jest/globals": "^29.7.0", | ||
"@ls-lint/ls-lint": "^2.2.3", | ||
"@oclif/dev-cli": "^1.26.10", | ||
"@salesforce/cli-plugins-testkit": "^5.3.18", | ||
"@salesforce/cli-plugins-testkit": "^5.3.20", | ||
"@salesforce/dev-config": "^4.1.0", | ||
"@salesforce/ts-sinon": "^1.4.22", | ||
"@salesforce/ts-sinon": "^1.4.23", | ||
"@stryker-mutator/core": "^8.2.6", | ||
"@stryker-mutator/jest-runner": "^8.2.6", | ||
"@swc/core": "^1.6.13", | ||
"@swc/core": "^1.7.3", | ||
"@types/async": "^3.2.24", | ||
"@types/jest": "^29.5.12", | ||
"@types/mocha": "^10.0.7", | ||
"@types/node": "^20.14.10", | ||
"@typescript-eslint/eslint-plugin": "^7.15.0", | ||
"@typescript-eslint/parser": "^7.15.0", | ||
"@types/node": "^22.0.0", | ||
"@typescript-eslint/eslint-plugin": "^7.17.0", | ||
"@typescript-eslint/parser": "^7.17.0", | ||
"benchmark": "^2.1.4", | ||
"chai": "^4.3.10", | ||
"eslint": "^8.57.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"husky": "^9.0.11", | ||
"eslint-plugin-prettier": "^5.2.1", | ||
"husky": "^9.1.4", | ||
"jest": "^29.7.0", | ||
"knip": "^5.24.1", | ||
"knip": "^5.27.0", | ||
"lint-staged": "^15.2.7", | ||
"mocha": "^10.6.0", | ||
"mocha": "^10.7.0", | ||
"nyc": "^17.0.0", | ||
"prettier": "^3.3.2", | ||
"prettier": "^3.3.3", | ||
"shx": "^0.3.4", | ||
"sinon": "^18.0.0", | ||
"ts-jest": "^29.1.5", | ||
"ts-jest": "^29.2.3", | ||
"ts-node": "^10.9.2", | ||
"tslib": "^2.6.3", | ||
"typescript": "^5.5.3", | ||
"wireit": "^0.14.4", | ||
"typescript": "^5.5.4", | ||
"wireit": "^0.14.5", | ||
"yarn-audit-fix": "^10.0.7", | ||
"yarn-upgrade-all": "^0.7.2" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict' | ||
import { format } from 'util' | ||
|
||
import messages from '../locales/en' | ||
|
||
import StandardHandler from './standardHandler' | ||
|
||
export default class FlowHandler extends StandardHandler { | ||
public override async handleDeletion() { | ||
await super.handleDeletion() | ||
this.warnFlowDeleted() | ||
} | ||
|
||
private warnFlowDeleted() { | ||
this.work.warnings.push( | ||
new Error(format(messages.warningFlowDeleted, this._getElementName())) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.