Skip to content

Commit

Permalink
[8.x] [Lens] Corrects incorrect copy for line chart & fix flaky t…
Browse files Browse the repository at this point in the history
…est (elastic#192734) (elastic#193347)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Lens] Corrects incorrect copy for line chart & fix flaky test
(elastic#192734)](elastic#192734)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Marta
Bondyra","email":"4283304+mbondyra@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-09-18T18:39:25Z","message":"[Lens]
Corrects incorrect copy for line chart & fix flaky test (elastic#192734)\n\n##
Summary\r\nCorrects incorrect copy for line chart. \r\n\r\nRewrites some
of the tests to rtl.\r\nUnskips flaky or failing tests.\r\nFixes
https://github.com/elastic/kibana/issues/192476\r\nRemoves some errors
from the console that appear during unit
test\r\nrunning.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"e1db2969636658b48a8a53c58755e59995097d5d","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Visualizations","release_note:skip","Feature:Lens","v9.0.0","v8.16.0"],"title":"[Lens]
Corrects incorrect copy for line chart & fix flaky
test","number":192734,"url":"https://github.com/elastic/kibana/pull/192734","mergeCommit":{"message":"[Lens]
Corrects incorrect copy for line chart & fix flaky test (elastic#192734)\n\n##
Summary\r\nCorrects incorrect copy for line chart. \r\n\r\nRewrites some
of the tests to rtl.\r\nUnskips flaky or failing tests.\r\nFixes
https://github.com/elastic/kibana/issues/192476\r\nRemoves some errors
from the console that appear during unit
test\r\nrunning.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"e1db2969636658b48a8a53c58755e59995097d5d"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192734","number":192734,"mergeCommit":{"message":"[Lens]
Corrects incorrect copy for line chart & fix flaky test (elastic#192734)\n\n##
Summary\r\nCorrects incorrect copy for line chart. \r\n\r\nRewrites some
of the tests to rtl.\r\nUnskips flaky or failing tests.\r\nFixes
https://github.com/elastic/kibana/issues/192476\r\nRemoves some errors
from the console that appear during unit
test\r\nrunning.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"e1db2969636658b48a8a53c58755e59995097d5d"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Marta Bondyra <4283304+mbondyra@users.noreply.github.com>
  • Loading branch information
kibanamachine and mbondyra authored Sep 18, 2024
1 parent e9ad93d commit 3a62655
Show file tree
Hide file tree
Showing 14 changed files with 476 additions and 942 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ const datasourceMap = mockDatasourceMap();
const visualizationMap = mockVisualizationMap();

describe('LensEditConfigurationFlyout', () => {
function renderConfigFlyout(
async function renderConfigFlyout(
propsOverrides: Partial<EditConfigPanelProps> = {},
query?: Query | AggregateQuery
) {
return renderWithReduxStore(
const { container, ...rest } = renderWithReduxStore(
<LensEditConfigurationFlyout
attributes={lensAttributes}
updatePanelState={jest.fn()}
Expand All @@ -155,12 +155,13 @@ describe('LensEditConfigurationFlyout', () => {
},
}
);
await waitFor(() => container.querySelector('lnsEditFlyoutBody'));
return { container, ...rest };
}

it('should display the header and the link to editor if necessary props are given', async () => {
const navigateToLensEditorSpy = jest.fn();

renderConfigFlyout({
await renderConfigFlyout({
displayFlyoutHeader: true,
navigateToLensEditor: navigateToLensEditorSpy,
});
Expand All @@ -170,7 +171,7 @@ describe('LensEditConfigurationFlyout', () => {
});

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

renderConfigFlyout({
await renderConfigFlyout({
closeFlyout: closeFlyoutSpy,
});
expect(screen.getByTestId('lns-layerPanel-0')).toBeInTheDocument();
Expand All @@ -192,7 +193,7 @@ describe('LensEditConfigurationFlyout', () => {

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

renderConfigFlyout({
await renderConfigFlyout({
closeFlyout: jest.fn(),
updateByRefInput: updateByRefInputSpy,
savedObjectId: 'id',
Expand All @@ -216,7 +217,7 @@ describe('LensEditConfigurationFlyout', () => {
const updateByRefInputSpy = jest.fn();
const saveByRefSpy = jest.fn();

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

renderConfigFlyout(
await renderConfigFlyout(
{
closeFlyout: jest.fn(),
onApplyCb: onApplyCbSpy,
Expand All @@ -254,14 +255,14 @@ describe('LensEditConfigurationFlyout', () => {
});

it('should not display the editor if canEditTextBasedQuery prop is false', async () => {
renderConfigFlyout({
await renderConfigFlyout({
canEditTextBasedQuery: false,
});
expect(screen.queryByTestId('TextBasedLangEditor')).toBeNull();
});

it('should not display the editor if canEditTextBasedQuery prop is true but the query is not text based', async () => {
renderConfigFlyout({
await renderConfigFlyout({
canEditTextBasedQuery: true,
attributes: {
...lensAttributes,
Expand All @@ -278,14 +279,14 @@ describe('LensEditConfigurationFlyout', () => {
});

it('should not display the suggestions if hidesSuggestions prop is true', async () => {
renderConfigFlyout({
await renderConfigFlyout({
hidesSuggestions: true,
});
expect(screen.queryByTestId('InlineEditingSuggestions')).toBeNull();
});

it('should display the suggestions if canEditTextBasedQuery prop is true', async () => {
renderConfigFlyout(
await renderConfigFlyout(
{
canEditTextBasedQuery: true,
},
Expand All @@ -298,7 +299,7 @@ describe('LensEditConfigurationFlyout', () => {
});

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

renderConfigFlyout(newProps);
await renderConfigFlyout(newProps);
expect(screen.getByRole('button', { name: /apply changes/i })).toBeDisabled();
});
});
Loading

0 comments on commit 3a62655

Please sign in to comment.