From 2fde8b6f2a84347df9e4241d59e0b6657851eb09 Mon Sep 17 00:00:00 2001 From: D048415 Date: Wed, 26 Nov 2025 17:43:07 +0100 Subject: [PATCH 1/5] remove hardcoded usage of webapp folder name --- packages/adp-tooling/src/base/change-utils.ts | 23 ++++--- .../changes/writers/annotations-writer.ts | 2 +- .../writers/component-usages-writer.ts | 4 +- .../changes/writers/data-source-writer.ts | 4 +- .../writer/changes/writers/inbound-writer.ts | 4 +- .../changes/writers/new-model-writer.ts | 2 +- .../test/unit/base/change-utils.test.ts | 64 +++++++++---------- .../unit/writer/changes/writers/index.test.ts | 4 +- 8 files changed, 55 insertions(+), 52 deletions(-) diff --git a/packages/adp-tooling/src/base/change-utils.ts b/packages/adp-tooling/src/base/change-utils.ts index cf153eb26fd..f22849c3cbf 100644 --- a/packages/adp-tooling/src/base/change-utils.ts +++ b/packages/adp-tooling/src/base/change-utils.ts @@ -3,7 +3,7 @@ import path from 'node:path'; import type { Editor } from 'mem-fs-editor'; import { existsSync, readFileSync, readdirSync } from 'node:fs'; -import { DirName } from '@sap-ux/project-access'; +import { DirName, getWebappPath } from '@sap-ux/project-access'; import { TemplateFileName, type AnnotationsData, @@ -32,18 +32,19 @@ interface InboundChange extends ManifestChangeProperties { * @param {ManifestChangeProperties} change - The annotation data change that will be written. * @param {Editor} fs - The `mem-fs-editor` instance used for file operations. * @param {string} templatesPath - The path to the templates used for generating changes. - * @returns {void} + * @returns {Promise} */ -export function writeAnnotationChange( +export async function writeAnnotationChange( projectPath: string, timestamp: number, annotation: AnnotationsData['annotation'], change: ManifestChangeProperties | undefined, fs: Editor, templatesPath?: string -): void { +): Promise { try { - const changesFolderPath = path.join(projectPath, DirName.Webapp, DirName.Changes); + const webappPath = await getWebappPath(projectPath, fs); + const changesFolderPath = path.join(webappPath, DirName.Changes); const annotationsFolderPath = path.join(changesFolderPath, DirName.Annotations); if (change) { @@ -83,11 +84,12 @@ export function writeAnnotationChange( * @param {ManifestChangeProperties} change - The change data to be written to the file. * @param {Editor} fs - The `mem-fs-editor` instance used for file operations. * @param {string} [dir] - An optional subdirectory within the 'changes' directory where the file will be written. - * @returns {void} + * @returns {Promise} */ -export function writeChangeToFolder(projectPath: string, change: ManifestChangeProperties, fs: Editor, dir = ''): void { +export async function writeChangeToFolder(projectPath: string, change: ManifestChangeProperties, fs: Editor, dir = ''): Promise { try { - let targetFolderPath = path.join(projectPath, DirName.Webapp, DirName.Changes); + const webappPath = await getWebappPath(projectPath, fs); + let targetFolderPath = path.join(webappPath, DirName.Changes); if (dir) { targetFolderPath = path.join(targetFolderPath, dir); @@ -210,11 +212,12 @@ export function getChangesByType( * @returns {InboundChangeData} An object containing the file path and the change object with the matching inbound ID. * @throws {Error} Throws an error if the change file cannot be read or if there's an issue accessing the directory. */ -export function findChangeWithInboundId(projectPath: string, inboundId: string): InboundChangeData { +export async function findChangeWithInboundId(projectPath: string, inboundId: string): Promise { let changeObj: InboundChange | undefined; let filePath = ''; - const pathToInboundChangeFiles = path.join(projectPath, DirName.Webapp, DirName.Changes); + const webappPath = await getWebappPath(projectPath); + const pathToInboundChangeFiles = path.join(webappPath, DirName.Changes); if (!existsSync(pathToInboundChangeFiles)) { return { diff --git a/packages/adp-tooling/src/writer/changes/writers/annotations-writer.ts b/packages/adp-tooling/src/writer/changes/writers/annotations-writer.ts index cd5436b526d..f02d6d12168 100644 --- a/packages/adp-tooling/src/writer/changes/writers/annotations-writer.ts +++ b/packages/adp-tooling/src/writer/changes/writers/annotations-writer.ts @@ -80,6 +80,6 @@ export class AnnotationsWriter implements IWriter { if (data.isCommand) { change = getChange(variant, timestamp, content, ChangeType.ADD_ANNOTATIONS_TO_ODATA); } - writeAnnotationChange(this.projectPath, timestamp, data.annotation, change, this.fs, this.templatesPath); + await writeAnnotationChange(this.projectPath, timestamp, data.annotation, change, this.fs, this.templatesPath); } } diff --git a/packages/adp-tooling/src/writer/changes/writers/component-usages-writer.ts b/packages/adp-tooling/src/writer/changes/writers/component-usages-writer.ts index 768c2cb6a34..aca98abcbfd 100644 --- a/packages/adp-tooling/src/writer/changes/writers/component-usages-writer.ts +++ b/packages/adp-tooling/src/writer/changes/writers/component-usages-writer.ts @@ -68,7 +68,7 @@ export class ComponentUsagesWriter implements IWriter { ChangeType.ADD_COMPONENT_USAGES ); - writeChangeToFolder(this.projectPath, compUsagesChange, this.fs); + await writeChangeToFolder(this.projectPath, compUsagesChange, this.fs); if (!('library' in data)) { return; @@ -78,6 +78,6 @@ export class ComponentUsagesWriter implements IWriter { const libTimestamp = timestamp + 1; const refLibChange = getChange(data.variant, libTimestamp, libRefContent, ChangeType.ADD_LIBRARY_REFERENCE); - writeChangeToFolder(this.projectPath, refLibChange, this.fs); + await writeChangeToFolder(this.projectPath, refLibChange, this.fs); } } diff --git a/packages/adp-tooling/src/writer/changes/writers/data-source-writer.ts b/packages/adp-tooling/src/writer/changes/writers/data-source-writer.ts index 7c206b8d4d5..b5d62593a22 100644 --- a/packages/adp-tooling/src/writer/changes/writers/data-source-writer.ts +++ b/packages/adp-tooling/src/writer/changes/writers/data-source-writer.ts @@ -63,14 +63,14 @@ export class DataSourceWriter implements IWriter { const content = this.constructContent(id, uri, maxAge); const change = getChange(variant, timestamp, content, ChangeType.CHANGE_DATA_SOURCE); - writeChangeToFolder(this.projectPath, change, this.fs); + await writeChangeToFolder(this.projectPath, change, this.fs); if (annotationId && annotationUri) { const annotationContent = this.constructContent(annotationId, annotationUri); const annotationTs = timestamp + 1; const annotationChange = getChange(variant, annotationTs, annotationContent, ChangeType.CHANGE_DATA_SOURCE); - writeChangeToFolder(this.projectPath, annotationChange, this.fs); + await writeChangeToFolder(this.projectPath, annotationChange, this.fs); } } } diff --git a/packages/adp-tooling/src/writer/changes/writers/inbound-writer.ts b/packages/adp-tooling/src/writer/changes/writers/inbound-writer.ts index 45d6ec4baac..696e08b16cc 100644 --- a/packages/adp-tooling/src/writer/changes/writers/inbound-writer.ts +++ b/packages/adp-tooling/src/writer/changes/writers/inbound-writer.ts @@ -77,14 +77,14 @@ export class InboundWriter implements IWriter { * @returns {Promise} A promise that resolves when the change writing process is completed. */ async write(data: InboundData): Promise { - const { changeWithInboundId, filePath } = findChangeWithInboundId(this.projectPath, data.inboundId); + const { changeWithInboundId, filePath } = await findChangeWithInboundId(this.projectPath, data.inboundId); const timestamp = Date.now(); if (!changeWithInboundId) { const content = this.constructContent(data); const change = getChange(data.variant, timestamp, content, ChangeType.CHANGE_INBOUND); - writeChangeToFolder(this.projectPath, change, this.fs); + await writeChangeToFolder(this.projectPath, change, this.fs); } else { if (changeWithInboundId.content) { this.getEnhancedContent(data, changeWithInboundId.content); diff --git a/packages/adp-tooling/src/writer/changes/writers/new-model-writer.ts b/packages/adp-tooling/src/writer/changes/writers/new-model-writer.ts index 8eef725afc0..ee5bf902204 100644 --- a/packages/adp-tooling/src/writer/changes/writers/new-model-writer.ts +++ b/packages/adp-tooling/src/writer/changes/writers/new-model-writer.ts @@ -82,6 +82,6 @@ export class NewModelWriter implements IWriter { const content = this.constructContent(data); const change = getChange(data.variant, timestamp, content, ChangeType.ADD_NEW_MODEL); - writeChangeToFolder(this.projectPath, change, this.fs); + await writeChangeToFolder(this.projectPath, change, this.fs); } } diff --git a/packages/adp-tooling/test/unit/base/change-utils.test.ts b/packages/adp-tooling/test/unit/base/change-utils.test.ts index 6e7a3034a30..2eaee6605a0 100644 --- a/packages/adp-tooling/test/unit/base/change-utils.test.ts +++ b/packages/adp-tooling/test/unit/base/change-utils.test.ts @@ -51,8 +51,8 @@ describe('Change Utils', () => { const writeJsonSpy = jest.fn(); const mockFs = { writeJSON: writeJsonSpy }; - it('should write change to the specified folder without subdirectory', () => { - writeChangeToFolder( + it('should write change to the specified folder without subdirectory', async () => { + await writeChangeToFolder( projectPath, change as unknown as ManifestChangeProperties, mockFs as unknown as Editor @@ -61,9 +61,9 @@ describe('Change Utils', () => { expect(writeJsonSpy).toHaveBeenCalledWith(expect.stringContaining(change.fileName), change); }); - it('should write change to the specified folder with subdirectory', () => { + it('should write change to the specified folder with subdirectory', async () => { const dir = 'subdir'; - writeChangeToFolder( + await writeChangeToFolder( projectPath, change as unknown as ManifestChangeProperties, mockFs as unknown as Editor, @@ -73,7 +73,7 @@ describe('Change Utils', () => { expect(writeJsonSpy).toHaveBeenCalledWith(expect.stringContaining(path.join(dir, change.fileName)), change); }); - it('should throw error when writing json fails', () => { + it('should throw error when writing json fails', async () => { const errMsg = 'Corrupted json.'; mockFs.writeJSON.mockImplementation(() => { throw new Error(errMsg); @@ -81,13 +81,13 @@ describe('Change Utils', () => { const expectedPath = path.join('project', 'webapp', 'changes', `${change.fileName}.change`); - expect(() => { + await expect(() => writeChangeToFolder( projectPath, change as unknown as ManifestChangeProperties, mockFs as unknown as Editor - ); - }).toThrow( + ) + ).rejects.toThrow( `Could not write change to folder. Reason: Could not write change to file: ${expectedPath}. Reason: Corrupted json.` ); }); @@ -274,24 +274,24 @@ describe('Change Utils', () => { const readdirSyncMock = readdirSync as jest.Mock; const readFileSyncMock = readFileSync as jest.Mock; - it('should return empty results if the directory does not exist', () => { + it('should return empty results if the directory does not exist', async () => { existsSyncMock.mockReturnValue(false); - const result = findChangeWithInboundId(mockProjectPath, mockInboundId); + const result = await findChangeWithInboundId(mockProjectPath, mockInboundId); expect(result).toEqual({ filePath: '', changeWithInboundId: undefined }); }); - it('should return empty results if no matching file is found', () => { + it('should return empty results if no matching file is found', async () => { existsSyncMock.mockReturnValue(true); readdirSyncMock.mockReturnValue([]); - const result = findChangeWithInboundId(mockProjectPath, mockInboundId); + const result = await findChangeWithInboundId(mockProjectPath, mockInboundId); expect(result).toEqual({ filePath: '', changeWithInboundId: undefined }); }); - it('should return the change object and file path if a matching file is found', () => { + it('should return the change object and file path if a matching file is found', async () => { existsSyncMock.mockReturnValue(true); readdirSyncMock.mockReturnValue([ { name: 'id_addAnnotationsToOData.change', isFile: () => true }, @@ -299,7 +299,7 @@ describe('Change Utils', () => { ]); readFileSyncMock.mockReturnValue(JSON.stringify({ content: { inboundId: mockInboundId } })); - const result = findChangeWithInboundId(mockProjectPath, mockInboundId); + const result = await findChangeWithInboundId(mockProjectPath, mockInboundId); expect(result).toEqual({ filePath: expect.stringContaining('id_changeInbound.change'), @@ -307,14 +307,14 @@ describe('Change Utils', () => { }); }); - it('should throw an error if reading the file fails', () => { + it('should throw an error if reading the file fails', async () => { existsSyncMock.mockReturnValue(true); readdirSyncMock.mockReturnValue([{ name: 'id_changeInbound.change', isFile: () => true }]); readFileSyncMock.mockImplementation(() => { throw new Error('Read file error'); }); - expect(() => findChangeWithInboundId(mockProjectPath, mockInboundId)).toThrow( + await expect(() => findChangeWithInboundId(mockProjectPath, mockInboundId)).rejects.toThrow( 'Could not find change with inbound id' ); }); @@ -349,11 +349,11 @@ describe('Change Utils', () => { writeJSON: writeJsonSpy }; - it('should write the change file and an annotation file from a template', () => { + it('should write the change file and an annotation file from a template', async () => { renderFileMock.mockImplementation((templatePath, data, options, callback) => { callback(undefined, 'test'); }); - writeAnnotationChange( + await writeAnnotationChange( mockProjectPath, 123456789, { @@ -394,11 +394,11 @@ describe('Change Utils', () => { expect(writeSpy).toHaveBeenCalledWith(expect.stringContaining('mockAnnotation.xml'), 'test'); }); - it('should write the change file and an annotation file from a template using the provided templates path', () => { + it('should write the change file and an annotation file from a template using the provided templates path', async () => { renderFileMock.mockImplementation((templatePath, data, options, callback) => { callback(undefined, 'test'); }); - writeAnnotationChange( + await writeAnnotationChange( mockProjectPath, 123456789, { @@ -440,10 +440,10 @@ describe('Change Utils', () => { expect(writeSpy).toHaveBeenCalledWith(expect.stringContaining('mockAnnotation.xml'), 'test'); }); - it('should copy the annotation file to the correct directory if not creating a new empty file', () => { + it('should copy the annotation file to the correct directory if not creating a new empty file', async () => { mockData.annotation.filePath = `mock/path/to/annotation/file.xml`; - writeAnnotationChange( + await writeAnnotationChange( mockProjectPath, 123456789, mockData.annotation as AnnotationsData['annotation'], @@ -457,7 +457,7 @@ describe('Change Utils', () => { ); }); - it('should not copy the annotation file if the selected directory is the same as the target', () => { + it('should not copy the annotation file if the selected directory is the same as the target', async () => { mockData.annotation.filePath = path.join( 'mock', 'project', @@ -468,7 +468,7 @@ describe('Change Utils', () => { 'mockAnnotation.xml' ); - writeAnnotationChange( + await writeAnnotationChange( mockProjectPath, 123456789, mockData.annotation as AnnotationsData['annotation'], @@ -479,22 +479,22 @@ describe('Change Utils', () => { expect(copySpy).not.toHaveBeenCalled(); }); - it('should throw error when write operation fails', () => { + it('should throw error when write operation fails', async () => { mockData.annotation.filePath = ''; mockFs.writeJSON.mockImplementationOnce(() => { throw new Error('Failed to write JSON'); }); - expect(() => { + await expect(() => writeAnnotationChange( mockProjectPath, 123456789, mockData.annotation as AnnotationsData['annotation'], mockChange as unknown as ManifestChangeProperties, mockFs as unknown as Editor - ); - }).toThrow( + ) + ).rejects.toThrow( `Could not write annotation changes. Reason: Could not write change to file: ${path.join( mockProjectPath, 'webapp', @@ -504,20 +504,20 @@ describe('Change Utils', () => { ); }); - it('should throw an error if rendering the annotation file fails', () => { + it('should throw an error if rendering the annotation file fails', async () => { renderFileMock.mockImplementation((templatePath, data, options, callback) => { callback(new Error('Failed to render annotation file'), ''); }); - expect(() => { + await expect(() => writeAnnotationChange( mockProjectPath, 123456789, mockData.annotation as AnnotationsData['annotation'], mockChange as unknown as ManifestChangeProperties, mockFs as unknown as Editor - ); - }).toThrow('Failed to render annotation file'); + ) + ).rejects.toThrow('Failed to render annotation file'); }); }); }); diff --git a/packages/adp-tooling/test/unit/writer/changes/writers/index.test.ts b/packages/adp-tooling/test/unit/writer/changes/writers/index.test.ts index a767a5f7ced..41563c22c12 100644 --- a/packages/adp-tooling/test/unit/writer/changes/writers/index.test.ts +++ b/packages/adp-tooling/test/unit/writer/changes/writers/index.test.ts @@ -369,7 +369,7 @@ describe('InboundWriter', () => { variant: {} as DescriptorVariant }; - findChangeWithInboundIdMock.mockReturnValue({ changeWithInboundId: null, filePath: '' }); + findChangeWithInboundIdMock.mockResolvedValue({ changeWithInboundId: null, filePath: '' }); await writer.write(mockData); @@ -389,7 +389,7 @@ describe('InboundWriter', () => { }; const existingChangeContent = { inboundId: 'testInboundId', entityPropertyChange: [] }; - findChangeWithInboundIdMock.mockReturnValue({ + findChangeWithInboundIdMock.mockResolvedValue({ changeWithInboundId: { content: existingChangeContent }, filePath: `${mockProjectPath}/webapp/changes/manifest/inboundChange.change` }); From 193d33bc31799e29b718508c2b37b0347b11c045 Mon Sep 17 00:00:00 2001 From: D048415 Date: Wed, 26 Nov 2025 17:43:53 +0100 Subject: [PATCH 2/5] add cset --- .changeset/easy-dots-happen.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/easy-dots-happen.md diff --git a/.changeset/easy-dots-happen.md b/.changeset/easy-dots-happen.md new file mode 100644 index 00000000000..d5a7ea69937 --- /dev/null +++ b/.changeset/easy-dots-happen.md @@ -0,0 +1,5 @@ +--- +'@sap-ux/adp-tooling': patch +--- + +fix: remove hard coded usage of webapp folder name From 94fb5d511301e0ce2ca2c4fbb2dc04b128eb76ee Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 26 Nov 2025 16:53:39 +0000 Subject: [PATCH 3/5] Linting auto fix commit --- packages/adp-tooling/src/base/change-utils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/adp-tooling/src/base/change-utils.ts b/packages/adp-tooling/src/base/change-utils.ts index f22849c3cbf..9a3ee2c8dd1 100644 --- a/packages/adp-tooling/src/base/change-utils.ts +++ b/packages/adp-tooling/src/base/change-utils.ts @@ -86,7 +86,12 @@ export async function writeAnnotationChange( * @param {string} [dir] - An optional subdirectory within the 'changes' directory where the file will be written. * @returns {Promise} */ -export async function writeChangeToFolder(projectPath: string, change: ManifestChangeProperties, fs: Editor, dir = ''): Promise { +export async function writeChangeToFolder( + projectPath: string, + change: ManifestChangeProperties, + fs: Editor, + dir = '' +): Promise { try { const webappPath = await getWebappPath(projectPath, fs); let targetFolderPath = path.join(webappPath, DirName.Changes); From c52cf5daa960cc46b5b675ce37809e3e3938451b Mon Sep 17 00:00:00 2001 From: D048415 Date: Thu, 27 Nov 2025 09:53:07 +0100 Subject: [PATCH 4/5] use existing memFS instance for findChangeWithInboundId --- packages/adp-tooling/src/base/change-utils.ts | 5 +++-- .../src/writer/changes/writers/inbound-writer.ts | 2 +- .../adp-tooling/test/unit/base/change-utils.test.ts | 12 +++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/adp-tooling/src/base/change-utils.ts b/packages/adp-tooling/src/base/change-utils.ts index 9a3ee2c8dd1..f0e2a029ba2 100644 --- a/packages/adp-tooling/src/base/change-utils.ts +++ b/packages/adp-tooling/src/base/change-utils.ts @@ -214,14 +214,15 @@ export function getChangesByType( * * @param {string} projectPath - The root path of the project. * @param {string} inboundId - The inbound ID to search for within change files. + * @param {Editor} fs - The `mem-fs-editor` instance used for file operations. * @returns {InboundChangeData} An object containing the file path and the change object with the matching inbound ID. * @throws {Error} Throws an error if the change file cannot be read or if there's an issue accessing the directory. */ -export async function findChangeWithInboundId(projectPath: string, inboundId: string): Promise { +export async function findChangeWithInboundId(projectPath: string, inboundId: string, fs: Editor): Promise { let changeObj: InboundChange | undefined; let filePath = ''; - const webappPath = await getWebappPath(projectPath); + const webappPath = await getWebappPath(projectPath, fs); const pathToInboundChangeFiles = path.join(webappPath, DirName.Changes); if (!existsSync(pathToInboundChangeFiles)) { diff --git a/packages/adp-tooling/src/writer/changes/writers/inbound-writer.ts b/packages/adp-tooling/src/writer/changes/writers/inbound-writer.ts index 696e08b16cc..307b15bba97 100644 --- a/packages/adp-tooling/src/writer/changes/writers/inbound-writer.ts +++ b/packages/adp-tooling/src/writer/changes/writers/inbound-writer.ts @@ -77,7 +77,7 @@ export class InboundWriter implements IWriter { * @returns {Promise} A promise that resolves when the change writing process is completed. */ async write(data: InboundData): Promise { - const { changeWithInboundId, filePath } = await findChangeWithInboundId(this.projectPath, data.inboundId); + const { changeWithInboundId, filePath } = await findChangeWithInboundId(this.projectPath, data.inboundId, this.fs); const timestamp = Date.now(); if (!changeWithInboundId) { diff --git a/packages/adp-tooling/test/unit/base/change-utils.test.ts b/packages/adp-tooling/test/unit/base/change-utils.test.ts index 2eaee6605a0..23aceb0826b 100644 --- a/packages/adp-tooling/test/unit/base/change-utils.test.ts +++ b/packages/adp-tooling/test/unit/base/change-utils.test.ts @@ -1,5 +1,5 @@ import path, { resolve } from 'node:path'; -import type { Editor } from 'mem-fs-editor'; +import { create, type Editor } from 'mem-fs-editor'; import type { UI5FlexLayer } from '@sap-ux/project-access'; import { readFileSync, existsSync, readdirSync } from 'node:fs'; import { renderFile } from 'ejs'; @@ -26,6 +26,7 @@ import { writeAnnotationChange, writeChangeToFolder } from '../../../src/base/change-utils'; +import {create as createStorage} from "mem-fs"; jest.mock('fs', () => ({ ...jest.requireActual('fs'), @@ -265,6 +266,7 @@ describe('Change Utils', () => { describe('findChangeWithInboundId', () => { const mockProjectPath = '/mock/project/path'; const mockInboundId = 'mockInboundId'; + const memFs = create(createStorage()); beforeEach(() => { jest.resetAllMocks(); @@ -277,7 +279,7 @@ describe('Change Utils', () => { it('should return empty results if the directory does not exist', async () => { existsSyncMock.mockReturnValue(false); - const result = await findChangeWithInboundId(mockProjectPath, mockInboundId); + const result = await findChangeWithInboundId(mockProjectPath, mockInboundId, memFs); expect(result).toEqual({ filePath: '', changeWithInboundId: undefined }); }); @@ -286,7 +288,7 @@ describe('Change Utils', () => { existsSyncMock.mockReturnValue(true); readdirSyncMock.mockReturnValue([]); - const result = await findChangeWithInboundId(mockProjectPath, mockInboundId); + const result = await findChangeWithInboundId(mockProjectPath, mockInboundId, memFs); expect(result).toEqual({ filePath: '', changeWithInboundId: undefined }); }); @@ -299,7 +301,7 @@ describe('Change Utils', () => { ]); readFileSyncMock.mockReturnValue(JSON.stringify({ content: { inboundId: mockInboundId } })); - const result = await findChangeWithInboundId(mockProjectPath, mockInboundId); + const result = await findChangeWithInboundId(mockProjectPath, mockInboundId, memFs); expect(result).toEqual({ filePath: expect.stringContaining('id_changeInbound.change'), @@ -314,7 +316,7 @@ describe('Change Utils', () => { throw new Error('Read file error'); }); - await expect(() => findChangeWithInboundId(mockProjectPath, mockInboundId)).rejects.toThrow( + await expect(() => findChangeWithInboundId(mockProjectPath, mockInboundId, memFs)).rejects.toThrow( 'Could not find change with inbound id' ); }); From 29e722e9ae88dacc4b3b581ccb0937346b496653 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 27 Nov 2025 09:02:40 +0000 Subject: [PATCH 5/5] Linting auto fix commit --- packages/adp-tooling/src/base/change-utils.ts | 6 +++++- .../src/writer/changes/writers/inbound-writer.ts | 6 +++++- packages/adp-tooling/test/unit/base/change-utils.test.ts | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/adp-tooling/src/base/change-utils.ts b/packages/adp-tooling/src/base/change-utils.ts index f0e2a029ba2..085dce3104d 100644 --- a/packages/adp-tooling/src/base/change-utils.ts +++ b/packages/adp-tooling/src/base/change-utils.ts @@ -218,7 +218,11 @@ export function getChangesByType( * @returns {InboundChangeData} An object containing the file path and the change object with the matching inbound ID. * @throws {Error} Throws an error if the change file cannot be read or if there's an issue accessing the directory. */ -export async function findChangeWithInboundId(projectPath: string, inboundId: string, fs: Editor): Promise { +export async function findChangeWithInboundId( + projectPath: string, + inboundId: string, + fs: Editor +): Promise { let changeObj: InboundChange | undefined; let filePath = ''; diff --git a/packages/adp-tooling/src/writer/changes/writers/inbound-writer.ts b/packages/adp-tooling/src/writer/changes/writers/inbound-writer.ts index 307b15bba97..e6e9da43334 100644 --- a/packages/adp-tooling/src/writer/changes/writers/inbound-writer.ts +++ b/packages/adp-tooling/src/writer/changes/writers/inbound-writer.ts @@ -77,7 +77,11 @@ export class InboundWriter implements IWriter { * @returns {Promise} A promise that resolves when the change writing process is completed. */ async write(data: InboundData): Promise { - const { changeWithInboundId, filePath } = await findChangeWithInboundId(this.projectPath, data.inboundId, this.fs); + const { changeWithInboundId, filePath } = await findChangeWithInboundId( + this.projectPath, + data.inboundId, + this.fs + ); const timestamp = Date.now(); if (!changeWithInboundId) { diff --git a/packages/adp-tooling/test/unit/base/change-utils.test.ts b/packages/adp-tooling/test/unit/base/change-utils.test.ts index 23aceb0826b..6eddca732fa 100644 --- a/packages/adp-tooling/test/unit/base/change-utils.test.ts +++ b/packages/adp-tooling/test/unit/base/change-utils.test.ts @@ -26,7 +26,7 @@ import { writeAnnotationChange, writeChangeToFolder } from '../../../src/base/change-utils'; -import {create as createStorage} from "mem-fs"; +import { create as createStorage } from 'mem-fs'; jest.mock('fs', () => ({ ...jest.requireActual('fs'),