From e8c395a4bbb5a64117375b9c00122cf521bb9d5f Mon Sep 17 00:00:00 2001 From: Kevin Marete <49183352+kevinmarete@users.noreply.github.com> Date: Wed, 19 Feb 2025 14:37:07 -0500 Subject: [PATCH] [CORE-323] Fix cost cap message in submission modal (#5255) --- .../workspace/workflows/WorkflowView.js | 2 +- .../workspace/workflows/WorkflowView.test.js | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/pages/workspaces/workspace/workflows/WorkflowView.js b/src/pages/workspaces/workspace/workflows/WorkflowView.js index 12ed6e63d6..994ca56aed 100644 --- a/src/pages/workspaces/workspace/workflows/WorkflowView.js +++ b/src/pages/workspaces/workspace/workflows/WorkflowView.js @@ -1146,7 +1146,7 @@ export const WorkflowView = _.flow( min: 0.01, max: 9999999999.99, placeholder: 'Example: 1.00', - onChange: (v) => this.setState({ perWorkflowCostCap: v ? v.toFixed(2) : undefined }), + onChange: (v) => this.setState({ perWorkflowCostCap: v ? v.toFixed(2) : '' }), style: { fontSize: 12, marginTop: '0.5rem', width: '100%', marginLeft: '0.1rem' }, }), ]), diff --git a/src/pages/workspaces/workspace/workflows/WorkflowView.test.js b/src/pages/workspaces/workspace/workflows/WorkflowView.test.js index aa2d1ba94a..ea2b9a7f13 100644 --- a/src/pages/workspaces/workspace/workflows/WorkflowView.test.js +++ b/src/pages/workspaces/workspace/workflows/WorkflowView.test.js @@ -694,4 +694,32 @@ describe('Workflow View (GCP)', () => { // check that workflow cost capping is shown expect(screen.queryByText('Set cost limit per workflow (BETA)')).not.toBeNull(); }); + + it('updates perWorkflowCostCap state on input change', async () => { + // Arrange + asMockedFn(isFeaturePreviewEnabled).mockReturnValue(true); + + const user = userEvent.setup(); + const namespace = 'gatk'; + const name = 'echo_to_file-configured'; + + mockDefaultAjax(); + + // Act + await act(async () => { + render(h(WorkflowView, { name, namespace, queryParams: { selectionKey } })); + }); + + const costCapInput = screen.getByPlaceholderText('Example: 1.00'); + expect(costCapInput).toBeInTheDocument(); + + // Assert initial state + expect(costCapInput).toHaveValue(null); + + // Act + await user.type(costCapInput, '123.456'); + + // Assert updated state + expect(Number(costCapInput.value)).toBeCloseTo(123.456, 2); + }); });