Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into add-metrics-t…
Browse files Browse the repository at this point in the history
…o-node-details

* 'master' of github.com:elastic/kibana:
  SO Tagging: fix flaky test and re-enable it (elastic#82930)
  [Metrics UI] Converting legend key to optional (elastic#83495)
  • Loading branch information
phillipb committed Nov 18, 2020
2 parents 48392c1 + b3eefb9 commit 913a83b
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 14 deletions.
14 changes: 14 additions & 0 deletions test/functional/services/listing_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ export function ListingTableProvider({ getService, getPageObjects }: FtrProvider
return visualizationNames;
}

public async waitUntilTableIsLoaded() {
return retry.try(async () => {
const isLoaded = await find.existsByDisplayedByCssSelector(
'[data-test-subj="itemsInMemTable"]:not(.euiBasicTable-loading)'
);

if (isLoaded) {
return true;
} else {
throw new Error('Waiting');
}
});
}

/**
* Navigates through all pages on Landing page and returns array of items names
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { PageContent } from '../../../../components/page';
import { useSnapshot } from '../hooks/use_snaphot';
import { useWaffleTimeContext } from '../hooks/use_waffle_time';
import { useWaffleFiltersContext } from '../hooks/use_waffle_filters';
import { useWaffleOptionsContext } from '../hooks/use_waffle_options';
import { DEFAULT_LEGEND, useWaffleOptionsContext } from '../hooks/use_waffle_options';
import { useSourceContext } from '../../../../containers/source';
import { InfraFormatterType } from '../../../../lib/lib';
import { euiStyled } from '../../../../../../observability/public';
Expand Down Expand Up @@ -62,10 +62,14 @@ export const Layout = () => {
false
);

const legendPalette = legend?.palette ?? DEFAULT_LEGEND.palette;
const legendSteps = legend?.steps ?? DEFAULT_LEGEND.steps;
const legendReverseColors = legend?.reverseColors ?? DEFAULT_LEGEND.reverseColors;

const options = {
formatter: InfraFormatterType.percent,
formatTemplate: '{{value}}',
legend: createLegend(legend.palette, legend.steps, legend.reverseColors),
legend: createLegend(legendPalette, legendSteps, legendReverseColors),
metric,
sort,
fields: source?.configuration?.fields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import {
import { GradientLegend } from './gradient_legend';
import { LegendControls } from './legend_controls';
import { StepLegend } from './steps_legend';
import { useWaffleOptionsContext, WaffleLegendOptions } from '../../hooks/use_waffle_options';
import {
DEFAULT_LEGEND,
useWaffleOptionsContext,
WaffleLegendOptions,
} from '../../hooks/use_waffle_options';
import { SteppedGradientLegend } from './stepped_gradient_legend';
interface Props {
legend: InfraWaffleMapLegend;
Expand Down Expand Up @@ -52,7 +56,7 @@ export const Legend: React.FC<Props> = ({ dataBounds, legend, bounds, formatter
return (
<LegendContainer>
<LegendControls
options={legendOptions}
options={legendOptions != null ? legendOptions : DEFAULT_LEGEND}
dataBounds={dataBounds}
bounds={bounds}
autoBounds={autoBounds}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ import {
import { useUrlState } from '../../../../utils/use_url_state';
import { InventoryItemType, ItemTypeRT } from '../../../../../common/inventory_models/types';

export const DEFAULT_LEGEND: WaffleLegendOptions = {
palette: 'cool',
steps: 10,
reverseColors: false,
};

export const DEFAULT_WAFFLE_OPTIONS_STATE: WaffleOptionsState = {
metric: { type: 'cpu' },
groupBy: [],
Expand All @@ -34,11 +40,7 @@ export const DEFAULT_WAFFLE_OPTIONS_STATE: WaffleOptionsState = {
accountId: '',
region: '',
customMetrics: [],
legend: {
palette: 'cool',
steps: 10,
reverseColors: false,
},
legend: DEFAULT_LEGEND,
source: 'default',
sort: { by: 'name', direction: 'desc' },
};
Expand Down Expand Up @@ -183,10 +185,9 @@ export const WaffleOptionsStateRT = rt.intersection([
accountId: rt.string,
region: rt.string,
customMetrics: rt.array(SnapshotCustomMetricInputRT),
legend: WaffleLegendOptionsRT,
sort: WaffleSortOptionRT,
}),
rt.partial({ source: rt.string }),
rt.partial({ source: rt.string, legend: WaffleLegendOptionsRT }),
]);

export type WaffleSortOption = rt.TypeOf<typeof WaffleSortOptionRT>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const listingTable = getService('listingTable');
const testSubjects = getService('testSubjects');
const find = getService('find');
const PageObjects = getPageObjects(['dashboard', 'tagManagement', 'common']);
const PageObjects = getPageObjects(['dashboard', 'tagManagement', 'common', 'header']);

/**
* Select tags in the searchbar's tag filter.
Expand All @@ -31,6 +31,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
// click elsewhere to close the filter dropdown
const searchFilter = await find.byCssSelector('main .euiFieldSearch');
await searchFilter.click();
// wait until the table refreshes
await listingTable.waitUntilTableIsLoaded();
};

describe('dashboard integration', () => {
Expand All @@ -47,6 +49,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
beforeEach(async () => {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.gotoDashboardLandingPage();
await listingTable.waitUntilTableIsLoaded();
});

it('allows to manually type tag filter query', async () => {
Expand Down Expand Up @@ -96,6 +99,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
});

await PageObjects.dashboard.gotoDashboardLandingPage();
await listingTable.waitUntilTableIsLoaded();

await selectFilterTags('tag-1');
const itemNames = await listingTable.getAllItemsNames();
expect(itemNames).to.contain('my-new-dashboard');
Expand Down Expand Up @@ -128,8 +133,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
expect(await tagModal.isOpened()).to.be(false);

await PageObjects.dashboard.clickSave();
await PageObjects.common.waitForSaveModalToClose();

await PageObjects.dashboard.gotoDashboardLandingPage();
await listingTable.waitUntilTableIsLoaded();

await selectFilterTags('my-new-tag');
const itemNames = await listingTable.getAllItemsNames();
expect(itemNames).to.contain('dashboard-with-new-tag');
Expand All @@ -140,6 +148,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
beforeEach(async () => {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.gotoDashboardLandingPage();
await listingTable.waitUntilTableIsLoaded();
});

it('allows to select tags for an existing dashboard', async () => {
Expand All @@ -152,6 +161,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
});

await PageObjects.dashboard.gotoDashboardLandingPage();
await listingTable.waitUntilTableIsLoaded();

await selectFilterTags('tag-3');
const itemNames = await listingTable.getAllItemsNames();
expect(itemNames).to.contain('dashboard 4 with real data (tag-1)');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const listingTable = getService('listingTable');
const testSubjects = getService('testSubjects');
const find = getService('find');
const PageObjects = getPageObjects(['visualize', 'tagManagement', 'visEditor']);
const PageObjects = getPageObjects(['visualize', 'tagManagement', 'visEditor', 'common']);

/**
* Select tags in the searchbar's tag filter.
Expand All @@ -31,6 +31,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
// click elsewhere to close the filter dropdown
const searchFilter = await find.byCssSelector('main .euiFieldSearch');
await searchFilter.click();
// wait until the table refreshes
await listingTable.waitUntilTableIsLoaded();
};

const selectSavedObjectTags = async (...tagNames: string[]) => {
Expand All @@ -56,6 +58,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
describe('listing', () => {
beforeEach(async () => {
await PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();
});

it('allows to manually type tag filter query', async () => {
Expand Down Expand Up @@ -83,7 +86,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
});

describe('creating', () => {
it.skip('allows to assign tags to the new visualization', async () => {
it('allows to assign tags to the new visualization', async () => {
await PageObjects.visualize.navigateToNewVisualization();

await PageObjects.visualize.clickMarkdownWidget();
Expand All @@ -95,7 +98,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await selectSavedObjectTags('tag-1');

await testSubjects.click('confirmSaveSavedObjectButton');
await PageObjects.common.waitForSaveModalToClose();

await PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();

await selectFilterTags('tag-1');
const itemNames = await listingTable.getAllItemsNames();
Expand Down Expand Up @@ -133,7 +139,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
expect(await tagModal.isOpened()).to.be(false);

await testSubjects.click('confirmSaveSavedObjectButton');
await PageObjects.common.waitForSaveModalToClose();

await PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();

await selectFilterTags('my-new-tag');
const itemNames = await listingTable.getAllItemsNames();
Expand All @@ -144,6 +153,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
describe('editing', () => {
beforeEach(async () => {
await PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();
});

it('allows to assign tags to an existing visualization', async () => {
Expand All @@ -153,7 +163,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await selectSavedObjectTags('tag-2');

await testSubjects.click('confirmSaveSavedObjectButton');
await PageObjects.common.waitForSaveModalToClose();

await PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();

await selectFilterTags('tag-2');
const itemNames = await listingTable.getAllItemsNames();
Expand Down

0 comments on commit 913a83b

Please sign in to comment.