From 1a6875274b8dc2dd9deb1eb08b96fd377bb97d6c Mon Sep 17 00:00:00 2001 From: Matt Benson Date: Mon, 23 Oct 2023 17:47:44 -0500 Subject: [PATCH] add failing test for single template expression input values in each-iterated actions Signed-off-by: Matt Benson --- .../tasks/NunjucksWorkflowRunner.test.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.test.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.test.ts index 6907f8cc2c..30856482a1 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.test.ts @@ -645,6 +645,35 @@ describe('DefaultWorkflowRunner', () => { }), ); }); + + it('should run a step repeatedly with validation of single-expression value', async () => { + const numbers = [5, 7, 9]; + const task = createMockTaskWithSpec({ + apiVersion: 'scaffolder.backstage.io/v1beta3', + steps: [ + { + id: 'test', + name: 'name', + each: '${{parameters.numbers}}', + action: 'jest-validated-action', + input: { foo: '${{each.value}}' }, + }, + ], + output: {}, + parameters: { + numbers, + }, + }); + await runner.execute(task); + + for (const foo of numbers) { + expect(fakeActionHandler).toHaveBeenCalledWith( + expect.objectContaining({ + input: { foo }, + }), + ); + } + }); }); describe('secrets', () => {