Skip to content

Commit

Permalink
added
Browse files Browse the repository at this point in the history
  • Loading branch information
Sai Medhini Reddy Maryada authored and Sai Medhini Reddy Maryada committed Sep 11, 2024
1 parent cd96bdc commit 23622a2
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 62 deletions.
2 changes: 1 addition & 1 deletion public/pages/workflow_detail/resizable_workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export function ResizableWorkspace(props: ResizableWorkspaceProps) {
</EuiFlexItem>
</EuiFlexGroup>
</EuiResizablePanel>
<EuiResizableButton data-testid="toolsPanelCollapseButton" />
<EuiResizableButton data-testid="toolsPanelSizeAdjustButton" />
<EuiResizablePanel
id={TOOLS_PANEL_ID}
mode="collapsible"
Expand Down
117 changes: 58 additions & 59 deletions public/pages/workflow_detail/workflow_detail.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import React from 'react';
import { render, waitFor } from '@testing-library/react';
import { getAllByTestId, render, waitFor } from '@testing-library/react';
import { Provider } from 'react-redux';
import { RouteComponentProps, Route, Switch, Router } from 'react-router-dom';
import userEvent from '@testing-library/user-event';
Expand Down Expand Up @@ -60,7 +60,7 @@ const renderWithRouter = (
};
};

