11import React from 'react' ;
22import { render , screen } from '@mongodb-js/testing-library-compass' ;
3- import IndexFlowSection from './index-flow-section' ;
3+ import IndexFlowSection , {
4+ generateCoveredQueries ,
5+ generateCoveredQueriesArr ,
6+ generateOptimalQueries ,
7+ } from './index-flow-section' ;
48import { expect } from 'chai' ;
5- import type { Field } from '../../modules/create-index' ;
9+ import { ActionTypes , type Field } from '../../modules/create-index' ;
610import { Provider } from 'react-redux' ;
711import { setupStore } from '../../../test/setup-store' ;
812
@@ -75,18 +79,28 @@ describe('IndexFlowSection', () => {
7579 } ) ;
7680 } ) ;
7781
78- // TODO: fix in CLOUDP-325883
79- describe . skip ( 'when 4 index fields are filled in and user clicks on covered queries button' , ( ) => {
82+ describe ( 'when 4 index fields are filled in and user clicks on covered queries button' , ( ) => {
8083 const fields : Field [ ] = [
8184 { name : 'field1' , type : '1 (asc)' } ,
8285 { name : 'field2' , type : '-1 (desc)' } ,
8386 { name : 'field3' , type : '1 (asc)' } ,
8487 { name : 'field4' , type : '1 (asc)' } ,
8588 ] ;
8689
90+ const coveredQueriesArr = generateCoveredQueriesArr ( fields ) ;
91+ const coveredQueries = generateCoveredQueries ( coveredQueriesArr , ( ) => { } ) ;
92+ const optimalQueries = generateOptimalQueries ( coveredQueriesArr ) ;
93+
8794 beforeEach ( ( ) => {
8895 renderComponent ( { fields } ) ;
96+
8997 screen . getByTestId ( 'index-flow-section-covered-queries-button' ) . click ( ) ;
98+ store . dispatch ( {
99+ type : ActionTypes . CoveredQueriesFetched ,
100+ coveredQueries,
101+ optimalQueries,
102+ showCoveredQueries : true ,
103+ } ) ;
90104 } ) ;
91105
92106 it ( 'renders the covered queries examples' , ( ) => {
@@ -125,17 +139,27 @@ describe('IndexFlowSection', () => {
125139 } ) ;
126140 } ) ;
127141
128- // TODO: fix in CLOUDP-325883
129- describe . skip ( 'when 3 index fields are filled in and user clicks on covered queries button' , ( ) => {
142+ describe ( 'when 3 index fields are filled in and user clicks on covered queries button' , ( ) => {
130143 const fields : Field [ ] = [
131144 { name : 'field1' , type : '1 (asc)' } ,
132145 { name : 'field2' , type : '-1 (desc)' } ,
133146 { name : 'field3' , type : '1 (asc)' } ,
134147 ] ;
135148
149+ const coveredQueriesArr = generateCoveredQueriesArr ( fields ) ;
150+ const coveredQueries = generateCoveredQueries ( coveredQueriesArr , ( ) => { } ) ;
151+ const optimalQueries = generateOptimalQueries ( coveredQueriesArr ) ;
152+
136153 beforeEach ( ( ) => {
137154 renderComponent ( { fields } ) ;
155+
138156 screen . getByTestId ( 'index-flow-section-covered-queries-button' ) . click ( ) ;
157+ store . dispatch ( {
158+ type : ActionTypes . CoveredQueriesFetched ,
159+ coveredQueries,
160+ optimalQueries,
161+ showCoveredQueries : true ,
162+ } ) ;
139163 } ) ;
140164
141165 it ( 'renders the covered queries examples' , ( ) => {
@@ -173,16 +197,26 @@ describe('IndexFlowSection', () => {
173197 } ) ;
174198 } ) ;
175199
176- // TODO: fix in CLOUDP-325883
177- describe . skip ( 'when 2 index fields are filled in and user clicks on covered queries button' , ( ) => {
200+ describe ( 'when 2 index fields are filled in and user clicks on covered queries button' , ( ) => {
178201 const fields : Field [ ] = [
179202 { name : 'field1' , type : '1 (asc)' } ,
180203 { name : 'field2' , type : '1 (asc)' } ,
181204 ] ;
182205
206+ const coveredQueriesArr = generateCoveredQueriesArr ( fields ) ;
207+ const coveredQueries = generateCoveredQueries ( coveredQueriesArr , ( ) => { } ) ;
208+ const optimalQueries = generateOptimalQueries ( coveredQueriesArr ) ;
209+
183210 beforeEach ( ( ) => {
184211 renderComponent ( { fields } ) ;
212+
185213 screen . getByTestId ( 'index-flow-section-covered-queries-button' ) . click ( ) ;
214+ store . dispatch ( {
215+ type : ActionTypes . CoveredQueriesFetched ,
216+ coveredQueries,
217+ optimalQueries,
218+ showCoveredQueries : true ,
219+ } ) ;
186220 } ) ;
187221
188222 it ( 'renders the covered queries examples' , ( ) => {
@@ -206,13 +240,23 @@ describe('IndexFlowSection', () => {
206240 } ) ;
207241 } ) ;
208242
209- // TODO: fix in CLOUDP-325883
210- describe . skip ( 'when 1 index field is filled in and user clicks on covered queries button' , ( ) => {
243+ describe ( 'when 1 index field is filled in and user clicks on covered queries button' , ( ) => {
211244 const fields : Field [ ] = [ { name : 'field1' , type : '1 (asc)' } ] ;
212245
246+ const coveredQueriesArr = generateCoveredQueriesArr ( fields ) ;
247+ const coveredQueries = generateCoveredQueries ( coveredQueriesArr , ( ) => { } ) ;
248+ const optimalQueries = generateOptimalQueries ( coveredQueriesArr ) ;
249+
213250 beforeEach ( ( ) => {
214251 renderComponent ( { fields } ) ;
252+
215253 screen . getByTestId ( 'index-flow-section-covered-queries-button' ) . click ( ) ;
254+ store . dispatch ( {
255+ type : ActionTypes . CoveredQueriesFetched ,
256+ coveredQueries,
257+ optimalQueries,
258+ showCoveredQueries : true ,
259+ } ) ;
216260 } ) ;
217261
218262 it ( 'renders the covered queries examples' , ( ) => {
0 commit comments