Skip to content

Commit

Permalink
feat(widget-builder): Add error messaging to the Visualize field (#83103
Browse files Browse the repository at this point in the history
)

Added the ability to show an error message for the visualize field when
validation fails. There are errors specifically for chart and non-chart
widgets so the correct error message will be displayed. This follows the
same error conventions that are in the current widget builder. The
following is an example of what the error message would look like:

<img width="553" alt="image"
src="https://github.com/user-attachments/assets/c9db10c3-99a3-48d9-8545-ae219b3903fb"
/>

Contributes to #81729

Note: There's a lot of random spacing changes so it's best to take a
look with hiding whitespace
  • Loading branch information
nikkikapadia authored Jan 8, 2025
1 parent ad19e5e commit 5e45866
Show file tree
Hide file tree
Showing 3 changed files with 385 additions and 291 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,68 @@ describe('Visualize', () => {
expect(screen.getAllByText('epm')).toHaveLength(1);
});

it('shows appropriate error messages for non-chart widget queries', async () => {
render(
<WidgetBuilderProvider>
<Visualize
error={{
queries: [
{
fields: ['this field has an error'],
aggregates: ['this aggregate has an error'],
},
],
}}
/>
</WidgetBuilderProvider>,
{
organization,
router: RouterFixture({
location: LocationFixture({
query: {
dataset: WidgetType.TRANSACTIONS,
displayType: DisplayType.BIG_NUMBER,
},
}),
}),
}
);

expect(await screen.findByText('this field has an error')).toBeInTheDocument();
expect(screen.queryByText('this aggregate has an error')).not.toBeInTheDocument();
});

it('shows appropriate error messages for chart type widget queries', async () => {
render(
<WidgetBuilderProvider>
<Visualize
error={{
queries: [
{
fields: ['this field has an error'],
aggregates: ['this aggregate has an error'],
},
],
}}
/>
</WidgetBuilderProvider>,
{
organization,
router: RouterFixture({
location: LocationFixture({
query: {
dataset: WidgetType.TRANSACTIONS,
displayType: DisplayType.LINE,
},
}),
}),
}
);

expect(await screen.findByText('this aggregate has an error')).toBeInTheDocument();
expect(screen.queryByText('this field has an error')).not.toBeInTheDocument();
});

describe('spans', () => {
beforeEach(() => {
jest.mocked(useSpanTags).mockImplementation((type?: 'string' | 'number') => {
Expand Down
Loading

0 comments on commit 5e45866

Please sign in to comment.