Skip to content

Commit

Permalink
address comments on 12/26
Browse files Browse the repository at this point in the history
Signed-off-by: Kama Huang <[email protected]>
  • Loading branch information
Kama Huang committed Dec 28, 2024
1 parent f0d6196 commit 5e853ab
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 87 deletions.
2 changes: 2 additions & 0 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export enum WORKFLOW_TYPE {
}
// If no datasource version is found, we default to 2.17.0
export const MIN_SUPPORTED_VERSION = '2.17.0';
// Min version to support ML processors
export const MINIMUM_FULL_SUPPORTED_VERSION = '2.19.0';

// the names should be consistent with the underlying implementation. used when generating the
// final ingest/search pipeline configurations.
Expand Down
26 changes: 13 additions & 13 deletions public/pages/workflow_detail/workflow_detail.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,28 @@ describe('WorkflowDetail Page Functionality (Custom Workflow)', () => {
workflowName,
WORKFLOW_TYPE.CUSTOM
);

// Export button opens the export component
userEvent.click(getByTestId('exportButton'));
await waitFor(() => {
expect(getByText(`Export '${workflowName}'`)).toBeInTheDocument();
});
// Close the export component
userEvent.click(getByTestId('exportCloseButton'));

// Check workspace button group exists (Visual and JSON)
getByTestId('visualJSONToggleButtonGroup');

// Tools panel should collapse and expand the toggle
const toolsPanel = container.querySelector('#tools_panel_id');
expect(toolsPanel).toBeVisible();

const toggleButton = toolsPanel?.querySelector('button[type="button"]');
expect(toggleButton).toBeInTheDocument();
userEvent.click(toggleButton!);

// Tools panel after collapsing
const collapsedToolsPanel = container.querySelector('#tools_panel_id');
await waitFor(() => {
expect(collapsedToolsPanel).toHaveClass('euiResizablePanel-isCollapsed');
});

// Tools panel after expanding
userEvent.click(toggleButton!);
const expandedToolsPanel = container.querySelector('#tools_panel_id');
await waitFor(() => {
Expand All @@ -147,7 +147,7 @@ describe('WorkflowDetail Page Functionality (Custom Workflow)', () => {
workflowName,
WORKFLOW_TYPE.CUSTOM
);

// The WorkflowDetail Page Close button should navigate back to the workflows list
userEvent.click(getByTestId('closeButton'));
await waitFor(() => {
expect(history.location.pathname).toBe('/workflows');
Expand All @@ -166,20 +166,20 @@ describe('WorkflowDetail Page with skip ingestion option (Hybrid Search Workflow
workflowName,
WORKFLOW_TYPE.HYBRID_SEARCH
);

// Defining a new ingest pipeline & index is enabled by default
const enabledCheckbox = getByTestId('switch-ingest.enabled');

// Skipping ingest pipeline and navigating to search
userEvent.click(enabledCheckbox);
await waitFor(() => {});

const searchPipelineButton = getByTestId('searchPipelineButton');
userEvent.click(searchPipelineButton);

// Search pipeline
await waitFor(() => {
expect(getAllByText('Define search flow').length).toBeGreaterThan(0);
});
expect(getAllByText('Configure query').length).toBeGreaterThan(0);

// Edit Search Query
const queryEditButton = getByTestId('queryEditButton');
expect(queryEditButton).toBeInTheDocument();
userEvent.click(queryEditButton);
Expand All @@ -193,7 +193,7 @@ describe('WorkflowDetail Page with skip ingestion option (Hybrid Search Workflow
const updateSearchQueryButton = getByTestId('updateSearchQueryButton');
expect(updateSearchQueryButton).toBeInTheDocument();
userEvent.click(updateSearchQueryButton);

// Add request processor
const addRequestProcessorButton = await waitFor(
() => getAllByTestId('addProcessorButton')[0]
);
Expand All @@ -203,14 +203,14 @@ describe('WorkflowDetail Page with skip ingestion option (Hybrid Search Workflow
const popoverPanel = document.querySelector('.euiPopover__panel');
expect(popoverPanel).toBeTruthy();
});

// Add response processor
const addResponseProcessorButton = getAllByTestId('addProcessorButton')[1];
userEvent.click(addResponseProcessorButton);
await waitFor(() => {
const popoverPanel = document.querySelector('.euiPopover__panel');
expect(popoverPanel).toBeTruthy();
});

// Build and Run query, Back buttons are present
const searchPipelineBackButton = getByTestId('searchPipelineBackButton');
userEvent.click(searchPipelineBackButton);

Expand Down
10 changes: 7 additions & 3 deletions public/pages/workflow_detail/workflow_inputs/processors_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ import {
import { ProcessorInputs } from './processor_inputs';
import { useLocation } from 'react-router-dom';
import { getDataSourceEnabled } from '../../../../public/services';
import {
MIN_SUPPORTED_VERSION,
MINIMUM_FULL_SUPPORTED_VERSION,
} from '../../../../common';

interface ProcessorsListProps {
uiConfig: WorkflowConfig;
Expand Down Expand Up @@ -78,7 +82,7 @@ export function ProcessorsList(props: ProcessorsListProps) {

const enabled = getDataSourceEnabled().enabled;
if (!enabled) {
setVersion('2.19.0');
setVersion(MINIMUM_FULL_SUPPORTED_VERSION);
return;
}

Expand Down Expand Up @@ -110,7 +114,8 @@ export function ProcessorsList(props: ProcessorsListProps) {

const getMenuItems = () => {
const isPreV219 =
semver.gte(version, '2.17.0') && semver.lt(version, '2.19.0');
semver.gte(version, MIN_SUPPORTED_VERSION) &&
semver.lt(version, MINIMUM_FULL_SUPPORTED_VERSION);
const ingestProcessors = [
...(isPreV219
? [
Expand Down Expand Up @@ -377,7 +382,6 @@ export function ProcessorsList(props: ProcessorsListProps) {
title: getMenuItems().length > 0 ? 'PROCESSORS' : '',
items: (() => {
const items = getMenuItems();
console.log('Menu items:', items);
return items;
})(),
},
Expand Down
14 changes: 10 additions & 4 deletions public/pages/workflows/new_workflow/new_workflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { getSavedObjectsClient } from '../../../../public/services';
import {
WORKFLOW_TYPE,
MIN_SUPPORTED_VERSION,
MINIMUM_FULL_SUPPORTED_VERSION,
} from '../../../../common/constants';

interface NewWorkflowProps {}
Expand Down Expand Up @@ -64,7 +65,6 @@ const filterPresetsByVersion = async (
workflows: WorkflowTemplate[],
dataSourceId: string | undefined
): Promise<WorkflowTemplate[]> => {
console.log('Initial workflows count:', workflows.length);
// if MDS is disabled, skip the version check and assume it is version 2.19+
const dataSourceEnabled = getDataSourceEnabled().enabled;
if (!dataSourceEnabled) {
Expand All @@ -84,11 +84,14 @@ const filterPresetsByVersion = async (
try {
const version = await getEffectiveVersion(dataSourceId);

if (semver.lt(version, '2.17.0')) {
if (semver.lt(version, MIN_SUPPORTED_VERSION)) {
return [];
}

if (semver.gte(version, '2.17.0') && semver.lt(version, '2.19.0')) {
if (
semver.gte(version, MIN_SUPPORTED_VERSION) &&
semver.lt(version, MINIMUM_FULL_SUPPORTED_VERSION)
) {
return workflows.filter((workflow) => {
const workflowType =
workflow.ui_metadata?.type ?? WORKFLOW_TYPE.UNKNOWN;
Expand Down Expand Up @@ -154,7 +157,10 @@ export function NewWorkflow(props: NewWorkflowProps) {

if (!dataSourceEnabled) {
const enrichedWorkflows = presetWorkflows.map((presetWorkflow) =>
enrichPresetWorkflowWithUiMetadata(presetWorkflow, '2.19.0')
enrichPresetWorkflowWithUiMetadata(
presetWorkflow,
MINIMUM_FULL_SUPPORTED_VERSION
)
);
setAllWorkflows(enrichedWorkflows);
setFilteredWorkflows(enrichedWorkflows);
Expand Down
Loading

0 comments on commit 5e853ab

Please sign in to comment.