describe('WorkflowDetail', () => {
describe('WorkflowDetail with create ingestion', () => {
Object.values(WORKFLOW_TYPE).forEach((type) => {
test(`renders the page with ${type} type`, async () => {
const {
Expand Down Expand Up @@ -104,13 +104,13 @@ describe('WorkflowDetail', () => {
expect(searchPipelineButton).toBeInTheDocument();
expect(searchPipelineButton).toBeDisabled();

// // "Create an ingest pipeline" option should be selected by default
// const createIngestRadio = getByLabelText('createIngestPipelineOption');
// expect(createIngestRadio).toBeChecked();
// "Create an ingest pipeline" option should be selected by default
const createIngestRadio = container.querySelector("#create");
expect(createIngestRadio).toBeChecked();

// // "Skip ingestion pipeline" option should be disabled by default
// const skipIngestRadio = getByTestId('skipIngestPipelineOption');
// expect(skipIngestRadio).not.toBeChecked();
// "Skip ingestion pipeline" option should be disabled by default
const skipIngestRadio = container.querySelector("#skip");
expect(skipIngestRadio).not.toBeChecked();

// Clicking the "Export" button should open the export component
await waitFor(() => userEvent.click(getByTestId('exportButton')));
Expand All @@ -127,65 +127,64 @@ describe('WorkflowDetail', () => {
await waitFor(() => userEvent.click(jsonButton));
expect(jsonButton).toHaveClass('euiFilterButton-hasActiveFilters');

// Testing collapsible Tools panel
const toolsPanel = getByTestId('toolsPanelCollapseButton'); // Assuming the collapse button has the 'toolsPanelCollapseButton' test id

const toolsPanelContainer = getByTestId('toolsPanelId'); // Assuming the Tools panel has a test ID 'toolsPanel'

// Initial state: Tools panel should be open and not collapsed
expect(getByText('Tools')).toBeVisible();
expect(toolsPanelContainer).not.toHaveClass(

// Testing collapsible Tools panel
// Get the initial state of the Tools panel

const toolsPanelInitially = container.querySelector('#tools_panel_id');
expect(toolsPanelInitially).toBeVisible();
// Find and click the button to adjust panel sizes
// const adjustPanelSizeButton = getByTestId('toolsPanelSizeAdjustButton');
// // const adjustPanelSizeButton = container.querySelector(
// // 'button[aria-label="Press up or down to adjust panels size"].euiResizableButton--vertical'
// // );
// expect(adjustPanelSizeButton).toBeInTheDocument();
//console.log("toolsPanelInitially printed", toolsPanelInitially);
// await waitFor(() => userEvent.click(adjustPanelSizeButton!));
// Find the toggle button for the Tools panel
const toggleButton = toolsPanelInitially?.querySelector(
'button[type="button"]'
// aria-label="Press to toggle this panel"].euiResizableToggleButton--vertical'
);
//console.log("toggleButton printed", toggleButton);
expect(toggleButton).toBeInTheDocument();
// expect(toggleButton).toHaveClass('euiResizableToggleButton-isVisible');
// Collapse the Tools panel
await waitFor(() => userEvent.click(toggleButton!));
const toolsPanelAfterCollapse = container.querySelector(
'#tools_panel_id'
)!;
expect(toolsPanelAfterCollapse).toHaveClass(
'euiResizablePanel-isCollapsed'
);

// Click to collapse the Tools panel
await waitFor(() => userEvent.click(toolsPanel));

// After collapsing, the Tools panel should not be visible and should have the collapsed class
// expect(getByText('Tools')).not.toBeVisible();
expect(toolsPanelContainer).toHaveClass('euiResizablePanel-isCollapsed');

// Click again to expand the Tools panel
await waitFor(() => userEvent.click(toolsPanel));

// After expanding, the Tools panel should be visible and should not have the collapsed class
expect(getByText('Tools')).toBeVisible();
expect(toolsPanelContainer).not.toHaveClass(
// Expand the Tools panel
await waitFor(() => userEvent.click(toggleButton!));
const toolsPanelAfterExpand = container.querySelector('#tools_panel_id')!;
expect(toolsPanelAfterExpand).not.toHaveClass(
'euiResizablePanel-isCollapsed'
);

// // Testing collapsible Tools panel
// // // Get the initial state of the Tools panel
// // const toolsPanelInitially = container.querySelector('#tools_panel_id');
// // expect(toolsPanelInitially).toBeVisible();
// // Find and click the button to adjust panel sizes
// const adjustPanelSizeButton = getByTestId('toolsPanelCollapseButton');
// expect(adjustPanelSizeButton).toBeInTheDocument();
// await waitFor(() => userEvent.click(adjustPanelSizeButton!));
// // Find the toggle button for the Tools panel
// const toggleButton = container.querySelector(
// 'button[aria-label="Press to toggle this panel"].euiResizableToggleButton--vertical'
// );
// expect(toggleButton).toBeInTheDocument();
// expect(toggleButton).toHaveClass('euiResizableToggleButton-isVisible');
// // Collapse the Tools panel
// await waitFor(() => userEvent.click(toggleButton!));
// const toolsPanelAfterCollapse = container.querySelector(
// '#tools_panel_id'
// )!;
// expect(toolsPanelAfterCollapse).toHaveClass(
// 'euiResizablePanel-isCollapsed'
// );
// // Expand the Tools panel
// await waitFor(() => userEvent.click(toggleButton!));
// const toolsPanelAfterExpand = container.querySelector('#tools_panel_id')!;
// expect(toolsPanelAfterExpand).not.toHaveClass(
// 'euiResizablePanel-isCollapsed'
// );

// Clicking the "close" button should go back to the list page
await waitFor(() => userEvent.click(getByTestId('closeButton')));
expect(history.location.pathname).toBe('/workflows');
});
});
});

describe('WorkflowDetail skip ingestion pipeline', () => {
Object.values(WORKFLOW_TYPE).forEach((type) => {
test(`renders the page with ${type} type`, async () => {
const {
container,
} = renderWithRouter(workflowId, workflowName, type);

const skipIngestRadio = container.querySelector("#skip");
expect(skipIngestRadio).not.toBeChecked();

// Clicking the "Export" button should open the export component
await waitFor(() => userEvent.click(skipIngestRadio!));
expect(skipIngestRadio).toBeChecked();

});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ export function WorkflowInputs(props: WorkflowInputsProps) {
<EuiFlexGroup direction="column" gutterSize="none">
<EuiText
color="default"
data-testid="createIngestPipelineOption"
// data-testid="createIngestPipelineOption"
>
Create an ingest pipeline
</EuiText>
Expand All @@ -673,7 +673,7 @@ export function WorkflowInputs(props: WorkflowInputsProps) {
<EuiFlexGroup direction="column" gutterSize="none">
<EuiText
color="default"
data-testid="skipIngestPipelineOption"
// data-testid="skipIngestPipelineOption"
>
Skip ingestion pipeline
</EuiText>
Expand Down

0 comments on commit 23622a2

Please sign in to comment.