Skip to content

Commit 48da5fc

Browse files
[Lens] Corrects incorrect copy for line chart & fix flaky test (#192734)
## Summary Corrects incorrect copy for line chart. Rewrites some of the tests to rtl. Unskips flaky or failing tests. Fixes #192476 Removes some errors from the console that appear during unit test running. --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> (cherry picked from commit e1db296)
1 parent 076cce8 commit 48da5fc

14 files changed

Lines changed: 476 additions & 942 deletions

File tree

x-pack/plugins/lens/public/app_plugin/shared/edit_on_the_fly/lens_configuration_flyout.test.tsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ const datasourceMap = mockDatasourceMap();
125125
const visualizationMap = mockVisualizationMap();
126126

127127
describe('LensEditConfigurationFlyout', () => {
128-
function renderConfigFlyout(
128+
async function renderConfigFlyout(
129129
propsOverrides: Partial<EditConfigPanelProps> = {},
130130
query?: Query | AggregateQuery
131131
) {
132-
return renderWithReduxStore(
132+
const { container, ...rest } = renderWithReduxStore(
133133
<LensEditConfigurationFlyout
134134
attributes={lensAttributes}
135135
updatePanelState={jest.fn()}
@@ -155,12 +155,13 @@ describe('LensEditConfigurationFlyout', () => {
155155
},
156156
}
157157
);
158+
await waitFor(() => container.querySelector('lnsEditFlyoutBody'));
159+
return { container, ...rest };
158160
}
159161

160162
it('should display the header and the link to editor if necessary props are given', async () => {
161163
const navigateToLensEditorSpy = jest.fn();
162-
163-
renderConfigFlyout({
164+
await renderConfigFlyout({
164165
displayFlyoutHeader: true,
165166
navigateToLensEditor: navigateToLensEditorSpy,
166167
});
@@ -170,7 +171,7 @@ describe('LensEditConfigurationFlyout', () => {
170171
});
171172

172173
it('should display the header title correctly for a newly created panel', async () => {
173-
renderConfigFlyout({
174+
await renderConfigFlyout({
174175
displayFlyoutHeader: true,
175176
isNewPanel: true,
176177
});
@@ -182,7 +183,7 @@ describe('LensEditConfigurationFlyout', () => {
182183
it('should call the closeFlyout callback if cancel button is clicked', async () => {
183184
const closeFlyoutSpy = jest.fn();
184185

185-
renderConfigFlyout({
186+
await renderConfigFlyout({
186187
closeFlyout: closeFlyoutSpy,
187188
});
188189
expect(screen.getByTestId('lns-layerPanel-0')).toBeInTheDocument();
@@ -192,7 +193,7 @@ describe('LensEditConfigurationFlyout', () => {
192193

193194
it('should call the updatePanelState callback if cancel button is clicked', async () => {
194195
const updatePanelStateSpy = jest.fn();
195-
renderConfigFlyout({
196+
await renderConfigFlyout({
196197
updatePanelState: updatePanelStateSpy,
197198
});
198199
expect(screen.getByTestId('lns-layerPanel-0')).toBeInTheDocument();
@@ -203,7 +204,7 @@ describe('LensEditConfigurationFlyout', () => {
203204
it('should call the updateByRefInput callback if cancel button is clicked and savedObjectId exists', async () => {
204205
const updateByRefInputSpy = jest.fn();
205206

206-
renderConfigFlyout({
207+
await renderConfigFlyout({
207208
closeFlyout: jest.fn(),
208209
updateByRefInput: updateByRefInputSpy,
209210
savedObjectId: 'id',
@@ -216,7 +217,7 @@ describe('LensEditConfigurationFlyout', () => {
216217
const updateByRefInputSpy = jest.fn();
217218
const saveByRefSpy = jest.fn();
218219

219-
renderConfigFlyout({
220+
await renderConfigFlyout({
220221
closeFlyout: jest.fn(),
221222
updateByRefInput: updateByRefInputSpy,
222223
savedObjectId: 'id',
@@ -230,7 +231,7 @@ describe('LensEditConfigurationFlyout', () => {
230231
it('should call the onApplyCb callback if apply button is clicked', async () => {
231232
const onApplyCbSpy = jest.fn();
232233

233-
renderConfigFlyout(
234+
await renderConfigFlyout(
234235
{
235236
closeFlyout: jest.fn(),
236237
onApplyCb: onApplyCbSpy,
@@ -254,14 +255,14 @@ describe('LensEditConfigurationFlyout', () => {
254255
});
255256

256257
it('should not display the editor if canEditTextBasedQuery prop is false', async () => {
257-
renderConfigFlyout({
258+
await renderConfigFlyout({
258259
canEditTextBasedQuery: false,
259260
});
260261
expect(screen.queryByTestId('TextBasedLangEditor')).toBeNull();
261262
});
262263

263264
it('should not display the editor if canEditTextBasedQuery prop is true but the query is not text based', async () => {
264-
renderConfigFlyout({
265+
await renderConfigFlyout({
265266
canEditTextBasedQuery: true,
266267
attributes: {
267268
...lensAttributes,
@@ -278,14 +279,14 @@ describe('LensEditConfigurationFlyout', () => {
278279
});
279280

280281
it('should not display the suggestions if hidesSuggestions prop is true', async () => {
281-
renderConfigFlyout({
282+
await renderConfigFlyout({
282283
hidesSuggestions: true,
283284
});
284285
expect(screen.queryByTestId('InlineEditingSuggestions')).toBeNull();
285286
});
286287

287288
it('should display the suggestions if canEditTextBasedQuery prop is true', async () => {
288-
renderConfigFlyout(
289+
await renderConfigFlyout(
289290
{
290291
canEditTextBasedQuery: true,
291292
},
@@ -298,7 +299,7 @@ describe('LensEditConfigurationFlyout', () => {
298299
});
299300

300301
it('should display the ES|QL results table if canEditTextBasedQuery prop is true', async () => {
301-
renderConfigFlyout({
302+
await renderConfigFlyout({
302303
canEditTextBasedQuery: true,
303304
});
304305
await waitFor(() => expect(screen.getByTestId('ESQLQueryResults')).toBeInTheDocument());
@@ -317,7 +318,7 @@ describe('LensEditConfigurationFlyout', () => {
317318
// todo: replace testDatasource with formBased or textBased as it's the only ones accepted
318319
// @ts-ignore
319320
newProps.attributes.state.datasourceStates.testDatasource = 'state';
320-
renderConfigFlyout(newProps);
321+
await renderConfigFlyout(newProps);
321322
expect(screen.getByRole('button', { name: /apply changes/i })).toBeDisabled();
322323
});
323324
it('save button should be disabled if expression cannot be generated', async () => {
@@ -337,7 +338,7 @@ describe('LensEditConfigurationFlyout', () => {
337338
},
338339
};
339340

340-
renderConfigFlyout(newProps);
341+
await renderConfigFlyout(newProps);
341342
expect(screen.getByRole('button', { name: /apply changes/i })).toBeDisabled();
342343
});
343344
});

0 commit comments

Comments
 (0)