Skip to content

Commit 8a4d8b2

Browse files
committed
workflow_detail tests
Signed-off-by: saimedhi <saimedhi@amazon.com>
1 parent 1e39db4 commit 8a4d8b2

File tree

1 file changed

+34
-87
lines changed

1 file changed

+34
-87
lines changed

public/pages/workflow_detail/workflow_detail.test.tsx

+34-87
Original file line numberDiff line numberDiff line change
@@ -57,94 +57,41 @@ const workflowId = '12345';
5757
const workflowName = 'test_workflow';
5858

5959
describe('WorkflowDetail', () => {
60-
test('renders the page with Custom type', () => {
61-
const { getAllByText, getByText, getByRole } = renderWithRouter(
62-
workflowId,
63-
workflowName,
64-
WORKFLOW_TYPE.CUSTOM
65-
);
60+
const workflowTypes = [
61+
WORKFLOW_TYPE.CUSTOM,
62+
WORKFLOW_TYPE.SEMANTIC_SEARCH,
63+
WORKFLOW_TYPE.HYBRID_SEARCH,
64+
];
6665

67-
expect(getAllByText(workflowName).length).toBeGreaterThan(0);
68-
expect(getAllByText('Create an ingest pipeline').length).toBeGreaterThan(0);
69-
expect(getAllByText('Skip ingestion pipeline').length).toBeGreaterThan(0);
70-
expect(getAllByText('Define ingest pipeline').length).toBeGreaterThan(0);
71-
expect(getAllByText('Tools').length).toBeGreaterThan(0);
72-
expect(getAllByText('Preview').length).toBeGreaterThan(0);
73-
expect(getAllByText('Not started').length).toBeGreaterThan(0);
74-
expect(
75-
getAllByText((content, element) => content.startsWith('Last updated:'))
76-
.length
77-
).toBeGreaterThan(0);
78-
expect(getAllByText('Search pipeline').length).toBeGreaterThan(0);
79-
expect(getByText('Close')).toBeInTheDocument();
80-
expect(getByText('Export')).toBeInTheDocument();
81-
expect(getByText('Visual')).toBeInTheDocument();
82-
expect(getByText('JSON')).toBeInTheDocument();
83-
expect(getByRole('tab', { name: 'Run ingestion' })).toBeInTheDocument();
84-
expect(getByRole('tab', { name: 'Run queries' })).toBeInTheDocument();
85-
expect(getByRole('tab', { name: 'Errors' })).toBeInTheDocument();
86-
expect(getByRole('tab', { name: 'Resources' })).toBeInTheDocument();
87-
});
88-
});
89-
90-
describe('WorkflowDetail', () => {
91-
test('renders the page with Semantic Search type', () => {
92-
const { getAllByText, getByText, getByRole } = renderWithRouter(
93-
workflowId,
94-
workflowName,
95-
WORKFLOW_TYPE.SEMANTIC_SEARCH
96-
);
97-
98-
expect(getAllByText(workflowName).length).toBeGreaterThan(0);
99-
expect(getAllByText('Create an ingest pipeline').length).toBeGreaterThan(0);
100-
expect(getAllByText('Skip ingestion pipeline').length).toBeGreaterThan(0);
101-
expect(getAllByText('Define ingest pipeline').length).toBeGreaterThan(0);
102-
expect(getAllByText('Tools').length).toBeGreaterThan(0);
103-
expect(getAllByText('Preview').length).toBeGreaterThan(0);
104-
expect(getAllByText('Not started').length).toBeGreaterThan(0);
105-
expect(
106-
getAllByText((content, element) => content.startsWith('Last updated:'))
107-
.length
108-
).toBeGreaterThan(0);
109-
expect(getAllByText('Search pipeline').length).toBeGreaterThan(0);
110-
expect(getByText('Close')).toBeInTheDocument();
111-
expect(getByText('Export')).toBeInTheDocument();
112-
expect(getByText('Visual')).toBeInTheDocument();
113-
expect(getByText('JSON')).toBeInTheDocument();
114-
expect(getByRole('tab', { name: 'Run ingestion' })).toBeInTheDocument();
115-
expect(getByRole('tab', { name: 'Run queries' })).toBeInTheDocument();
116-
expect(getByRole('tab', { name: 'Errors' })).toBeInTheDocument();
117-
expect(getByRole('tab', { name: 'Resources' })).toBeInTheDocument();
118-
});
119-
});
120-
121-
describe('WorkflowDetail', () => {
122-
test('renders the page with Hybrid Search type', () => {
123-
const { getAllByText, getByText, getByRole } = renderWithRouter(
124-
workflowId,
125-
workflowName,
126-
WORKFLOW_TYPE.HYBRID_SEARCH
127-
);
66+
workflowTypes.forEach((type) => {
67+
test(`renders the page with ${type} type`, () => {
68+
const { getAllByText, getByText, getByRole } = renderWithRouter(
69+
workflowId,
70+
workflowName,
71+
type
72+
);
12873

129-
expect(getAllByText(workflowName).length).toBeGreaterThan(0);
130-
expect(getAllByText('Create an ingest pipeline').length).toBeGreaterThan(0);
131-
expect(getAllByText('Skip ingestion pipeline').length).toBeGreaterThan(0);
132-
expect(getAllByText('Define ingest pipeline').length).toBeGreaterThan(0);
133-
expect(getAllByText('Tools').length).toBeGreaterThan(0);
134-
expect(getAllByText('Preview').length).toBeGreaterThan(0);
135-
expect(getAllByText('Not started').length).toBeGreaterThan(0);
136-
expect(
137-
getAllByText((content, element) => content.startsWith('Last updated:'))
138-
.length
139-
).toBeGreaterThan(0);
140-
expect(getAllByText('Search pipeline').length).toBeGreaterThan(0);
141-
expect(getByText('Close')).toBeInTheDocument();
142-
expect(getByText('Export')).toBeInTheDocument();
143-
expect(getByText('Visual')).toBeInTheDocument();
144-
expect(getByText('JSON')).toBeInTheDocument();
145-
expect(getByRole('tab', { name: 'Run ingestion' })).toBeInTheDocument();
146-
expect(getByRole('tab', { name: 'Run queries' })).toBeInTheDocument();
147-
expect(getByRole('tab', { name: 'Errors' })).toBeInTheDocument();
148-
expect(getByRole('tab', { name: 'Resources' })).toBeInTheDocument();
74+
expect(getAllByText(workflowName).length).toBeGreaterThan(0);
75+
expect(getAllByText('Create an ingest pipeline').length).toBeGreaterThan(
76+
0
77+
);
78+
expect(getAllByText('Skip ingestion pipeline').length).toBeGreaterThan(0);
79+
expect(getAllByText('Define ingest pipeline').length).toBeGreaterThan(0);
80+
expect(getAllByText('Tools').length).toBeGreaterThan(0);
81+
expect(getAllByText('Preview').length).toBeGreaterThan(0);
82+
expect(getAllByText('Not started').length).toBeGreaterThan(0);
83+
expect(
84+
getAllByText((content) => content.startsWith('Last updated:')).length
85+
).toBeGreaterThan(0);
86+
expect(getAllByText('Search pipeline').length).toBeGreaterThan(0);
87+
expect(getByText('Close')).toBeInTheDocument();
88+
expect(getByText('Export')).toBeInTheDocument();
89+
expect(getByText('Visual')).toBeInTheDocument();
90+
expect(getByText('JSON')).toBeInTheDocument();
91+
expect(getByRole('tab', { name: 'Run ingestion' })).toBeInTheDocument();
92+
expect(getByRole('tab', { name: 'Run queries' })).toBeInTheDocument();
93+
expect(getByRole('tab', { name: 'Errors' })).toBeInTheDocument();
94+
expect(getByRole('tab', { name: 'Resources' })).toBeInTheDocument();
95+
});
14996
});
15097
});

0 commit comments

Comments
 (0)