Skip to content

Commit 6403a8c

Browse files
committed
add testing
1 parent fdcc282 commit 6403a8c

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from 'react';
2+
import { render, screen } from '@mongodb-js/testing-library-compass';
3+
import QueryFlowSection from './query-flow-section';
4+
import { expect } from 'chai';
5+
6+
describe('QueryFlowSection', () => {
7+
it('renders the input query section with placeholder text', () => {
8+
render(<QueryFlowSection />);
9+
const inputElement = screen.getByPlaceholderText(
10+
"Type a query: { field: 'value' }"
11+
);
12+
expect(inputElement).to.be.visible;
13+
});
14+
15+
it('renders the "Show me suggested index" button', () => {
16+
render(<QueryFlowSection />);
17+
const buttonElement = screen.getByText('Show me suggested index');
18+
expect(buttonElement).to.be.visible;
19+
});
20+
21+
it('renders the suggested index section with formatted index code', () => {
22+
render(<QueryFlowSection />);
23+
const codeElement = screen.getByTestId(
24+
'query-flow-section-suggested-index'
25+
);
26+
expect(codeElement).to.be.visible;
27+
});
28+
29+
it('renders the link to the MongoDB documentation', () => {
30+
render(<QueryFlowSection />);
31+
const linkElement = screen.getByText('here');
32+
expect(linkElement).to.be.visible;
33+
});
34+
});

packages/compass-indexes/src/components/create-index-form/query-flow-section.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ db.getSiblingDB("${db_name}").getCollection("${collection_name}").createIndex(
9292
Suggested Index
9393
</Body>{' '}
9494
<div className={suggestedIndexContainerStyles}>
95-
<Code language="javascript">{formatSuggestedIndex()}</Code>
95+
<Code
96+
data-testid="query-flow-section-suggested-index"
97+
language="javascript"
98+
>
99+
{formatSuggestedIndex()}
100+
</Code>
96101
<span className={programmingLanguageLinkStyles}>
97102
View programming language driver syntax{' '}
98103
<Link

0 commit comments

Comments
 (0)