Skip to content

Commit

Permalink
Update setFilterRatioOption function
Browse files Browse the repository at this point in the history
  • Loading branch information
DianaDerevyankina committed Jul 19, 2021
1 parent cf328d3 commit 0c14193
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ export const FilterRatioAgg = (props) => {
defaultMessage="Numerator"
/>
}
data-test-subj="numeratorRow"
>
<QueryBarWrapper
query={model.numerator}
onChange={handleNumeratorQueryChange}
indexPatterns={[indexPattern]}
data-test-subj="filterRatioNumeratorInput"
/>
</EuiFormRow>
</EuiFlexItem>
Expand All @@ -120,12 +120,12 @@ export const FilterRatioAgg = (props) => {
defaultMessage="Denominator"
/>
}
data-test-subj="denominatorRow"
>
<QueryBarWrapper
query={model.denominator}
onChange={handleDenominatorQueryChange}
indexPatterns={[indexPattern]}
data-test-subj="filterRatioDenominatorInput"
/>
</EuiFormRow>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ import { fetchIndexPattern, isStringTypeIndexPattern } from '../../../common/ind

type QueryBarWrapperProps = Pick<QueryStringInputProps, 'query' | 'onChange'> & {
indexPatterns: IndexPatternValue[];
'data-test-subj'?: string;
};

export function QueryBarWrapper({ query, onChange, indexPatterns }: QueryBarWrapperProps) {
export function QueryBarWrapper({
query,
onChange,
indexPatterns,
'data-test-subj': dataTestSubj,
}: QueryBarWrapperProps) {
const { indexPatterns: indexPatternsService } = getDataStart();
const [indexes, setIndexes] = useState<QueryStringInputProps['indexPatterns']>([]);

Expand Down Expand Up @@ -58,6 +64,7 @@ export function QueryBarWrapper({ query, onChange, indexPatterns }: QueryBarWrap
onChange={onChange}
indexPatterns={indexes}
{...coreStartContext}
dataTestSubj={dataTestSubj}
/>
);
}
4 changes: 2 additions & 2 deletions test/functional/apps/visualize/_tsvb_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
it('should display correct values for filter ratio aggregation with numerator and denominator', async () => {
const EXPECTED = 'OS Filter Ratio\nwin 8 2\nwin xp 0\nwin 7 3\nios 0\nosx 0';
await visualBuilder.selectAggType('Filter Ratio');
await visualBuilder.setFilterRatioOption('numerator', 'extension.raw : "css"');
await visualBuilder.setFilterRatioOption('denominator', 'bytes <= 3000');
await visualBuilder.setFilterRatioOption('Numerator', 'extension.raw : "css"');
await visualBuilder.setFilterRatioOption('Denominator', 'bytes <= 3000');
await visChart.waitForVisualizationRenderingStabilized();

const tableData = await visualBuilder.getViewTable();
Expand Down
6 changes: 2 additions & 4 deletions test/functional/page_objects/visual_builder_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,8 @@ export class VisualBuilderPageObject extends FtrService {
});
}

public async setFilterRatioOption(optionType: 'numerator' | 'denominator', query: string) {
const optionInput = await this.find.byCssSelector(
`[data-test-subj="${optionType}Row"] [data-test-subj="queryInput"]`
);
public async setFilterRatioOption(optionType: 'Numerator' | 'Denominator', query: string) {
const optionInput = await this.testSubjects.find(`filterRatio${optionType}Input`);
await optionInput.type(query);
}
}

0 comments on commit 0c14193

Please sign in to comment.