/** * Copyright (c) 2020-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { ContextMenu, PlusIcon, ResizablePanel, ResizablePanelGroup, ResizablePanelSplitter, ResizablePanelSplitterLine, MenuContent, MenuContentItem, clsx, FlaskIcon, RunAllIcon, RunErrorsIcon, CheckCircleIcon, TimesCircleIcon, TestTubeIcon, CustomSelectorInput, Dialog, RefreshIcon, TimesIcon, FilledWindowMaximizeIcon, PlayIcon, } from '@finos/legend-art'; import { type ValueSpecification, PrimitiveInstanceValue, PrimitiveType, PureMultiExecution, resolveServiceQueryRawLambda, } from '@finos/legend-graph'; import { BasicValueSpecificationEditor, instanceValue_setValue, } from '@finos/legend-query-builder'; import { filterByType, guaranteeNonNullable, prettyCONSTName, } from '@finos/legend-shared'; import { flowResult } from 'mobx'; import { observer } from 'mobx-react-lite'; import { forwardRef, useEffect, useState } from 'react'; import type { ServiceTestSuiteState } from '../../../../../stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js'; import { type KeyOption, type ServiceTestSetupState, type ServiceTestState, ServiceValueSpecificationTestParameterState, } from '../../../../../stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js'; import { TESTABLE_TEST_TAB } from '../../../../../stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js'; import { atomicTest_setId, testAssertion_setId, } from '../../../../../stores/graph-modifier/Testable_GraphModifierHelper.js'; import { getTestableResultFromTestResult, TESTABLE_RESULT, } from '../../../../../stores/editor/sidebar-state/testable/GlobalTestRunnerState.js'; import { getTestableResultIcon } from '../../../side-bar/testable/GlobalTestRunner.js'; import { ExternalFormatParameterEditorModal, RenameModal, TestAssertionEditor, TestAssertionItem, } from '../../testable/TestableSharedComponents.js'; import { LEGEND_STUDIO_TEST_ID } from '../../../../../__lib__/LegendStudioTesting.js'; import { getContentTypeWithParamFromQuery, type TestParamContentType, } from '../../../../../stores/editor/utils/TestableUtils.js'; export const NewParameterModal = observer( (props: { setupState: ServiceTestSetupState; isReadOnly: boolean }) => { const { setupState, isReadOnly } = props; const applicationStore = setupState.editorStore.applicationStore; const currentOption = { value: setupState.newParameterValueName, label: setupState.newParameterValueName, }; const options = setupState.newParamOptions; const closeModal = (): void => setupState.setShowNewParameterModal(false); const onChange = (val: { label: string; value: string } | null): void => { if (val === null) { setupState.setNewParameterValueName(''); } else if (val.value !== setupState.newParameterValueName) { setupState.setNewParameterValueName(val.value); } }; return (
{ event.preventDefault(); setupState.addParameterValue(); }} className="modal modal--dark search-modal" >
New Test Parameter Value
); }, ); const ServiceTestParameterEditor = observer( (props: { isReadOnly: boolean; paramState: ServiceValueSpecificationTestParameterState; serviceTestState: ServiceTestState; contentTypeParamPair: TestParamContentType | undefined; }) => { const { serviceTestState, paramState, isReadOnly, contentTypeParamPair } = props; const [showPopUp, setShowPopUp] = useState(false); const setupState = serviceTestState.setupState; const paramIsRequired = paramState.varExpression.multiplicity.lowerBound > 0; const type = contentTypeParamPair ? contentTypeParamPair.contentType : (paramState.varExpression.genericType?.value.rawType.name ?? 'unknown'); const paramValue = paramState.varExpression.genericType?.value.rawType === PrimitiveType.BYTE ? atob( (paramState.valueSpec as PrimitiveInstanceValue) .values[0] as string, ) : ((paramState.valueSpec as PrimitiveInstanceValue) .values[0] as string); const openInPopUp = (): void => setShowPopUp(!showPopUp); const closePopUp = (): void => setShowPopUp(false); const updateParamValue = (val: string): void => { if (paramState.valueSpec instanceof PrimitiveInstanceValue) { instanceValue_setValue( paramState.valueSpec, paramState.varExpression.genericType?.value.rawType === PrimitiveType.BYTE ? btoa(val) : val, 0, setupState.editorStore.changeDetectionState.observerContext, ); paramState.updateValueSpecification(paramState.valueSpec); } }; return (
{paramState.parameterValue.name}
<> {contentTypeParamPair ? (