Skip to content

Commit

Permalink
fix: processing and assigning an action's annotations when there are …
Browse files Browse the repository at this point in the history
…none (#198)
  • Loading branch information
shazron authored Dec 17, 2024
1 parent 827baba commit ea597e5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,9 @@ function rewriteActionsWithAdobeAuthAnnotation (packages, deploymentPackages) {
if (newPackages[key].actions) {
Object.keys(newPackages[key].actions).forEach((actionName) => {
const thisAction = newPackages[key].actions[actionName]
Object.assign(thisAction.annotations, processAnnotationsForWebAction(thisAction))
if (thisAction.annotations) {
Object.assign(thisAction.annotations, processAnnotationsForWebAction(thisAction))
}
const isWeb = thisAction.annotations?.[ANNOTATION_WEB_EXPORT]
const isRaw = thisAction.annotations?.[ANNOTATION_RAW_HTTP]

Expand Down
30 changes: 30 additions & 0 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,36 @@ describe('processPackage', () => {
spy.mockRestore()
})

test('1 action with no annotations', () => {
const spy = jest.spyOn(fs, 'readFileSync')
const fakeCode = 'fake action code'
spy.mockImplementation(() => fakeCode)
const deploymentPackages = { pkg1: { actions: { theaction: { inputs: { a: 34 } } } } }

const basicPackageNoAnnotations = structuredClone(basicPackage)
delete basicPackageNoAnnotations.pkg1.actions.theaction.annotations

const res = utils.processPackage(basicPackageNoAnnotations, deploymentPackages, {}, {}, false, { apihost: 'https://adobeioruntime.net' })
expect(res).toEqual({
actions: [
{
name: 'pkg1/theaction',
action: fakeCode,
params: { a: 34 },
annotations: {
'web-export': true,
'raw-http': false
}
}
],
apis: [],
pkgAndDeps: [{ name: 'pkg1' }],
rules: [],
triggers: []
})
spy.mockRestore()
})

test('action using the annotation + rewrite deployment package => action has empty imputs', () => {
const spy = jest.spyOn(fs, 'readFileSync')
const fakeCode = 'fake action code'
Expand Down

0 comments on commit ea597e5

Please sign in to comment.