mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Dashboard][ES|QL] Unable to load page error on edit/add ES|QL panel (#188664)
## Summary Fixes https://github.com/elastic/kibana/issues/184544
This commit is contained in:
parent
76c6f550dc
commit
b7b3260db2
2 changed files with 20 additions and 15 deletions
|
@ -249,9 +249,9 @@ describe('dimension editor', () => {
|
|||
userEvent.type(customPrefixTextbox, prefix);
|
||||
};
|
||||
return {
|
||||
settingNone: screen.getByTitle(/none/i),
|
||||
settingAuto: screen.getByTitle(/auto/i),
|
||||
settingCustom: screen.getByTitle(/custom/i),
|
||||
settingNone: () => screen.getByTitle(/none/i),
|
||||
settingAuto: () => screen.getByTitle(/auto/i),
|
||||
settingCustom: () => screen.getByTitle(/custom/i),
|
||||
customPrefixTextbox,
|
||||
typePrefix,
|
||||
...rtlRender,
|
||||
|
@ -266,6 +266,11 @@ describe('dimension editor', () => {
|
|||
expect(screen.queryByTestId(SELECTORS.BREAKDOWN_EDITOR)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it(`doesn't break when layer data is missing`, () => {
|
||||
renderSecondaryMetricEditor({ frame: { activeData: { first: undefined } } });
|
||||
expect(screen.getByTestId(SELECTORS.SECONDARY_METRIC_EDITOR)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('metric prefix', () => {
|
||||
const NONE_PREFIX = '';
|
||||
const AUTO_PREFIX = undefined;
|
||||
|
@ -280,9 +285,9 @@ describe('dimension editor', () => {
|
|||
state: localState,
|
||||
});
|
||||
|
||||
expect(settingAuto).toHaveAttribute('aria-pressed', 'true');
|
||||
expect(settingNone).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(settingCustom).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(settingAuto()).toHaveAttribute('aria-pressed', 'true');
|
||||
expect(settingNone()).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(settingCustom()).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(customPrefixTextbox).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
@ -290,9 +295,9 @@ describe('dimension editor', () => {
|
|||
const { settingAuto, settingCustom, settingNone, customPrefixTextbox } =
|
||||
renderSecondaryMetricEditor({ state: { ...localState, secondaryPrefix: NONE_PREFIX } });
|
||||
|
||||
expect(settingNone).toHaveAttribute('aria-pressed', 'true');
|
||||
expect(settingAuto).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(settingCustom).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(settingNone()).toHaveAttribute('aria-pressed', 'true');
|
||||
expect(settingAuto()).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(settingCustom()).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(customPrefixTextbox).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
@ -301,9 +306,9 @@ describe('dimension editor', () => {
|
|||
const { settingAuto, settingCustom, settingNone, customPrefixTextbox } =
|
||||
renderSecondaryMetricEditor({ state: customPrefixState });
|
||||
|
||||
expect(settingAuto).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(settingNone).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(settingCustom).toHaveAttribute('aria-pressed', 'true');
|
||||
expect(settingAuto()).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(settingNone()).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(settingCustom()).toHaveAttribute('aria-pressed', 'true');
|
||||
expect(customPrefixTextbox).toHaveValue(customPrefixState.secondaryPrefix);
|
||||
});
|
||||
|
||||
|
@ -316,12 +321,12 @@ describe('dimension editor', () => {
|
|||
state: { ...localState, secondaryPrefix: customPrefix },
|
||||
});
|
||||
|
||||
userEvent.click(settingNone);
|
||||
userEvent.click(settingNone());
|
||||
expect(setState).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ secondaryPrefix: NONE_PREFIX })
|
||||
);
|
||||
|
||||
userEvent.click(settingAuto);
|
||||
userEvent.click(settingAuto());
|
||||
expect(setState).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ secondaryPrefix: AUTO_PREFIX })
|
||||
);
|
||||
|
|
|
@ -131,7 +131,7 @@ function MaximumEditor({ setState, state, idPrefix }: SubProps) {
|
|||
}
|
||||
|
||||
function SecondaryMetricEditor({ accessor, idPrefix, frame, layerId, setState, state }: SubProps) {
|
||||
const columnName = getColumnByAccessor(accessor, frame.activeData?.[layerId].columns)?.name;
|
||||
const columnName = getColumnByAccessor(accessor, frame.activeData?.[layerId]?.columns)?.name;
|
||||
const defaultPrefix = columnName || '';
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue