[Discover] Fix toggle table column for classic table (#128603) (#128871)

* Fx toggle table column
* Add functional test

Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
(cherry picked from commit 349b6cf5d2)

Co-authored-by: Dmitry Tomashevich <39378793+Dmitriynj@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2022-03-30 06:52:05 -04:00 committed by GitHub
parent 4f79676fa9
commit 9543131fc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 2 deletions

View file

@ -102,6 +102,7 @@ function CalloutTitle({ onCloseCallout }: { onCloseCallout: () => void }) {
aria-label={i18n.translate('discover.docExplorerCallout.closeButtonAriaLabel', {
defaultMessage: 'Close',
})}
data-test-subj="dscExplorerCalloutClose"
onClick={onCloseCallout}
type="button"
iconType="cross"

View file

@ -164,12 +164,13 @@ export const DocTableWrapper = forwardRef(
indexPattern={indexPattern}
row={current}
useNewFieldsApi={useNewFieldsApi}
onAddColumn={onAddColumn}
fieldsToShow={fieldsToShow}
onAddColumn={onAddColumn}
onRemoveColumn={onRemoveColumn}
/>
));
},
[columns, onFilter, indexPattern, useNewFieldsApi, onAddColumn, fieldsToShow]
[columns, onFilter, indexPattern, useNewFieldsApi, fieldsToShow, onAddColumn, onRemoveColumn]
);
return (

View file

@ -189,6 +189,30 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(defaultMessageElResubmit).to.be.ok();
});
});
it('should show allow toggling columns from the expanded document', async function () {
await PageObjects.discover.clickNewSearchButton();
await testSubjects.click('dscExplorerCalloutClose');
await retry.try(async function () {
await docTable.clickRowToggle({ isAnchorRow: false, rowIndex: rowToInspect - 1 });
// add columns
const fields = ['_id', '_index', 'agent'];
for (const field of fields) {
await testSubjects.click(`toggleColumnButton-${field}`);
}
const headerWithFields = await docTable.getHeaderFields();
expect(headerWithFields.join(' ')).to.contain(fields.join(' '));
// remove columns
for (const field of fields) {
await testSubjects.click(`toggleColumnButton-${field}`);
}
const headerWithoutFields = await docTable.getHeaderFields();
expect(headerWithoutFields.join(' ')).not.to.contain(fields.join(' '));
});
});
});
describe('add and remove columns', function () {