Skip to content

Commit

Permalink
Merge pull request #5 from saimedhi/tests2_copy
Browse files Browse the repository at this point in the history
workflow_detail tests
  • Loading branch information
saimedhi authored Sep 5, 2024
2 parents 6735c58 + 8a4d8b2 commit 99fb0b3
Show file tree
Hide file tree
Showing 2 changed files with 239 additions and 213 deletions.
136 changes: 36 additions & 100 deletions public/pages/workflow_detail/workflow_detail.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,10 @@ window.ResizeObserver = resizeObserverMock;
const renderWithRouter = (
workflowId: string,
workflowName: string,
workflowType: WORKFLOW_TYPE,
includeProcessor: boolean
workflowType: WORKFLOW_TYPE
) => ({
...render(
<Provider
store={mockStore(
workflowId,
workflowName,
workflowType,
includeProcessor
)}
>
<Provider store={mockStore(workflowId, workflowName, workflowType)}>
<Router history={history}>
<Switch>
<Route
Expand All @@ -65,97 +57,41 @@ const workflowId = '12345';
const workflowName = 'test_workflow';

describe('WorkflowDetail', () => {
test('renders the page with Custom type', () => {
const { getAllByText, getByText, getByRole } = renderWithRouter(
workflowId,
workflowName,
WORKFLOW_TYPE.CUSTOM,
false
);

expect(getAllByText(workflowName).length).toBeGreaterThan(0);
expect(getAllByText('Create an ingest pipeline').length).toBeGreaterThan(0);
expect(getAllByText('Skip ingestion pipeline').length).toBeGreaterThan(0);
expect(getAllByText('Define ingest pipeline').length).toBeGreaterThan(0);
expect(getAllByText('Tools').length).toBeGreaterThan(0);
expect(getAllByText('Preview').length).toBeGreaterThan(0);
expect(getAllByText('Not started').length).toBeGreaterThan(0);
expect(
getAllByText((content, element) => content.startsWith('Last updated:'))
.length
).toBeGreaterThan(0);
expect(getAllByText('Search pipeline').length).toBeGreaterThan(0);
expect(getByText('Close')).toBeInTheDocument();
expect(getByText('Export')).toBeInTheDocument();
expect(getByText('Visual')).toBeInTheDocument();
expect(getByText('JSON')).toBeInTheDocument();
expect(getByRole('tab', { name: 'Run ingestion' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Run queries' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Errors' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Resources' })).toBeInTheDocument();
});
});

describe('WorkflowDetail', () => {
test('renders the page with Semantic Search type', () => {
const { getAllByText, getByText, getByRole } = renderWithRouter(
workflowId,
workflowName,
WORKFLOW_TYPE.SEMANTIC_SEARCH,
true
);
const workflowTypes = [
WORKFLOW_TYPE.CUSTOM,
WORKFLOW_TYPE.SEMANTIC_SEARCH,
WORKFLOW_TYPE.HYBRID_SEARCH,
];

expect(getAllByText(workflowName).length).toBeGreaterThan(0);
expect(getAllByText('Create an ingest pipeline').length).toBeGreaterThan(0);
expect(getAllByText('Skip ingestion pipeline').length).toBeGreaterThan(0);
expect(getAllByText('Define ingest pipeline').length).toBeGreaterThan(0);
expect(getAllByText('Tools').length).toBeGreaterThan(0);
expect(getAllByText('Preview').length).toBeGreaterThan(0);
expect(getAllByText('Not started').length).toBeGreaterThan(0);
expect(
getAllByText((content, element) => content.startsWith('Last updated:'))
.length
).toBeGreaterThan(0);
expect(getAllByText('Search pipeline').length).toBeGreaterThan(0);
expect(getByText('Close')).toBeInTheDocument();
expect(getByText('Export')).toBeInTheDocument();
expect(getByText('Visual')).toBeInTheDocument();
expect(getByText('JSON')).toBeInTheDocument();
expect(getByRole('tab', { name: 'Run ingestion' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Run queries' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Errors' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Resources' })).toBeInTheDocument();
});
});

describe('WorkflowDetail', () => {
test('renders the page with Hybrid Search type', () => {
const { getAllByText, getByText, getByRole } = renderWithRouter(
workflowId,
workflowName,
WORKFLOW_TYPE.HYBRID_SEARCH,
true
);
workflowTypes.forEach((type) => {
test(`renders the page with ${type} type`, () => {
const { getAllByText, getByText, getByRole } = renderWithRouter(
workflowId,
workflowName,
type
);

expect(getAllByText(workflowName).length).toBeGreaterThan(0);
expect(getAllByText('Create an ingest pipeline').length).toBeGreaterThan(0);
expect(getAllByText('Skip ingestion pipeline').length).toBeGreaterThan(0);
expect(getAllByText('Define ingest pipeline').length).toBeGreaterThan(0);
expect(getAllByText('Tools').length).toBeGreaterThan(0);
expect(getAllByText('Preview').length).toBeGreaterThan(0);
expect(getAllByText('Not started').length).toBeGreaterThan(0);
expect(
getAllByText((content, element) => content.startsWith('Last updated:'))
.length
).toBeGreaterThan(0);
expect(getAllByText('Search pipeline').length).toBeGreaterThan(0);
expect(getByText('Close')).toBeInTheDocument();
expect(getByText('Export')).toBeInTheDocument();
expect(getByText('Visual')).toBeInTheDocument();
expect(getByText('JSON')).toBeInTheDocument();
expect(getByRole('tab', { name: 'Run ingestion' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Run queries' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Errors' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Resources' })).toBeInTheDocument();
expect(getAllByText(workflowName).length).toBeGreaterThan(0);
expect(getAllByText('Create an ingest pipeline').length).toBeGreaterThan(
0
);
expect(getAllByText('Skip ingestion pipeline').length).toBeGreaterThan(0);
expect(getAllByText('Define ingest pipeline').length).toBeGreaterThan(0);
expect(getAllByText('Tools').length).toBeGreaterThan(0);
expect(getAllByText('Preview').length).toBeGreaterThan(0);
expect(getAllByText('Not started').length).toBeGreaterThan(0);
expect(
getAllByText((content) => content.startsWith('Last updated:')).length
).toBeGreaterThan(0);
expect(getAllByText('Search pipeline').length).toBeGreaterThan(0);
expect(getByText('Close')).toBeInTheDocument();
expect(getByText('Export')).toBeInTheDocument();
expect(getByText('Visual')).toBeInTheDocument();
expect(getByText('JSON')).toBeInTheDocument();
expect(getByRole('tab', { name: 'Run ingestion' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Run queries' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Errors' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Resources' })).toBeInTheDocument();
});
});
});
Loading

0 comments on commit 99fb0b3

Please sign in to comment.