Skip to content

Commit

Permalink
Add a couple of tests to check if the setting is displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
DianaDerevyankina committed Dec 9, 2021
1 parent b0f62d9 commit a9cb5ab
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/plugins/vis_types/pie/public/editor/components/pie.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,18 @@ describe('PalettePicker', function () {
expect(findTestSubject(component, 'visTypePieValueDecimals').length).toBe(1);
});
});

it('renders the donut size button group for the elastic charts implementation', async () => {
component = mountWithIntl(<PieOptions {...props} />);
await act(async () => {
expect(findTestSubject(component, 'visTypePieEmptySizeRatioButtonGroup').length).toBe(1);
});
});

it('not renders the donut size button group for the vislib implementation', async () => {
component = mountWithIntl(<PieOptions {...props} showElasticChartsOptions={false} />);
await act(async () => {
expect(findTestSubject(component, 'visTypePieEmptySizeRatioButtonGroup').length).toBe(0);
});
});
});
1 change: 1 addition & 0 deletions src/plugins/vis_types/pie/public/editor/components/pie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const PieOptions = (props: PieOptionsProps) => {
?.id ?? 'emptySizeRatioOption-medium'
}
onChange={handleEmptySizeRatioChange}
data-test-subj="visTypePieEmptySizeRatioButtonGroup"
/>
</EuiFormRow>
)}
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lens/public/pie_visualization/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export function PieToolbar(props: VisualizationToolbarProps<PieVisualizationStat
'emptySizeRatioOption-medium'
}
onChange={onEmptySizeRatioChange}
data-test-subj="lnsEmptySizeRatioButtonGroup"
/>
</EuiFormRow>
</ToolbarPopover>
Expand Down
24 changes: 24 additions & 0 deletions x-pack/test/functional/apps/lens/smokescreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const elasticChart = getService('elasticChart');
const filterBar = getService('filterBar');
const retry = getService('retry');

describe('lens smokescreen tests', () => {
it('should allow creation of lens xy chart', async () => {
Expand Down Expand Up @@ -766,5 +767,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

await filterBar.removeFilter('extension.raw');
});

it('should show visual options button group for a donut chart', async () => {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVisType('lens');
await PageObjects.lens.switchToVisualization('donut');

const hasVisualOptionsButton = await PageObjects.lens.hasVisualOptionsButton();
expect(hasVisualOptionsButton).to.be(true);

await PageObjects.lens.openVisualOptions();
await retry.try(async () => {
expect(await PageObjects.lens.hasEmptySizeRatioButtonGroup()).to.be(true);
});
});

it('should not show visual options button group for a pie chart', async () => {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVisType('lens');
await PageObjects.lens.switchToVisualization('pie');

const hasVisualOptionsButton = await PageObjects.lens.hasVisualOptionsButton();
expect(hasVisualOptionsButton).to.be(false);
});
});
}
7 changes: 7 additions & 0 deletions x-pack/test/functional/page_objects/lens_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,9 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
await colorPickerInput.type(color);
await PageObjects.common.sleep(1000); // give time for debounced components to rerender
},
hasVisualOptionsButton() {
return testSubjects.exists('lnsVisualOptionsButton');
},
async openVisualOptions() {
await retry.try(async () => {
await testSubjects.click('lnsVisualOptionsButton');
Expand Down Expand Up @@ -1223,5 +1226,9 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
const filterIn = await testSubjects.find(`legend-${value}-filterIn`);
await filterIn.click();
},

hasEmptySizeRatioButtonGroup() {
return testSubjects.exists('lnsEmptySizeRatioButtonGroup');
},
});
}

0 comments on commit a9cb5ab

Please sign in to comment.