mirror of
https://github.com/SigNoz/signoz.git
synced 2026-11-30 12:10:42 +00:00
Compare commits
13 Commits
perf/uplot
...
chore/dead
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
681603e365 | ||
|
|
29bd9896c4 | ||
|
|
39ada9604a | ||
|
|
018611fd49 | ||
|
|
c85af868f0 | ||
|
|
a1700275cb | ||
|
|
eeb040020f | ||
|
|
718cf02162 | ||
|
|
e95ff8e53c | ||
|
|
3185504015 | ||
|
|
fd1329bf60 | ||
|
|
c65a73001d | ||
|
|
a6be4d894c |
@@ -20,12 +20,16 @@ You are the Playwright Test Generator for the SigNoz frontend. You take a plan w
|
||||
await expect(routing.activeRouteTab(PATH.metricsSummary)).toBeVisible();
|
||||
});
|
||||
```
|
||||
- A driver is a function closing over the page that returns `Locator` getters and async actions. Actions wait inside themselves (e.g. `run()` pairs the click with `waitForResponse(/query_range/)`), so specs don't.
|
||||
- A driver is a function closing over the page that returns `Locator` getters and async actions. Actions wait inside themselves (e.g. `run()` pairs the click with `waitForResponse(/query_range/)`), so specs don't. A wait for "the request the action fired" skips aborted requests, which have no response: Run after a cancel re-sends the cancelled query and aborts it, and `query-builder/run` TC-34 read that one.
|
||||
- A page action that opens an explorer waits for the content pane's scrollbar viewport (`quick-filters-layout-content [data-overlayscrollbars-viewport]`) before anything types. The scrollbar starts on idle and re-parents the editors, so keys typed across it land at the start of the text. Typing into a CodeMirror editor retypes until the editor holds exactly the text, as `editorAt(...).type` and `querySearch.apply` do: `query-builder/aggregation` TC-17 sent `c()` for `count()`.
|
||||
- `driver(name, build, dispose?)` in `drivers/kit.ts` makes it a test-scoped fixture on `authedPage`; `dispose` deletes what it seeded. `seeded(name, open, close)` makes a worker-scoped seed.
|
||||
- Read [tests/e2e/tests/dashboards/editor/query.spec.ts](../../tests/e2e/tests/dashboards/editor/query.spec.ts) and [drivers/panel-editor.ts](../../tests/e2e/drivers/panel-editor.ts) for the canonical shape.
|
||||
- **Seeds are layers on the feature's `test`.** A spec destructures the seed it needs (`alertList`, `ownedRules`, `resolvedHistory` for alerts) instead of importing a fixtures module. A new seed goes in the feature's driver directory: `seeded()` for read-only data shared by a worker, a test-scoped layer for anything a test mutates.
|
||||
- **Test titles:** `TC-NN <short description>` — matches the planner's IDs.
|
||||
- **Self-contained state.** The bootstrap creates a fresh stack with **zero** dashboards / alerts / etc. Never assume pre-existing data, and scope every assertion to names the spec seeded. Pick the scope per the Seeding table in [tests/e2e/AGENTS.md](../../tests/e2e/AGENTS.md): test scope (a test-scoped layer, or `try / finally` through the driver) for mutations, worker scope (`seeded()`) for read-only data, suite `beforeAll` for a dataset only one file uses.
|
||||
- **A seed adds to org-wide settings, never replaces them.** Quick filters, org preferences and similar settings are shared by every spec on the stack, and `fullyParallel` runs those specs at once. Read the stored value and write a superset with only the missing entries, as `quickFilters.seed` does. A seed that replaced the logs filters made `query-builder/filter` TC-16 fail later on the same stack, and a restore in teardown races a parallel spec that seeded the same setting.
|
||||
- **Close a multiple combobox from its trigger, never with Escape.** A multi-select stays open after a pick, and Escape also closes the dialog or page around it; `onboarding/get-started` TC-09 landed on `/home`. `comboboxAt(...).pick` already does this.
|
||||
- **A context you open yourself drops its routes before closing.** Call `page.unrouteAll({ behavior: 'ignoreErrors' })` before `ctx.close()`, as `authedPage` does; a handler still inside `route.fetch` otherwise fails a test that already passed.
|
||||
- **Drive everything through the feature's driver** in `tests/e2e/drivers/`. A spec that reaches for `page.locator(...)` or `page.getByTestId(...)` is missing a driver method — add the method instead. `onAdminPage(browser, …)` from `drivers/kit.ts` is what suite hooks use, because `authedPage` is test-scoped and not visible to them.
|
||||
- **Seed through the kit when the UI flow is not under test.** Control-plane objects go through the feature driver (`dashboards.seed`, `alerts.seed.threshold`), which uses `apiDriver(page)` from `drivers/api.ts`; telemetry goes to the seeder. `page.request.*` does **not** carry the token, so never seed with it.
|
||||
- **Golden telemetry is pre-seeded.** `bootstrap/global.setup.ts` loads logs, traces and metrics over the last 6h (constants in `GOLDEN`, `drivers/dashboard-spec.ts`). Query within ≤ 6h and assert structure (series, rows, request payload), never exact counts.
|
||||
|
||||
@@ -50,6 +50,9 @@ Don't try to start the stack yourself — it can take ~4 minutes on a cold build
|
||||
- **Auth.** `tests/e2e/drivers/auth.ts` logs in once per worker and caches `storageState` (localStorage with `AUTH_TOKEN`). For API-driven seeding and cleanup use `apiDriver(page)` from `drivers/api.ts`, which attaches the header for you. Never re-implement login.
|
||||
- **Seeds.** Feature seeds are layers on the feature's `test`, e.g. `alertList`, `ownedRules` and `resolvedHistory` in `drivers/alerts/seeds.ts`. When a test fails on missing data, check which seed it destructures and whether it scopes to that seed's names.
|
||||
- **Timeouts.** Never add `test.slow()` to a driver: it triples the remaining budget per call and compounds in loops. Use `allowFor(floor)` from `drivers/kit.ts`. Budgets and their measurements are in `tests/e2e/docs/flake-notes.md`.
|
||||
- **A failure that shows only late in a long local run.** Run that spec's shard alone on a freshly seeded stack before fixing it, as CI does. A setting another spec changed and never restored, or golden telemetry aging past a query window, fails it only after the rest of the suite.
|
||||
- **`route.fetch: Target page, context or browser has been closed` after the test passed.** A route handler was still fetching when the context closed. Unroute with `page.unrouteAll({ behavior: 'ignoreErrors' })` before `ctx.close()` in the fixture that opened the context.
|
||||
- **Escape after a multi-select pick lands on another page.** Escape closed the dialog around the combobox too. Close it from its trigger (`comboboxAt(...).pick` does), never with another Escape.
|
||||
- **CI-only failures.** Reproduce with `STRESS=1 CI=1 pnpm test <path>` from `tests/e2e/` before calling it a product bug.
|
||||
- **Commits.** Driver fixes and spec fixes go in separate commits (see Commits in `tests/e2e/AGENTS.md`).
|
||||
- **Ant Design popovers** (sort menu, action menu) are click-toggle. The trigger element is often an inline `<svg>` with a `data-testid` — clicking it opens the popover; clicking it again closes. After selecting an option, the popover auto-closes. If a test interacts with the popover twice, wait for the menu items to be visible explicitly between toggles.
|
||||
|
||||
@@ -11,6 +11,7 @@ Examples and the harness API live in [`frontend/src/tests/README.md`](../../fron
|
||||
- **Import from the harness.** `render`, `screen`, `userEvent`, `waitFor` and the rest come from `tests/test-utils`, never from `@testing-library/react`. The harness mounts the router, React Query, Redux, app context and preferences. When it can't do what a test needs, extend `tests/test-utils` instead of importing around it.
|
||||
- **Find elements by test ID.** Query with `getByTestId`/`findByTestId` on the `data-testid` or `testId` the component exposes, and add one to the component when it has none. Fall back to role or text only for markup the app doesn't own. A test ID matches exactly one element and survives copy and markup changes; `getByRole` checks the computed style of every element it visits and is the slowest query. Always go through Testing Library (`screen`, `within`), never the DOM: no `querySelector`, `closest`, `container` or `document.body`. `signoz/no-dom-node-access` flags the DOM calls in test files; a test that checks DOM structure on purpose disables it on that line with a reason. Never call a `*ByRole` query inside `waitFor` or a loop: `waitFor` re-runs its callback every 50 ms. Wait with `findByTestId`, then query.
|
||||
- **Interact like a user.** `const user = userEvent.setup()`, then an awaited `user.click`, `hover`, `keyboard` or `type`. The harness turns off the pointer-events check: Base UI popups sit inside an element with an inline `pointer-events: none`, and the stylesheet that turns it back on for the popup never loads in jsdom, so the check would block every click on them. Never turn it back on. `fireEvent` only for events `userEvent` has no equivalent for: scroll, resize, setting `scrollTop`.
|
||||
- **Drop user-event's pause: `userEvent.setup(NO_DELAY_USER_EVENT)`** from `tests/test-utils`; spread it when the test needs other options. The default `delay: 0` waits a `setTimeout` after every key and click, so typing 40 characters waits 40 timer turns, each slower on a busy CI runner. With `delay: null` the actions run back to back. For a long value, click the field and `user.paste(text)` instead of typing it. Keep the default when the test checks what happens between two actions, such as a debounce per key or an update on a timer or `requestAnimationFrame` between steps: with `null` that code runs only after the whole action. Under `null` the Jest timeout can't fire mid-action, so judge a slow test by its `--verbose` time, not by whether it fails.
|
||||
- **Fake timers per test only**, for debounce or throttle, with `userEvent.setup({ advanceTimers: (ms) => jest.advanceTimersByTime(ms) })`. Never global.
|
||||
- **Network through MSW.** The global server runs for every test; override per test with `server.use(...)` from `mocks-server/server`. Large fixtures go in `mocks-server/__mockdata__`.
|
||||
- **Router through the harness.** Pass `initialRoute`/`routePath` to `render` and assert with `getCurrentLocation()` from `lib/router/navigation`. Never mock `react-router`, `react-router-dom` or `lib/history`; when a test can't render at a route, use the `lib/router` spies in `tests/router-mocks`.
|
||||
|
||||
@@ -123,10 +123,11 @@ Before writing the clicks, list what has to be on screen for the play's target t
|
||||
|
||||
Make those checks with the page's own code instead of restating a condition. Build the rows with the builder the handler uses and the view's own filter, and check a permission with the page's own check through `accessFor(...).allows(...)`, or the role against the constant the page gates on, such as `componentPermission.action`. Export the checks from the mocks module, next to the handlers, so a handler change moves them too. The alert rules page has `listedRules`, `hasRowMenu`, `showsNoRulesPage` and `listsSavedViews`; the dashboards list has `listedDashboards`, `canList`, `canCreate` and `canUpdate`.
|
||||
|
||||
Two habits cover the rest:
|
||||
Three habits cover the rest:
|
||||
|
||||
- Use `findAllBy*` and take the first whenever the text can appear twice, such as in a tooltip or a popover title.
|
||||
- Wrap `toBeVisible` in `waitFor` for anything that fades in. A tooltip or toast found the moment it mounts is not visible yet.
|
||||
- Wait for what a click depends on before clicking. A control can do something else until a request answers: in the cloud account setup, Cancel closes the drawer outright until the agent command exists, and asks to confirm only after. Clicking Cancel straight after Generate raced the account POST on CI; find `<provider>-agent-command` first.
|
||||
|
||||
## Rules
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
content="frame-src 'self' blob: data:"
|
||||
/>
|
||||
|
||||
<link rel="stylesheet" href="css/uPlot.min.css" />
|
||||
|
||||
<script>
|
||||
// i18n's language detector would pick the browser locale (e.g. `en-US`), which
|
||||
// /public/locales does not ship; pin it to the bundled language instead.
|
||||
|
||||
@@ -22,7 +22,6 @@ import i18n from '../src/ReactI18';
|
||||
// to its loader default and pulls Monaco from cdn.jsdelivr.net, which msw does
|
||||
// not report because the requests look like static assets.
|
||||
import '../src/lib/monaco/loader';
|
||||
import '../src/lib/uPlotStylesheet';
|
||||
|
||||
import '../src/styles.scss';
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@
|
||||
})(document, 'script');
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="css/uPlot.min.css" />
|
||||
<script type="module" src="./src/index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
1
frontend/public/css/uPlot.min.css
vendored
Normal file
1
frontend/public/css/uPlot.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.uplot, .uplot *, .uplot *::before, .uplot *::after {box-sizing: border-box;}.uplot {font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";line-height: 1.5;width: min-content;}.u-title {text-align: center;font-size: 18px;font-weight: bold;}.u-wrap {position: relative;user-select: none;}.u-over, .u-under {position: absolute;}.u-under {overflow: hidden;}.uplot canvas {display: block;position: relative;width: 100%;height: 100%;}.u-axis {position: absolute;}.u-legend {font-size: 14px;margin: auto;text-align: center;}.u-inline {display: block;}.u-inline * {display: inline-block;}.u-inline tr {margin-right: 16px;}.u-legend th {font-weight: 600;}.u-legend th > * {vertical-align: middle;display: inline-block;}.u-legend .u-marker {width: 1em;height: 1em;margin-right: 4px;background-clip: padding-box !important;}.u-inline.u-live th::after {content: ":";vertical-align: middle;}.u-inline:not(.u-live) .u-value {display: none;}.u-series > * {padding: 4px;}.u-series th {cursor: pointer;}.u-legend .u-off > * {opacity: 0.3;}.u-select {background: rgba(0,0,0,0.07);position: absolute;pointer-events: none;}.u-cursor-x, .u-cursor-y {position: absolute;left: 0;top: 0;pointer-events: none;will-change: transform;}.u-hz .u-cursor-x, .u-vt .u-cursor-y {height: 100%;border-right: 1px dashed #607D8B;}.u-hz .u-cursor-y, .u-vt .u-cursor-x {width: 100%;border-bottom: 1px dashed #607D8B;}.u-cursor-pt {position: absolute;top: 0;left: 0;border-radius: 50%;border: 0 solid;pointer-events: none;will-change: transform;/*this has to be !important since we set inline "background" shorthand */background-clip: padding-box !important;}.u-axis.u-off, .u-select.u-off, .u-cursor-x.u-off, .u-cursor-y.u-off, .u-cursor-pt.u-off {display: none;}
|
||||
@@ -28,4 +28,6 @@ until curl -sf http://127.0.0.1:6006/index.json >/dev/null 2>&1; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
pnpm exec test-storybook --ci --maxWorkers=2 --testTimeout 30000 "$@"
|
||||
# The first story of a heavy page compiles it on the cold dev server inside its
|
||||
# own test, which outlasts 30s on a loaded runner.
|
||||
pnpm exec test-storybook --ci --maxWorkers=2 --testTimeout 60000 "$@"
|
||||
|
||||
@@ -64,7 +64,7 @@ describe('InviteMembers - Submission', () => {
|
||||
|
||||
render(
|
||||
<InviteMembers
|
||||
initialRowCount={3}
|
||||
initialRowCount={2}
|
||||
renderFooter={({ submit }): JSX.Element => (
|
||||
<button data-testid="submit-btn" onClick={submit}>
|
||||
Submit
|
||||
@@ -77,13 +77,11 @@ describe('InviteMembers - Submission', () => {
|
||||
await pickRole(user, 0, 'role-viewer');
|
||||
await enterInviteEmail(user, 1, 'bob@signoz.io');
|
||||
await pickRole(user, 1, 'role-editor');
|
||||
await enterInviteEmail(user, 2, 'charlie@signoz.io');
|
||||
await pickRole(user, 2, 'role-admin');
|
||||
|
||||
await user.click(screen.getByTestId('submit-btn'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(calls).toHaveLength(3);
|
||||
expect(calls).toHaveLength(2);
|
||||
});
|
||||
|
||||
expect(calls[0]).toMatchObject({
|
||||
@@ -94,10 +92,6 @@ describe('InviteMembers - Submission', () => {
|
||||
email: 'bob@signoz.io',
|
||||
userRoles: [{ id: 'role-editor' }],
|
||||
});
|
||||
expect(calls[2]).toMatchObject({
|
||||
email: 'charlie@signoz.io',
|
||||
userRoles: [{ id: 'role-admin' }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ function LogDetailBody({
|
||||
target.closest('.cm-tooltip-autocomplete') ||
|
||||
target.closest('.drawer-popover') ||
|
||||
target.closest('.query-status-popover') ||
|
||||
target.closest('[data-radix-popper-content-wrapper]') ||
|
||||
target.closest('[data-base-ui-portal]')
|
||||
) {
|
||||
return;
|
||||
|
||||
@@ -155,14 +155,6 @@
|
||||
background: var(--l2-background);
|
||||
box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.1);
|
||||
|
||||
.context-btn {
|
||||
width: 50% !important;
|
||||
}
|
||||
.copy-link-btn {
|
||||
width: 50% !important;
|
||||
border-left: 1px solid var(--l1-border) !important;
|
||||
}
|
||||
|
||||
.ant-btn-default {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
|
||||
@@ -83,9 +83,3 @@ export const LogText = styled.div<LogTextProps>`
|
||||
: 'white-space: nowrap;'};
|
||||
};
|
||||
`;
|
||||
|
||||
export const SelectedLog = styled.div`
|
||||
display: flex;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
`;
|
||||
|
||||
@@ -27,14 +27,3 @@
|
||||
border-color: var(--l1-border) !important;
|
||||
}
|
||||
}
|
||||
|
||||
// In table/column view, keep action buttons visible at the viewport's right edge
|
||||
.log-line-action-buttons.table-view-log-actions {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 8px;
|
||||
left: auto;
|
||||
transform: translateY(-50%);
|
||||
margin: 0;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import { blue } from '@ant-design/colors';
|
||||
import { Color } from '@signozhq/design-tokens';
|
||||
import Space from 'periscope/components/Space/Space';
|
||||
import Col from 'periscope/components/Col/Col';
|
||||
import Row from 'periscope/components/Row/Row';
|
||||
import { FontSize } from 'container/OptionsMenu/types';
|
||||
import { Info } from '@signozhq/icons';
|
||||
@@ -73,12 +70,6 @@ export const InfoIconWrapper = styled(Info)`
|
||||
height: auto;
|
||||
`;
|
||||
|
||||
export const ExpandIconWrapper = styled(Col)`
|
||||
color: ${blue[6]};
|
||||
padding: 0.25rem 0.375rem;
|
||||
cursor: pointer;
|
||||
`;
|
||||
|
||||
export const RawLogContent = styled.div<RawLogContentProps>`
|
||||
margin-bottom: 0;
|
||||
font-family: 'SF Mono', monospace;
|
||||
@@ -112,11 +103,3 @@ export const RawLogContent = styled.div<RawLogContentProps>`
|
||||
cursor: ${({ $isActiveLog, $isReadOnly }): string =>
|
||||
$isActiveLog || $isReadOnly ? 'initial' : 'pointer'};
|
||||
`;
|
||||
|
||||
export const ActionButtonsWrapper = styled(Space)`
|
||||
position: absolute;
|
||||
transform: translate(-50%, -50%);
|
||||
top: 50%;
|
||||
right: 0;
|
||||
cursor: pointer;
|
||||
`;
|
||||
|
||||
@@ -187,177 +187,6 @@
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.add-new-column-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.add-new-column-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 8px;
|
||||
gap: 8px;
|
||||
|
||||
.back-icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
}
|
||||
|
||||
.add-new-column-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
padding-bottom: 16px;
|
||||
|
||||
min-height: 240px;
|
||||
max-height: 400px;
|
||||
|
||||
.loading-container {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.column-format-new-options {
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
|
||||
.column-name {
|
||||
padding: 4px 8px;
|
||||
border-radius: 1px;
|
||||
color: var(--l2-foreground);
|
||||
|
||||
&.selected {
|
||||
background-color: var(--l3-background);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
height: 1rem;
|
||||
width: 0.2rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.selected-item-content-container {
|
||||
.add-new-column-header {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.title {
|
||||
color: var(--l1-foreground);
|
||||
|
||||
margin-bottom: 12px;
|
||||
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.lucide {
|
||||
color: var(--l2-foreground);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.horizontal-line {
|
||||
height: 1px;
|
||||
background: var(--l3-background);
|
||||
}
|
||||
|
||||
.loading-container {
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.item-content {
|
||||
padding: 12px;
|
||||
|
||||
.column-format,
|
||||
.column-format-new-options {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
flex-direction: column;
|
||||
margin-top: 12px;
|
||||
|
||||
.column-name {
|
||||
color: var(--l2-foreground);
|
||||
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
cursor: pointer;
|
||||
|
||||
&.default-column {
|
||||
color: var(--l2-foreground);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&.no-columns-selected {
|
||||
color: var(--l3-foreground);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&.add-new-column-btn {
|
||||
color: var(--l2-foreground);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.name {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
display: none;
|
||||
flex: 0 0 16px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.delete-btn {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
overflow-x: hidden;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
height: 1rem;
|
||||
width: 0.2rem;
|
||||
}
|
||||
}
|
||||
|
||||
.column-format {
|
||||
max-height: 150px;
|
||||
overflow: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.column-format-new-options {
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.column-divider {
|
||||
margin: 12px 0;
|
||||
border-top: 2px solid var(--l1-border);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.active {
|
||||
.nested-menu-container {
|
||||
backdrop-filter: blur(18px);
|
||||
@@ -368,26 +197,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.selected-item-content-container {
|
||||
width: 110%;
|
||||
margin-left: -5%;
|
||||
|
||||
border-radius: 4px;
|
||||
border: 1px solid var(--l1-border);
|
||||
background: linear-gradient(
|
||||
139deg,
|
||||
color-mix(in srgb, var(--surface-2) 80%, transparent) 0%,
|
||||
color-mix(in srgb, var(--surface-2) 90%, transparent) 98.68%
|
||||
);
|
||||
|
||||
box-shadow: 4px 10px 16px 2px rgba(0, 0, 0, 0.2);
|
||||
backdrop-filter: blur(20px);
|
||||
|
||||
.column-format {
|
||||
margin-top: 0px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,3 @@
|
||||
width: max-content;
|
||||
}
|
||||
}
|
||||
|
||||
.select-label-with-coming-soon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
@@ -1,39 +1,8 @@
|
||||
import { Color } from '@signozhq/design-tokens';
|
||||
import { Tooltip } from 'antd';
|
||||
import type { DefaultOptionType } from 'antd/es/select';
|
||||
import { Info } from '@signozhq/icons';
|
||||
|
||||
import './MQCommon.styles.scss';
|
||||
|
||||
export function ComingSoon(): JSX.Element {
|
||||
return (
|
||||
<Tooltip
|
||||
title={
|
||||
<div>
|
||||
Join our Slack community for more details:{' '}
|
||||
<a
|
||||
href="https://signoz.io/slack"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
onClick={(e): void => e.stopPropagation()}
|
||||
>
|
||||
SigNoz Community
|
||||
</a>
|
||||
</div>
|
||||
}
|
||||
placement="top"
|
||||
overlayClassName="tooltip-overlay"
|
||||
>
|
||||
<div className="coming-soon">
|
||||
<div className="coming-soon__text">Coming Soon</div>
|
||||
<div className="coming-soon__icon">
|
||||
<Info size={10} color={Color.BG_SIENNA_400} />
|
||||
</div>
|
||||
</div>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
export function SelectMaxTagPlaceholder(
|
||||
omittedValues: Partial<DefaultOptionType>[],
|
||||
): JSX.Element {
|
||||
@@ -43,15 +12,3 @@ export function SelectMaxTagPlaceholder(
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
export function SelectLabelWithComingSoon({
|
||||
label,
|
||||
}: {
|
||||
label: string;
|
||||
}): JSX.Element {
|
||||
return (
|
||||
<div className="select-label-with-coming-soon">
|
||||
{label} <ComingSoon />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable sonarjs/cognitive-complexity */
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
autocompletion,
|
||||
closeCompletion,
|
||||
@@ -16,6 +16,7 @@ import CodeMirror, { EditorView, keymap } from '@uiw/react-codemirror';
|
||||
import { Button } from 'antd';
|
||||
import { Having } from 'api/v5/v5';
|
||||
import { useQueryBuilderV2Context } from 'components/QueryBuilderV2/QueryBuilderV2Context';
|
||||
import { useEditorDraft } from 'components/QueryBuilderV2/QueryV2/useEditorDraft';
|
||||
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||
import { ChevronUp } from '@signozhq/icons';
|
||||
import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
@@ -99,28 +100,20 @@ function HavingFilter({
|
||||
const { getAggregationOptions } = useQueryBuilderV2Context();
|
||||
const aggregationOptions = getAggregationOptions(queryData.queryName);
|
||||
const having = queryData?.having as Having;
|
||||
const [input, setInput] = useState(having?.expression || '');
|
||||
|
||||
useEffect(() => {
|
||||
setInput(having?.expression || '');
|
||||
}, [having?.expression]);
|
||||
const { editorRef, editorProps } = useEditorDraft(
|
||||
having?.expression || '',
|
||||
onChange,
|
||||
);
|
||||
|
||||
const [isFocused, setIsFocused] = useState(false);
|
||||
|
||||
const editorRef = useRef<EditorView | null>(null);
|
||||
|
||||
const [options, setOptions] = useState<{ label: string; value: string }[]>([]);
|
||||
|
||||
const handleChange = (value: string): void => {
|
||||
setInput(value);
|
||||
onChange(value);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (isFocused && editorRef.current && options.length > 0) {
|
||||
startCompletion(editorRef.current);
|
||||
}
|
||||
}, [isFocused, options]);
|
||||
}, [editorRef, isFocused, options]);
|
||||
|
||||
// Update options when aggregation options change
|
||||
useEffect(() => {
|
||||
@@ -329,8 +322,7 @@ function HavingFilter({
|
||||
<div className="having-filter-container">
|
||||
<div className="having-filter-select-container">
|
||||
<CodeMirror
|
||||
value={input}
|
||||
onChange={handleChange}
|
||||
{...editorProps}
|
||||
theme={isDarkMode ? copilot : githubLight}
|
||||
data-testid="having-editor"
|
||||
className="having-filter-select-editor"
|
||||
@@ -354,9 +346,6 @@ function HavingFilter({
|
||||
autocompletion: true,
|
||||
completionKeymap: true,
|
||||
}}
|
||||
onCreateEditor={(view: EditorView): void => {
|
||||
editorRef.current = view;
|
||||
}}
|
||||
onFocus={(): void => {
|
||||
setIsFocused(true);
|
||||
if (editorRef.current) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
/* eslint-disable sonarjs/cognitive-complexity */
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
autocompletion,
|
||||
closeCompletion,
|
||||
@@ -36,6 +36,7 @@ import {
|
||||
} from 'types/common/queryBuilder';
|
||||
|
||||
import { useQueryBuilderV2Context } from '../../QueryBuilderV2Context';
|
||||
import { useEditorDraft } from '../useEditorDraft';
|
||||
|
||||
import './QueryAggregation.styles.scss';
|
||||
|
||||
@@ -175,20 +176,17 @@ function QueryAggregationSelect({
|
||||
[],
|
||||
);
|
||||
|
||||
const [input, setInput] = useState(
|
||||
formatAggregations(queryData?.aggregations),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setInput(formatAggregations(queryData?.aggregations));
|
||||
}, [queryData?.aggregations, formatAggregations]);
|
||||
const {
|
||||
draft: input,
|
||||
editorRef,
|
||||
editorProps,
|
||||
} = useEditorDraft(formatAggregations(queryData?.aggregations), onChange);
|
||||
|
||||
const [cursorPos, setCursorPos] = useState(0);
|
||||
const [functionArgPairs, setFunctionArgPairs] = useState<
|
||||
{ func: string; arg: string }[]
|
||||
>([]);
|
||||
const [validationError, setValidationError] = useState<string | null>(null);
|
||||
const editorRef = useRef<EditorView | null>(null);
|
||||
const [isFocused, setIsFocused] = useState(false);
|
||||
|
||||
// Get valid function names (lowercase)
|
||||
@@ -204,7 +202,7 @@ function QueryAggregationSelect({
|
||||
startCompletion(editorRef.current);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
}, [editorRef]);
|
||||
|
||||
// Update cursor position on every editor update
|
||||
const handleUpdate = (update: { view: EditorView }): void => {
|
||||
@@ -601,11 +599,7 @@ function QueryAggregationSelect({
|
||||
return (
|
||||
<div className="query-aggregation-select-container">
|
||||
<CodeMirror
|
||||
value={input}
|
||||
onChange={(value): void => {
|
||||
setInput(value);
|
||||
onChange?.(value);
|
||||
}}
|
||||
{...editorProps}
|
||||
data-testid="query-aggregation-editor"
|
||||
className={`query-aggregation-select-editor ${
|
||||
validationError ? 'error' : ''
|
||||
@@ -637,9 +631,6 @@ function QueryAggregationSelect({
|
||||
completionKeymap: true,
|
||||
}}
|
||||
onUpdate={handleUpdate}
|
||||
onCreateEditor={(view: EditorView): void => {
|
||||
editorRef.current = view;
|
||||
}}
|
||||
onFocus={(): void => {
|
||||
setIsFocused(true);
|
||||
safeStartCompletion();
|
||||
|
||||
@@ -8,7 +8,14 @@ import { ENVIRONMENT } from 'constants/env';
|
||||
import { DEBOUNCE_DELAY } from 'constants/queryBuilderFilterConfig';
|
||||
import { initialQueriesMap } from 'constants/queryBuilder';
|
||||
import { rest, server } from 'mocks-server/server';
|
||||
import { act, render, screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import {
|
||||
act,
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
import type { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
import DistributionFieldSelect from '../DistributionFieldSelect';
|
||||
@@ -74,7 +81,7 @@ describe('DistributionFieldSelect', () => {
|
||||
});
|
||||
|
||||
it('picks a numeric field, keeping its context', async () => {
|
||||
const user = userEvent.setup({ delay: null, pointerEventsCheck: 0 });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onChange = jest.fn() as jest.MockedFunction<(field: string) => void>;
|
||||
render(
|
||||
<DistributionFieldSelect queryData={tracesQuery('')} onChange={onChange} />,
|
||||
@@ -97,7 +104,7 @@ describe('DistributionFieldSelect', () => {
|
||||
});
|
||||
|
||||
it('replaces the saved field with the newly picked one', async () => {
|
||||
const user = userEvent.setup({ delay: null, pointerEventsCheck: 0 });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onChange = jest.fn() as jest.MockedFunction<(field: string) => void>;
|
||||
render(
|
||||
<DistributionFieldSelect
|
||||
@@ -119,7 +126,7 @@ describe('DistributionFieldSelect', () => {
|
||||
});
|
||||
|
||||
it('only offers listed fields: typed text is a filter, not a value', async () => {
|
||||
const user = userEvent.setup({ delay: null, pointerEventsCheck: 0 });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
render(
|
||||
<DistributionFieldSelect queryData={tracesQuery('')} onChange={jest.fn()} />,
|
||||
);
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
import { EditorView } from '@uiw/react-codemirror';
|
||||
import { act, renderHook } from 'tests/test-utils';
|
||||
|
||||
import { useEditorDraft } from '../useEditorDraft';
|
||||
|
||||
function setup(
|
||||
external = '',
|
||||
onEdit?: (value: string) => void,
|
||||
): {
|
||||
result: { current: ReturnType<typeof useEditorDraft> };
|
||||
rerender: (props: { external: string }) => void;
|
||||
} {
|
||||
return renderHook(
|
||||
({ external: value }: { external: string }) => useEditorDraft(value, onEdit),
|
||||
{ initialProps: { external } },
|
||||
);
|
||||
}
|
||||
|
||||
// Reports document changes to `onChange` the way `@uiw/react-codemirror` does.
|
||||
function attachEditor(
|
||||
result: { current: ReturnType<typeof useEditorDraft> },
|
||||
doc: string,
|
||||
): EditorView {
|
||||
const view = new EditorView({
|
||||
doc,
|
||||
extensions: EditorView.updateListener.of((update) => {
|
||||
if (update.docChanged) {
|
||||
result.current.editorProps.onChange(update.state.doc.toString());
|
||||
}
|
||||
}),
|
||||
});
|
||||
act(() => result.current.editorProps.onCreateEditor(view));
|
||||
return view;
|
||||
}
|
||||
|
||||
function type(view: EditorView, text: string): void {
|
||||
act(() => {
|
||||
view.dispatch({ changes: { from: view.state.doc.length, insert: text } });
|
||||
});
|
||||
}
|
||||
|
||||
describe('useEditorDraft', () => {
|
||||
it('keeps newer typing when an older edit comes back', () => {
|
||||
const { result, rerender } = setup();
|
||||
|
||||
act(() => result.current.editorProps.onChange('count() > 1'));
|
||||
act(() => result.current.editorProps.onChange('count() > 10'));
|
||||
rerender({ external: 'count() > 1' });
|
||||
|
||||
expect(result.current.draft).toBe('count() > 10');
|
||||
});
|
||||
|
||||
it('takes a value set outside the editor', () => {
|
||||
const { result, rerender } = setup('count() > 1');
|
||||
|
||||
act(() => result.current.editorProps.onChange('count() > 10'));
|
||||
rerender({ external: 'count() > 10' });
|
||||
rerender({ external: 'count() < 5' });
|
||||
|
||||
expect(result.current.draft).toBe('count() < 5');
|
||||
});
|
||||
|
||||
it('takes an outside value equal to an edit older than the last echo', () => {
|
||||
const { result, rerender } = setup();
|
||||
|
||||
act(() => result.current.editorProps.onChange('a'));
|
||||
act(() => result.current.editorProps.onChange('ab'));
|
||||
rerender({ external: 'ab' });
|
||||
rerender({ external: 'a' });
|
||||
|
||||
expect(result.current.draft).toBe('a');
|
||||
});
|
||||
|
||||
it('keeps the editor value at the first text while the user types', () => {
|
||||
const { result, rerender } = setup('count()');
|
||||
|
||||
act(() => result.current.editorProps.onChange('count() >'));
|
||||
rerender({ external: 'count() >' });
|
||||
act(() => result.current.editorProps.onChange('count() > 1'));
|
||||
|
||||
expect(result.current.editorProps.value).toBe('count()');
|
||||
});
|
||||
|
||||
it('passes each edit on', () => {
|
||||
const onEdit = jest.fn();
|
||||
const { result } = setup('', onEdit);
|
||||
|
||||
act(() => result.current.editorProps.onChange('count()'));
|
||||
|
||||
expect(onEdit).toHaveBeenCalledWith('count()');
|
||||
});
|
||||
|
||||
it('writes an outside change into the editor without passing it on', () => {
|
||||
const onEdit = jest.fn();
|
||||
const { result, rerender } = setup('count() > 1', onEdit);
|
||||
const view = attachEditor(result, 'count() > 1');
|
||||
|
||||
rerender({ external: 'count() < 5' });
|
||||
|
||||
expect(view.state.doc.toString()).toBe('count() < 5');
|
||||
expect(view.state.selection.main.head).toBe('count() < 5'.length);
|
||||
expect(onEdit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('leaves the editor alone when an older edit comes back', () => {
|
||||
const { result, rerender } = setup();
|
||||
const view = attachEditor(result, '');
|
||||
|
||||
type(view, 'count_');
|
||||
type(view, 'di');
|
||||
rerender({ external: 'count_' });
|
||||
|
||||
expect(view.state.doc.toString()).toBe('count_di');
|
||||
});
|
||||
});
|
||||
109
frontend/src/components/QueryBuilderV2/QueryV2/useEditorDraft.ts
Normal file
109
frontend/src/components/QueryBuilderV2/QueryV2/useEditorDraft.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import type { MutableRefObject } from 'react';
|
||||
import type { EditorView } from '@uiw/react-codemirror';
|
||||
|
||||
// Bounds the history when no parent ever echoes the edits back.
|
||||
const MAX_PENDING_ECHOES = 200;
|
||||
|
||||
interface EditorDraft {
|
||||
/** The editor's current text. */
|
||||
draft: string;
|
||||
editorRef: MutableRefObject<EditorView | null>;
|
||||
/** Spread on `CodeMirror`. */
|
||||
editorProps: {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
onCreateEditor: (view: EditorView) => void;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Text of a query editor whose edits round-trip through query state. Each
|
||||
* edit comes back as `external` one or more renders later; writing an older
|
||||
* copy into the editor would drop the keys typed since and move the caret to
|
||||
* the start. Values the editor sent are ignored when they come back, and any
|
||||
* other `external` value replaces the text.
|
||||
*
|
||||
* The editor owns its text, so `editorProps.value` never changes after the
|
||||
* first render: `@uiw/react-codemirror` writes a changed `value` over the
|
||||
* document in a passive effect, which on a busy page runs after newer keys and
|
||||
* drops them. Outside changes are written through the view instead.
|
||||
*/
|
||||
export function useEditorDraft(
|
||||
external: string,
|
||||
onEdit?: (value: string) => void,
|
||||
): EditorDraft {
|
||||
const [draft, setDraft] = useState(external);
|
||||
const [initialValue] = useState(external);
|
||||
const editorRef = useRef<EditorView | null>(null);
|
||||
const pendingEchoes = useRef<string[]>([]);
|
||||
const writingOutsideChange = useRef(false);
|
||||
|
||||
const writeIntoEditor = useCallback((view: EditorView, text: string): void => {
|
||||
if (view.state.doc.toString() === text) {
|
||||
return;
|
||||
}
|
||||
writingOutsideChange.current = true;
|
||||
try {
|
||||
view.dispatch({
|
||||
changes: { from: 0, to: view.state.doc.length, insert: text },
|
||||
selection: { anchor: text.length },
|
||||
});
|
||||
} finally {
|
||||
writingOutsideChange.current = false;
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Echoes arrive in order, and a batched render can skip some, so a match
|
||||
// also drops every older entry: they can no longer come back.
|
||||
//
|
||||
// type "c", "co", "cou" pending [c, co, cou] draft "cou"
|
||||
// echo "c" pending [co, cou] ignored, draft stays "cou"
|
||||
// echo "cou" (skipped co) pending [] ignored
|
||||
// "count() > 5" from a saved view, never sent: applied
|
||||
//
|
||||
// Keeping the older entries would also swallow an outside change that
|
||||
// happens to equal one of them: after typing "a", "ab", a saved view with
|
||||
// "a" would be taken for an echo.
|
||||
useEffect(() => {
|
||||
const index = pendingEchoes.current.indexOf(external);
|
||||
if (index === -1) {
|
||||
pendingEchoes.current = [];
|
||||
setDraft(external);
|
||||
if (editorRef.current) {
|
||||
writeIntoEditor(editorRef.current, external);
|
||||
}
|
||||
return;
|
||||
}
|
||||
pendingEchoes.current = pendingEchoes.current.slice(index + 1);
|
||||
}, [external, writeIntoEditor]);
|
||||
|
||||
const onChange = useCallback(
|
||||
(value: string): void => {
|
||||
if (writingOutsideChange.current) {
|
||||
return;
|
||||
}
|
||||
pendingEchoes.current.push(value);
|
||||
if (pendingEchoes.current.length > MAX_PENDING_ECHOES) {
|
||||
pendingEchoes.current.shift();
|
||||
}
|
||||
setDraft(value);
|
||||
onEdit?.(value);
|
||||
},
|
||||
[onEdit],
|
||||
);
|
||||
|
||||
const onCreateEditor = useCallback(
|
||||
(view: EditorView): void => {
|
||||
editorRef.current = view;
|
||||
writeIntoEditor(view, draft);
|
||||
},
|
||||
[draft, writeIntoEditor],
|
||||
);
|
||||
|
||||
return {
|
||||
draft,
|
||||
editorRef,
|
||||
editorProps: { value: initialValue, onChange, onCreateEditor },
|
||||
};
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import {
|
||||
import { getHostsQuickFiltersConfig } from 'container/InfraMonitoringHostsV2/utils';
|
||||
import { INFRA_MONITORING_ATTR_KEYS } from 'container/InfraMonitoringK8sV2/constants';
|
||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
import { useAuthZ } from 'lib/authz/hooks/useAuthZ/useAuthZ';
|
||||
import { mockUseAuthZGrantAll } from 'lib/authz/utils/authz-test-utils';
|
||||
import {
|
||||
otherFiltersResponse,
|
||||
quickFiltersFieldValuesResponse,
|
||||
@@ -17,7 +19,14 @@ import {
|
||||
} from 'mocks-server/__mockdata__/customQuickFilters';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { render, screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import {
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
within,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
import { TelemetryFieldKey } from 'types/api/v5/queryRange';
|
||||
import { QueryBuilderContextType } from 'types/common/queryBuilder';
|
||||
|
||||
@@ -32,6 +41,7 @@ jest.mock('hooks/queryBuilder/useQueryBuilder', () => ({
|
||||
useQueryBuilder: jest.fn(),
|
||||
}));
|
||||
jest.mock('container/ApiMonitoring/queryParams');
|
||||
jest.mock('lib/authz/hooks/useAuthZ/useAuthZ');
|
||||
jest.mock(
|
||||
'components/OverlayScrollbar/OverlayScrollbar',
|
||||
() =>
|
||||
@@ -55,6 +65,7 @@ const mockSetApiMonitoringParams = jest.fn() as jest.MockedFunction<
|
||||
(newParams: Partial<ApiMonitoringParams>, replace?: boolean) => void
|
||||
>;
|
||||
const mockUseApiMonitoringParams = jest.mocked(useApiMonitoringParams);
|
||||
const mockedUseAuthZ = jest.mocked(useAuthZ);
|
||||
|
||||
const BASE_URL = ENVIRONMENT.baseURL;
|
||||
const quickFiltersListURL = `${BASE_URL}/api/v2/quick_filters/logs`;
|
||||
@@ -78,11 +89,12 @@ const QUERY_NAME = 'Test Query';
|
||||
|
||||
const savedFilters = quickFiltersListResponse.data
|
||||
.filters as TelemetryFieldKey[];
|
||||
const smallSavedFilters = savedFilters.slice(0, 2);
|
||||
const smallFiltersListResponse = {
|
||||
...quickFiltersListResponse,
|
||||
data: {
|
||||
...quickFiltersListResponse.data,
|
||||
filters: savedFilters.slice(0, 2),
|
||||
filters: smallSavedFilters,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -134,7 +146,7 @@ function renderSettings(): void {
|
||||
<QuickFiltersSettings
|
||||
savedFiltersSource={QuickfiltertypesSourceDTO.logs}
|
||||
setIsSettingsOpen={jest.fn()}
|
||||
customFilters={savedFilters}
|
||||
customFilters={smallSavedFilters}
|
||||
refetchCustomFilters={jest.fn()}
|
||||
/>,
|
||||
);
|
||||
@@ -180,12 +192,13 @@ beforeEach(() => {
|
||||
{ showIP: true } as ApiMonitoringParams,
|
||||
mockSetApiMonitoringParams,
|
||||
]);
|
||||
mockedUseAuthZ.mockImplementation(mockUseAuthZGrantAll);
|
||||
setupServer();
|
||||
});
|
||||
|
||||
describe('Quick Filters', () => {
|
||||
it('displays the correct query name in the header', () => {
|
||||
render(<TestQuickFilters />);
|
||||
render(<TestQuickFilters config={[]} />);
|
||||
expect(screen.getByText('Filters for')).toBeInTheDocument();
|
||||
expect(screen.getByText(QUERY_NAME)).toBeInTheDocument();
|
||||
});
|
||||
@@ -194,7 +207,7 @@ describe('Quick Filters', () => {
|
||||
const setLastUsedQuery = jest.fn() as jest.MockedFunction<
|
||||
QueryBuilderContextType['setLastUsedQuery']
|
||||
>;
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
|
||||
(useQueryBuilder as jest.Mock).mockReturnValue({
|
||||
currentQuery: {
|
||||
@@ -221,7 +234,7 @@ describe('Quick Filters', () => {
|
||||
panelType: 'graph', // not LIST view
|
||||
});
|
||||
|
||||
render(<TestQuickFilters />);
|
||||
render(<TestQuickFilters config={[]} />);
|
||||
|
||||
// The dropdown trigger should show the first query name
|
||||
const trigger = screen.getByTestId('quick-filters-query-select');
|
||||
@@ -243,12 +256,10 @@ describe('Quick Filters', () => {
|
||||
|
||||
// jsdom cannot deliver the pointer click Base UI expects on an option,
|
||||
// so pick Query B with the arrow keys and Enter
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.getByTestId('quick-filters-query-select-search'),
|
||||
).toHaveFocus(),
|
||||
await user.type(
|
||||
screen.getByTestId('quick-filters-query-select-search'),
|
||||
'{ArrowDown}{Enter}',
|
||||
);
|
||||
await user.keyboard('{ArrowDown}{Enter}');
|
||||
|
||||
// Verify setLastUsedQuery was called with index 1
|
||||
expect(setLastUsedQuery).toHaveBeenCalledWith(1);
|
||||
@@ -275,7 +286,7 @@ describe('Quick Filters', () => {
|
||||
panelType: 'list', // ListView
|
||||
});
|
||||
|
||||
render(<TestQuickFilters />);
|
||||
render(<TestQuickFilters config={[]} />);
|
||||
|
||||
// Should show static query name without dropdown
|
||||
expect(screen.getByText('Query A')).toBeInTheDocument();
|
||||
@@ -286,7 +297,7 @@ describe('Quick Filters', () => {
|
||||
});
|
||||
|
||||
it('should display static query name when only one query exists', () => {
|
||||
render(<TestQuickFilters />);
|
||||
render(<TestQuickFilters config={[]} />);
|
||||
|
||||
// Should show static query name
|
||||
expect(screen.getByText(QUERY_NAME)).toBeInTheDocument();
|
||||
@@ -298,7 +309,7 @@ describe('Quick Filters', () => {
|
||||
});
|
||||
|
||||
it('should add filter data to query when checkbox is clicked', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
|
||||
render(<TestQuickFilters />);
|
||||
|
||||
@@ -330,7 +341,7 @@ describe('Quick Filters', () => {
|
||||
});
|
||||
});
|
||||
it('toggles Show IP addresses and updates API Monitoring params', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
|
||||
render(
|
||||
<TestQuickFilters quickFilterSource={QuickFiltersSource.API_MONITORING} />,
|
||||
@@ -364,7 +375,7 @@ describe('Quick Filters with custom filters', () => {
|
||||
});
|
||||
|
||||
it('opens the settings with the saved filters added and the rest under other filters', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
server.use(
|
||||
rest.get(quickFiltersListURL, (_, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json(smallFiltersListResponse)),
|
||||
@@ -386,7 +397,7 @@ describe('Quick Filters with custom filters', () => {
|
||||
});
|
||||
|
||||
it('keeps same-name fields with different context as distinct entries', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
server.use(
|
||||
rest.get(quickFiltersSuggestionsURL, (_req, res, ctx) =>
|
||||
res(
|
||||
@@ -438,7 +449,7 @@ describe('Quick Filters with custom filters', () => {
|
||||
});
|
||||
|
||||
it('adds a filter from OTHER FILTERS to ADDED FILTERS when clicked', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
|
||||
renderSettings();
|
||||
|
||||
@@ -450,7 +461,7 @@ describe('Quick Filters with custom filters', () => {
|
||||
});
|
||||
|
||||
it('removes a filter from ADDED FILTERS and moves it to OTHER FILTERS', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
|
||||
renderSettings();
|
||||
const addedSection = screen.getByTestId(ADDED_FILTERS_TEST_ID);
|
||||
@@ -468,7 +479,7 @@ describe('Quick Filters with custom filters', () => {
|
||||
});
|
||||
|
||||
it('restores original filter state on Discard', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
|
||||
renderSettings();
|
||||
const addedSection = screen.getByTestId(ADDED_FILTERS_TEST_ID);
|
||||
@@ -491,7 +502,7 @@ describe('Quick Filters with custom filters', () => {
|
||||
});
|
||||
|
||||
it('saves the updated filters by calling PUT with correct payload', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
|
||||
renderSettings();
|
||||
|
||||
@@ -506,7 +517,7 @@ describe('Quick Filters with custom filters', () => {
|
||||
expect(requestBody.filters).not.toContainEqual(
|
||||
expect.objectContaining({ name: FILTER_OS_DESCRIPTION }),
|
||||
);
|
||||
expect(requestBody.filters).toHaveLength(10);
|
||||
expect(requestBody.filters).toHaveLength(smallSavedFilters.length - 1);
|
||||
});
|
||||
|
||||
it('should render duration slider for duration_nono filter', async () => {
|
||||
@@ -548,10 +559,10 @@ describe('Quick Filters with custom filters', () => {
|
||||
expect(maxDuration).toHaveProperty('placeholder', '100000000');
|
||||
|
||||
// Type values and advance debounce
|
||||
await user.clear(minDuration);
|
||||
await user.type(minDuration, '10000');
|
||||
await user.clear(maxDuration);
|
||||
await user.type(maxDuration, '20000');
|
||||
await user.click(minDuration);
|
||||
await user.paste('10000');
|
||||
await user.click(maxDuration);
|
||||
await user.paste('20000');
|
||||
jest.advanceTimersByTime(2000);
|
||||
|
||||
await waitFor(() => {
|
||||
@@ -650,7 +661,7 @@ describe('Quick Filters refetch behavior', () => {
|
||||
}),
|
||||
);
|
||||
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
render(
|
||||
<TestQuickFilters quickFilterSource={QuickFiltersSource.LOGS_EXPLORER} />,
|
||||
);
|
||||
@@ -692,7 +703,7 @@ describe('Quick Filters refetch behavior', () => {
|
||||
),
|
||||
);
|
||||
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
render(
|
||||
<TestQuickFilters quickFilterSource={QuickFiltersSource.LOGS_EXPLORER} />,
|
||||
);
|
||||
|
||||
@@ -1,51 +1,3 @@
|
||||
export const MOCK_USE_QUERIES_DATA = [
|
||||
{
|
||||
isLoading: false,
|
||||
isError: false,
|
||||
error: null,
|
||||
data: {
|
||||
statusCode: 200,
|
||||
payload: [
|
||||
{
|
||||
exceptionType: '*errors.errorString',
|
||||
exceptionMessage: 'redis timeout',
|
||||
exceptionCount: 2510,
|
||||
lastSeen: '2025-04-14T18:27:57.797616374Z',
|
||||
firstSeen: '2025-04-14T17:58:00.262775497Z',
|
||||
serviceName: 'redis-manual',
|
||||
groupID: '511b9c91a92b9c5166ecb77235f5743b',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
status: 'success',
|
||||
isLoading: false,
|
||||
isSuccess: true,
|
||||
isError: false,
|
||||
isIdle: false,
|
||||
data: {
|
||||
statusCode: 200,
|
||||
error: null,
|
||||
payload: 525,
|
||||
},
|
||||
dataUpdatedAt: 1744661020341,
|
||||
error: null,
|
||||
errorUpdatedAt: 0,
|
||||
failureCount: 0,
|
||||
errorUpdateCount: 0,
|
||||
isFetched: true,
|
||||
isFetchedAfterMount: true,
|
||||
isFetching: false,
|
||||
isRefetching: false,
|
||||
isLoadingError: false,
|
||||
isPlaceholderData: false,
|
||||
isPreviousData: false,
|
||||
isRefetchError: false,
|
||||
isStale: true,
|
||||
},
|
||||
];
|
||||
|
||||
export const INIT_URL_WITH_COMMON_QUERY =
|
||||
'/exceptions?compositeQuery=%257B%2522queryType%2522%253A%2522builder%2522%252C%2522builder%2522%253A%257B%2522queryData%2522%253A%255B%257B%2522dataSource%2522%253A%2522traces%2522%252C%2522queryName%2522%253A%2522A%2522%252C%2522aggregateOperator%2522%253A%2522noop%2522%252C%2522aggregateAttribute%2522%253A%257B%2522id%2522%253A%2522----resource--false%2522%252C%2522dataType%2522%253A%2522%2522%252C%2522key%2522%253A%2522%2522%252C%2522isColumn%2522%253Afalse%252C%2522type%2522%253A%2522resource%2522%252C%2522isJSON%2522%253Afalse%257D%252C%2522timeAggregation%2522%253A%2522rate%2522%252C%2522spaceAggregation%2522%253A%2522sum%2522%252C%2522functions%2522%253A%255B%255D%252C%2522filters%2522%253A%257B%2522items%2522%253A%255B%257B%2522id%2522%253A%2522db118ac7-9313-4adb-963f-f31b5b32c496%2522%252C%2522op%2522%253A%2522in%2522%252C%2522key%2522%253A%257B%2522key%2522%253A%2522deployment.environment%2522%252C%2522dataType%2522%253A%2522string%2522%252C%2522type%2522%253A%2522resource%2522%252C%2522isColumn%2522%253Afalse%252C%2522isJSON%2522%253Afalse%257D%252C%2522value%2522%253A%2522mq-kafka%2522%257D%255D%252C%2522op%2522%253A%2522AND%2522%257D%252C%2522expression%2522%253A%2522A%2522%252C%2522disabled%2522%253Afalse%252C%2522stepInterval%2522%253A60%252C%2522having%2522%253A%255B%255D%252C%2522limit%2522%253Anull%252C%2522orderBy%2522%253A%255B%255D%252C%2522groupBy%2522%253A%255B%255D%252C%2522legend%2522%253A%2522%2522%252C%2522reduceTo%2522%253A%2522avg%2522%257D%255D%252C%2522queryFormulas%2522%253A%255B%255D%257D%252C%2522promql%2522%253A%255B%257B%2522name%2522%253A%2522A%2522%252C%2522query%2522%253A%2522%2522%252C%2522legend%2522%253A%2522%2522%252C%2522disabled%2522%253Afalse%257D%255D%252C%2522clickhouse_sql%2522%253A%255B%257B%2522name%2522%253A%2522A%2522%252C%2522legend%2522%253A%2522%2522%252C%2522disabled%2522%253Afalse%252C%2522query%2522%253A%2522%2522%257D%255D%252C%2522id%2522%253A%2522dd576d04-0822-476d-b0c2-807a7af2e5e7%2522%257D';
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import uPlot from 'uplot';
|
||||
|
||||
import tooltipPlugin from './tooltipPlugin';
|
||||
|
||||
import 'uplot/dist/uPlot.min.css';
|
||||
import './AnomalyAlertEvaluationView.styles.scss';
|
||||
|
||||
const { Search } = Input;
|
||||
|
||||
@@ -50,16 +50,6 @@
|
||||
font-family: var(--code-base-500-font-family);
|
||||
}
|
||||
|
||||
.radio-button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding-top: var(--padding-1);
|
||||
border: 1px solid var(--l1-border);
|
||||
background: var(--l3-background);
|
||||
box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.round-metric-tag {
|
||||
display: inline-flex;
|
||||
padding: 2px 8px;
|
||||
@@ -783,80 +773,5 @@
|
||||
gap: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.no-dependent-services-message-container {
|
||||
height: 30vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.no-dependent-services-message-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
|
||||
width: fit-content;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.no-dependent-services-message {
|
||||
margin-top: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.end-point-details-zero-state-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
height: 100%;
|
||||
|
||||
.end-point-details-zero-state-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.end-point-details-zero-state-content-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: flex-start;
|
||||
gap: 12px;
|
||||
|
||||
.end-point-details-zero-state-text-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
|
||||
.title {
|
||||
color: var(--l1-foreground);
|
||||
}
|
||||
|
||||
.description {
|
||||
color: var(--l2-foreground);
|
||||
}
|
||||
}
|
||||
|
||||
.ant-select {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-select-item,
|
||||
.ant-select-item-option-content {
|
||||
flex: auto;
|
||||
white-space: normal;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,13 +69,6 @@ jest.mock('antd', () => {
|
||||
))}
|
||||
</div>
|
||||
)),
|
||||
Typography: {
|
||||
Text: jest
|
||||
.fn()
|
||||
.mockImplementation(({ children }) => (
|
||||
<div data-testid="typography-text">{children}</div>
|
||||
)),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,13 @@ import {
|
||||
GetMetricQueryRange,
|
||||
GetQueryResultsProps,
|
||||
} from 'lib/dashboard/getQueryResults';
|
||||
import { render, screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import {
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
import { MetricQueryRangeSuccessResponse } from 'types/api/metrics/getQueryRange';
|
||||
|
||||
import EndPointPicker from '../Explorer/Domains/DomainDetails/components/EndPointPicker';
|
||||
@@ -65,7 +71,7 @@ describe('EndPointPicker', () => {
|
||||
});
|
||||
|
||||
it('reports the picked endpoint', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onChange = jest.fn() as jest.MockedFunction<
|
||||
(endPointName: string) => void
|
||||
>;
|
||||
@@ -83,7 +89,7 @@ describe('EndPointPicker', () => {
|
||||
});
|
||||
|
||||
it('shows All endpoints when none is picked and clears through it', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onChange = jest.fn() as jest.MockedFunction<
|
||||
(endPointName: string) => void
|
||||
>;
|
||||
|
||||
@@ -130,13 +130,6 @@ jest.mock('antd', () => {
|
||||
{children}
|
||||
</div>
|
||||
)),
|
||||
Typography: {
|
||||
Text: jest
|
||||
.fn()
|
||||
.mockImplementation(({ children }) => (
|
||||
<div data-testid="typography-text">{children}</div>
|
||||
)),
|
||||
},
|
||||
Button: {
|
||||
...originalModule.Button,
|
||||
Group: jest.fn().mockImplementation(({ children, className }) => (
|
||||
|
||||
@@ -46,13 +46,6 @@ jest.mock('antd', () => {
|
||||
)}
|
||||
</div>
|
||||
)),
|
||||
Typography: {
|
||||
Text: jest.fn().mockImplementation(({ children, className }) => (
|
||||
<div data-testid="typography-text" className={className}>
|
||||
{children}
|
||||
</div>
|
||||
)),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
userEvent,
|
||||
waitFor,
|
||||
within,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
@@ -209,7 +210,7 @@ describe('TopErrors', () => {
|
||||
});
|
||||
|
||||
it('scopes the query to the endpoint picked in the picker', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const expressions: string[] = [];
|
||||
server.use(
|
||||
rest.post(V5_QUERY_RANGE_API_PATH, async (req) => {
|
||||
|
||||
@@ -1,16 +1,3 @@
|
||||
import { domainNameKey } from './constants';
|
||||
|
||||
export interface APIMonitoringResponseRow {
|
||||
data: {
|
||||
endpoints: number | string;
|
||||
error_rate: number | string;
|
||||
lastseen: number | string;
|
||||
[domainNameKey]: string;
|
||||
p99: number | string;
|
||||
rps: number | string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface APIMonitoringResponseColumn {
|
||||
name: string;
|
||||
signal: string;
|
||||
@@ -22,12 +9,6 @@ export interface APIMonitoringResponseColumn {
|
||||
columnType: string;
|
||||
}
|
||||
|
||||
export interface EndPointsResponseRow {
|
||||
data: {
|
||||
[key: string]: string | number | undefined;
|
||||
};
|
||||
}
|
||||
|
||||
export interface APIDomainsRowData {
|
||||
key: string;
|
||||
domainName: string;
|
||||
|
||||
@@ -1,32 +1,24 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { TableColumnType as ColumnType, Tooltip } from 'antd';
|
||||
import { Progress } from '@signozhq/ui/progress';
|
||||
import { Badge } from '@signozhq/ui/badge';
|
||||
import { combineInitialAndUserExpression } from 'components/QueryBuilderV2/QueryV2/QuerySearch/utils';
|
||||
import { formatValueForExpression } from 'components/QueryBuilderV2/utils';
|
||||
import {
|
||||
FiltersType,
|
||||
IQuickFiltersConfig,
|
||||
} from 'components/QuickFilters/types';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
import { GraphClickMetaData } from 'container/WidgetCard/hooks/useNavigateToExplorerPages';
|
||||
import { getWidgetQueryBuilder } from 'container/MetricsApplication/MetricsApplication.factory';
|
||||
import { convertNanoToMilliseconds } from 'container/MetricsExplorer/Summary/utils';
|
||||
import dayjs from 'dayjs';
|
||||
import { GetQueryResultsProps } from 'lib/dashboard/getQueryResults';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { ArrowUpDown, ChevronDown, ChevronRight, Info } from '@signozhq/icons';
|
||||
import { ArrowUpDown, Info } from '@signozhq/icons';
|
||||
import { getWidgetQuery } from 'pages/MessagingQueues/MQDetails/MetricPage/MetricPageUtil';
|
||||
import { Widgets } from 'types/api/widgets/widget';
|
||||
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
|
||||
import {
|
||||
BaseAutocompleteData,
|
||||
DataTypes,
|
||||
} from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import {
|
||||
IBuilderQuery,
|
||||
OrderByPayload,
|
||||
TagFilterItem,
|
||||
} from 'types/api/queryBuilder/queryBuilderData';
|
||||
import {
|
||||
@@ -41,11 +33,7 @@ import { v4 } from 'uuid';
|
||||
|
||||
import { domainNameKey } from './constants';
|
||||
import { SPAN_ATTRIBUTES } from './Explorer/Domains/DomainDetails/constants';
|
||||
import {
|
||||
APIDomainsRowData,
|
||||
APIMonitoringResponseColumn,
|
||||
EndPointsResponseRow,
|
||||
} from './types';
|
||||
import { APIDomainsRowData, APIMonitoringResponseColumn } from './types';
|
||||
|
||||
function metricProgressColor(
|
||||
percent: number,
|
||||
@@ -91,40 +79,6 @@ export const getDomainScopeExpression = (
|
||||
.filter(Boolean)
|
||||
.join(' AND ');
|
||||
|
||||
export const ApiMonitoringQuickFiltersConfig: IQuickFiltersConfig[] = [
|
||||
{
|
||||
type: FiltersType.CHECKBOX,
|
||||
title: 'Environment',
|
||||
|
||||
attributeKey: {
|
||||
key: 'deployment.environment',
|
||||
dataType: DataTypes.String,
|
||||
type: 'resource',
|
||||
},
|
||||
defaultOpen: true,
|
||||
},
|
||||
{
|
||||
type: FiltersType.CHECKBOX,
|
||||
title: 'Service Name',
|
||||
attributeKey: {
|
||||
key: 'service.name',
|
||||
dataType: DataTypes.String,
|
||||
type: 'resource',
|
||||
},
|
||||
defaultOpen: true,
|
||||
},
|
||||
{
|
||||
type: FiltersType.CHECKBOX,
|
||||
title: 'RPC Method',
|
||||
attributeKey: {
|
||||
key: 'rpc.method',
|
||||
dataType: DataTypes.String,
|
||||
type: 'tag',
|
||||
},
|
||||
defaultOpen: true,
|
||||
},
|
||||
];
|
||||
|
||||
export const getLastUsedRelativeTime = (lastRefresh: number): string => {
|
||||
const currentTime = dayjs();
|
||||
|
||||
@@ -571,258 +525,6 @@ const defaultGroupBy = [
|
||||
// },
|
||||
];
|
||||
|
||||
export const getEndPointsQueryPayload = (
|
||||
groupBy: BaseAutocompleteData[],
|
||||
domainName: string,
|
||||
start: number,
|
||||
end: number,
|
||||
): GetQueryResultsProps[] => {
|
||||
const isGroupedByAttribute = groupBy.length > 0;
|
||||
return [
|
||||
{
|
||||
selectedTime: 'GLOBAL_TIME',
|
||||
graphType: PANEL_TYPES.TABLE,
|
||||
query: {
|
||||
builder: {
|
||||
queryData: [
|
||||
{
|
||||
aggregateAttribute: {
|
||||
dataType: DataTypes.String,
|
||||
key: 'span_id',
|
||||
type: '',
|
||||
},
|
||||
aggregateOperator: 'count',
|
||||
dataSource: DataSource.TRACES,
|
||||
disabled: false,
|
||||
expression: 'A',
|
||||
filters: {
|
||||
items: [
|
||||
{
|
||||
id: 'ec316e57',
|
||||
key: {
|
||||
dataType: DataTypes.String,
|
||||
key: SPAN_ATTRIBUTES.SERVER_NAME,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: domainName,
|
||||
},
|
||||
{
|
||||
id: '212678b9',
|
||||
key: {
|
||||
key: 'kind_string',
|
||||
dataType: DataTypes.String,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: 'Client',
|
||||
},
|
||||
],
|
||||
op: 'AND',
|
||||
},
|
||||
functions: [],
|
||||
groupBy: isGroupedByAttribute ? groupBy : defaultGroupBy,
|
||||
having: [],
|
||||
legend: '',
|
||||
limit: 1000,
|
||||
orderBy: [],
|
||||
queryName: 'A',
|
||||
reduceTo: ReduceOperators.AVG,
|
||||
spaceAggregation: 'sum',
|
||||
stepInterval: 60,
|
||||
timeAggregation: 'count',
|
||||
},
|
||||
{
|
||||
aggregateAttribute: {
|
||||
dataType: DataTypes.Float64,
|
||||
key: 'duration_nano',
|
||||
type: '',
|
||||
},
|
||||
aggregateOperator: 'p99',
|
||||
dataSource: DataSource.TRACES,
|
||||
disabled: false,
|
||||
expression: 'B',
|
||||
filters: {
|
||||
items: [
|
||||
{
|
||||
id: '46d57857',
|
||||
key: {
|
||||
dataType: DataTypes.String,
|
||||
key: SPAN_ATTRIBUTES.SERVER_NAME,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: domainName,
|
||||
},
|
||||
{
|
||||
id: '212678b9',
|
||||
key: {
|
||||
key: 'kind_string',
|
||||
dataType: DataTypes.String,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: 'Client',
|
||||
},
|
||||
],
|
||||
op: 'AND',
|
||||
},
|
||||
functions: [],
|
||||
groupBy: isGroupedByAttribute ? groupBy : defaultGroupBy,
|
||||
having: [],
|
||||
legend: '',
|
||||
limit: 1000,
|
||||
orderBy: [],
|
||||
queryName: 'B',
|
||||
reduceTo: ReduceOperators.AVG,
|
||||
spaceAggregation: 'sum',
|
||||
stepInterval: 60,
|
||||
timeAggregation: 'p99',
|
||||
},
|
||||
{
|
||||
aggregateAttribute: {
|
||||
dataType: DataTypes.String,
|
||||
id: 'timestamp------false',
|
||||
key: 'timestamp',
|
||||
type: '',
|
||||
},
|
||||
aggregateOperator: 'max',
|
||||
dataSource: DataSource.TRACES,
|
||||
disabled: false,
|
||||
expression: 'C',
|
||||
filters: {
|
||||
items: [
|
||||
{
|
||||
id: '4a237616',
|
||||
key: {
|
||||
dataType: DataTypes.String,
|
||||
key: SPAN_ATTRIBUTES.SERVER_NAME,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: domainName,
|
||||
},
|
||||
{
|
||||
id: '212678b9',
|
||||
key: {
|
||||
key: 'kind_string',
|
||||
dataType: DataTypes.String,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: 'Client',
|
||||
},
|
||||
],
|
||||
op: 'AND',
|
||||
},
|
||||
functions: [],
|
||||
groupBy: isGroupedByAttribute ? groupBy : defaultGroupBy,
|
||||
having: [],
|
||||
legend: '',
|
||||
limit: 1000,
|
||||
orderBy: [],
|
||||
queryName: 'C',
|
||||
reduceTo: ReduceOperators.AVG,
|
||||
spaceAggregation: 'sum',
|
||||
stepInterval: 60,
|
||||
timeAggregation: 'max',
|
||||
},
|
||||
{
|
||||
aggregateAttribute: {
|
||||
dataType: DataTypes.String,
|
||||
key: 'span_id',
|
||||
type: '',
|
||||
},
|
||||
aggregateOperator: 'count',
|
||||
dataSource: DataSource.TRACES,
|
||||
disabled: true,
|
||||
expression: 'D',
|
||||
filters: {
|
||||
items: [
|
||||
{
|
||||
id: 'f162de1e',
|
||||
key: {
|
||||
dataType: DataTypes.String,
|
||||
key: SPAN_ATTRIBUTES.SERVER_NAME,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: domainName,
|
||||
},
|
||||
{
|
||||
id: '3df0ac1d',
|
||||
key: {
|
||||
dataType: DataTypes.bool,
|
||||
key: 'has_error',
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: 'true',
|
||||
},
|
||||
{
|
||||
id: '212678b9',
|
||||
key: {
|
||||
key: 'kind_string',
|
||||
dataType: DataTypes.String,
|
||||
type: '',
|
||||
},
|
||||
op: '=',
|
||||
value: 'Client',
|
||||
},
|
||||
],
|
||||
op: 'AND',
|
||||
},
|
||||
functions: [],
|
||||
groupBy: isGroupedByAttribute ? groupBy : defaultGroupBy,
|
||||
having: [],
|
||||
legend: '',
|
||||
limit: 1000,
|
||||
orderBy: [],
|
||||
queryName: 'D',
|
||||
reduceTo: ReduceOperators.AVG,
|
||||
spaceAggregation: 'sum',
|
||||
stepInterval: 60,
|
||||
timeAggregation: 'count',
|
||||
},
|
||||
],
|
||||
queryFormulas: [
|
||||
{
|
||||
queryName: 'F1',
|
||||
expression: '(D/A)*100',
|
||||
disabled: false,
|
||||
legend: 'error percentage',
|
||||
},
|
||||
],
|
||||
queryTraceOperator: [],
|
||||
},
|
||||
clickhouse_sql: [
|
||||
{
|
||||
disabled: false,
|
||||
legend: '',
|
||||
name: 'A',
|
||||
query: '',
|
||||
},
|
||||
],
|
||||
id: '315b15fa-ff0c-442f-89f8-2bf4fb1af2f2',
|
||||
promql: [
|
||||
{
|
||||
disabled: false,
|
||||
legend: '',
|
||||
name: 'A',
|
||||
query: '',
|
||||
},
|
||||
],
|
||||
queryType: EQueryType.QUERY_BUILDER,
|
||||
},
|
||||
variables: {},
|
||||
formatForWeb: true,
|
||||
start,
|
||||
end,
|
||||
step: 60,
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
function buildFilterExpression(
|
||||
domainName: string,
|
||||
filterExpression: string,
|
||||
@@ -907,16 +609,6 @@ export const getTopErrorsQueryPayload = (
|
||||
};
|
||||
};
|
||||
|
||||
export interface EndPointsTableRowData {
|
||||
key: string;
|
||||
endpointName: string;
|
||||
callCount: number | string;
|
||||
latency: number | string;
|
||||
errorRate: number | string;
|
||||
lastUsed: string | number;
|
||||
groupedByMeta?: Record<string, string | number>;
|
||||
}
|
||||
|
||||
export const extractPortAndEndpoint = (
|
||||
url: string,
|
||||
): { port: string; endpoint: string } => {
|
||||
@@ -937,258 +629,6 @@ export const extractPortAndEndpoint = (
|
||||
}
|
||||
};
|
||||
|
||||
export const getEndPointsColumnsConfig = (
|
||||
isGroupedByAttribute: boolean,
|
||||
expandedRowKeys: React.Key[],
|
||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||
): ColumnType<EndPointsTableRowData>[] => [
|
||||
{
|
||||
title: (
|
||||
<div className="endpoint-name-header">
|
||||
{isGroupedByAttribute ? 'Endpoint group' : 'Endpoint'}
|
||||
</div>
|
||||
),
|
||||
dataIndex: 'endpointName',
|
||||
key: 'endpointName',
|
||||
width: 180,
|
||||
ellipsis: true,
|
||||
sorter: false,
|
||||
className: 'column',
|
||||
render: (text: string, record: EndPointsTableRowData): React.ReactNode => {
|
||||
const endPointName = isGroupedByAttribute
|
||||
? text
|
||||
: extractPortAndEndpoint(record.endpointName).endpoint;
|
||||
return (
|
||||
<div className="endpoint-name-value">
|
||||
{((): React.ReactNode => {
|
||||
if (!isGroupedByAttribute) {
|
||||
return null;
|
||||
}
|
||||
return expandedRowKeys.includes(record.key) ? (
|
||||
<ChevronDown size={14} />
|
||||
) : (
|
||||
<ChevronRight size={14} />
|
||||
);
|
||||
})()}
|
||||
{isGroupedByAttribute
|
||||
? text.split(',').map((value) => (
|
||||
<Badge
|
||||
textTransform="none"
|
||||
variant="solid"
|
||||
key={value}
|
||||
color="secondary"
|
||||
>
|
||||
{value === '' ? '<no-value>' : value}
|
||||
</Badge>
|
||||
))
|
||||
: endPointName}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: <div className="column-header">Port</div>,
|
||||
dataIndex: 'port',
|
||||
key: 'port',
|
||||
width: 180,
|
||||
ellipsis: true,
|
||||
sorter: false,
|
||||
align: 'right',
|
||||
className: `column`,
|
||||
},
|
||||
{
|
||||
title: (
|
||||
<div className="column-header">
|
||||
Num of calls <ArrowUpDown size={14} />
|
||||
</div>
|
||||
),
|
||||
dataIndex: 'callCount',
|
||||
key: 'callCount',
|
||||
width: 180,
|
||||
ellipsis: true,
|
||||
align: 'right',
|
||||
className: `column`,
|
||||
},
|
||||
{
|
||||
title: (
|
||||
<div>
|
||||
Error <span className="round-metric-tag">%</span>
|
||||
</div>
|
||||
),
|
||||
dataIndex: 'errorRate',
|
||||
key: 'errorRate',
|
||||
width: 120,
|
||||
sorter: true,
|
||||
align: 'right',
|
||||
className: `column`,
|
||||
render: (errorRate: number | string): React.ReactNode => (
|
||||
<div className="progress-bar error-rate">
|
||||
<Progress
|
||||
percent={Number(
|
||||
(
|
||||
(errorRate === 'n/a' || errorRate === '-' ? 0 : errorRate) as number
|
||||
).toFixed(1),
|
||||
)}
|
||||
showInfo
|
||||
color={metricProgressColor(
|
||||
Number(
|
||||
(
|
||||
(errorRate === 'n/a' || errorRate === '-' ? 0 : errorRate) as number
|
||||
).toFixed(1),
|
||||
),
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: (
|
||||
<div>
|
||||
Latency <span className="round-metric-tag">ms</span>
|
||||
</div>
|
||||
),
|
||||
dataIndex: 'latency',
|
||||
key: 'latency',
|
||||
width: 120,
|
||||
sorter: true,
|
||||
align: 'right',
|
||||
className: `column`,
|
||||
},
|
||||
{
|
||||
title: <div>Last used</div>,
|
||||
dataIndex: 'lastUsed',
|
||||
key: 'lastUsed',
|
||||
width: 120,
|
||||
sorter: true,
|
||||
align: 'right',
|
||||
className: `column`,
|
||||
// eslint-disable-next-line sonarjs/no-identical-functions
|
||||
render: (lastUsed: string): string =>
|
||||
lastUsed === 'n/a' || lastUsed === '-'
|
||||
? '-'
|
||||
: getLastUsedRelativeTime(new Date(lastUsed).getTime()),
|
||||
},
|
||||
];
|
||||
|
||||
export const formatEndPointsDataForTable = (
|
||||
data: EndPointsResponseRow[] | undefined,
|
||||
groupBy: BaseAutocompleteData[],
|
||||
orderBy?: OrderByPayload | null,
|
||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||
): EndPointsTableRowData[] => {
|
||||
if (!data) {
|
||||
return [];
|
||||
}
|
||||
const isGroupedByAttribute = groupBy.length > 0;
|
||||
|
||||
let formattedData: EndPointsTableRowData[] = [];
|
||||
|
||||
if (!isGroupedByAttribute) {
|
||||
formattedData = data?.map((endpoint) => {
|
||||
const { port } = extractPortAndEndpoint(
|
||||
(endpoint.data[SPAN_ATTRIBUTES.HTTP_URL] as string) || '',
|
||||
);
|
||||
return {
|
||||
key: v4(),
|
||||
endpointName: (endpoint.data[SPAN_ATTRIBUTES.HTTP_URL] as string) || '-',
|
||||
port,
|
||||
callCount:
|
||||
endpoint.data.A === 'n/a' || endpoint.data.A === undefined
|
||||
? '-'
|
||||
: endpoint.data.A,
|
||||
latency:
|
||||
endpoint.data.B === 'n/a' || endpoint.data.B === undefined
|
||||
? '-'
|
||||
: Math.round(Number(endpoint.data.B) / 1000000), // Convert from nanoseconds to milliseconds
|
||||
lastUsed:
|
||||
endpoint.data.C === 'n/a' || endpoint.data.C === undefined
|
||||
? '-'
|
||||
: new Date(Math.floor(Number(endpoint.data.C) / 1000000)).toISOString(), // Convert from nanoseconds to milliseconds
|
||||
|
||||
errorRate:
|
||||
endpoint.data.F1 === undefined || endpoint.data.F1 === 'n/a'
|
||||
? 0
|
||||
: Number(endpoint.data.F1),
|
||||
};
|
||||
});
|
||||
} else {
|
||||
const groupedByAttributeData = groupBy.map((attribute) => attribute.key);
|
||||
|
||||
formattedData = data?.map((endpoint) => {
|
||||
const newEndpointName = groupedByAttributeData
|
||||
.map((attribute) => endpoint.data[attribute])
|
||||
.join(',');
|
||||
return {
|
||||
key: v4(),
|
||||
endpointName: newEndpointName,
|
||||
callCount:
|
||||
endpoint.data.A === 'n/a' || endpoint.data.A === undefined
|
||||
? '-'
|
||||
: endpoint.data.A,
|
||||
latency:
|
||||
endpoint.data.B === 'n/a' || endpoint.data.B === undefined
|
||||
? '-'
|
||||
: Math.round(Number(endpoint.data.B) / 1000000), // Convert from nanoseconds to milliseconds
|
||||
lastUsed:
|
||||
endpoint.data.C === 'n/a' || endpoint.data.C === undefined
|
||||
? '-'
|
||||
: getLastUsedRelativeTime(Math.floor(Number(endpoint.data.C) / 1000000)), // Convert from nanoseconds to milliseconds
|
||||
errorRate:
|
||||
endpoint.data.D === 'n/a' || endpoint.data.D === undefined
|
||||
? 0
|
||||
: Number(endpoint.data.D),
|
||||
groupedByMeta: groupedByAttributeData.reduce(
|
||||
(acc, attribute) => {
|
||||
acc[attribute] = endpoint.data[attribute] || '';
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, string | number>,
|
||||
),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// Apply sorting if orderBy is provided
|
||||
if (orderBy) {
|
||||
formattedData.sort((a, b) => {
|
||||
let valueA: number | string = a[
|
||||
orderBy.columnName as keyof EndPointsTableRowData
|
||||
] as number | string;
|
||||
let valueB: number | string = b[
|
||||
orderBy.columnName as keyof EndPointsTableRowData
|
||||
] as number | string;
|
||||
|
||||
// Handle special cases for each column type
|
||||
if (
|
||||
orderBy.columnName === 'callCount' ||
|
||||
orderBy.columnName === 'latency' ||
|
||||
orderBy.columnName === 'errorRate'
|
||||
) {
|
||||
valueA = valueA === '-' || valueA === 'n/a' ? 0 : Number(valueA);
|
||||
valueB = valueB === '-' || valueB === 'n/a' ? 0 : Number(valueB);
|
||||
} else if (orderBy.columnName === 'lastUsed') {
|
||||
// confirm once the implication of this
|
||||
valueA =
|
||||
valueA === '-' || valueA === 'n/a'
|
||||
? new Date(0).getTime()
|
||||
: new Date(valueA as string).getTime();
|
||||
valueB =
|
||||
valueB === '-' || valueB === 'n/a'
|
||||
? new Date(0).getTime()
|
||||
: new Date(valueB as string).getTime();
|
||||
}
|
||||
|
||||
// Apply sort direction
|
||||
if (orderBy.order === 'asc') {
|
||||
return valueA > valueB ? 1 : -1;
|
||||
}
|
||||
return valueA < valueB ? 1 : -1;
|
||||
});
|
||||
}
|
||||
|
||||
return formattedData;
|
||||
};
|
||||
|
||||
export type TopErrorsResponseRow = ScalarData;
|
||||
|
||||
export interface TopErrorsTableRowData {
|
||||
@@ -1333,37 +773,6 @@ export const getTopErrorsColumnsConfig =
|
||||
},
|
||||
];
|
||||
|
||||
export const createFiltersForSelectedRowData = (
|
||||
selectedRowData: EndPointsTableRowData,
|
||||
currentFilters?: IBuilderQuery['filters'],
|
||||
): IBuilderQuery['filters'] => {
|
||||
const baseFilters: IBuilderQuery['filters'] = {
|
||||
items: [...(currentFilters?.items || [])],
|
||||
op: 'and',
|
||||
};
|
||||
|
||||
if (!selectedRowData) {
|
||||
return baseFilters;
|
||||
}
|
||||
|
||||
const { groupedByMeta = {} } = selectedRowData;
|
||||
|
||||
// Replace for...of with Object.keys().map()
|
||||
baseFilters.items.push(
|
||||
...Object.keys(groupedByMeta).map((key) => ({
|
||||
key: {
|
||||
key,
|
||||
type: null,
|
||||
},
|
||||
op: '=',
|
||||
value: groupedByMeta[key] || '',
|
||||
id: key,
|
||||
})),
|
||||
);
|
||||
|
||||
return baseFilters;
|
||||
};
|
||||
|
||||
// First query payload for endpoint metrics
|
||||
// Second query payload for endpoint status code table
|
||||
// Third query payload for endpoint dependant services
|
||||
@@ -2465,21 +1874,6 @@ export const dependentServicesColumns: ColumnType<DependentServicesData>[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const getFormattedChartData = (
|
||||
data: MetricRangePayloadProps,
|
||||
newLegendArray: string[],
|
||||
): MetricRangePayloadProps => {
|
||||
const result = cloneDeep(data);
|
||||
if (result?.data?.result) {
|
||||
result.data.result = result?.data?.result?.map((series, index) => ({
|
||||
...series,
|
||||
legend: newLegendArray[index],
|
||||
}));
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const getStatusCodeClass = (statusCode: string): string => {
|
||||
const code = parseInt(statusCode, 10);
|
||||
|
||||
@@ -3100,40 +2494,6 @@ const getStartAndEndStatusCode = (
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates filter items for bar chart based on group by fields and request data
|
||||
* Used specifically for filtering status code ranges in bar charts
|
||||
* @param groupBy Array of group by fields to create filters for
|
||||
* @param requestData Data from graph click containing values to filter on
|
||||
* @returns Array of TagFilterItems with >= and < operators for status code ranges
|
||||
*/
|
||||
export const createGroupByFiltersForBarChart = (
|
||||
groupBy: BaseAutocompleteData[],
|
||||
requestData: GraphClickMetaData,
|
||||
): TagFilterItem[] =>
|
||||
groupBy
|
||||
.map((gb) => {
|
||||
const value = requestData[gb.key];
|
||||
const [startStatusCode, endStatusCode] = getStartAndEndStatusCode(value);
|
||||
return value
|
||||
? [
|
||||
{
|
||||
id: v4(),
|
||||
key: gb,
|
||||
op: '>=',
|
||||
value: startStatusCode,
|
||||
},
|
||||
{
|
||||
id: v4(),
|
||||
key: gb,
|
||||
op: '<=',
|
||||
value: endStatusCode,
|
||||
},
|
||||
]
|
||||
: [];
|
||||
})
|
||||
.flat();
|
||||
|
||||
export const getCustomFiltersForBarChart = (
|
||||
metric:
|
||||
| {
|
||||
|
||||
@@ -13,11 +13,6 @@ export const DashedContainer = styled.div`
|
||||
align-items: center;
|
||||
`;
|
||||
|
||||
export const ButtonContainer = styled.div`
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
`;
|
||||
|
||||
export const EventContainer = styled.div`
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
@@ -10,23 +10,23 @@ import { useGetExportToDashboardLink } from 'hooks/dashboard/useGetExportToDashb
|
||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
import { useSafeNavigate } from 'hooks/useSafeNavigate';
|
||||
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import {
|
||||
EXPLORER_ACTION_EVENTS,
|
||||
ExplorerActionsSource,
|
||||
getExplorerActionEventPayload,
|
||||
getExportPanelType,
|
||||
} from './utils';
|
||||
|
||||
function AddToDashboardButton({
|
||||
query,
|
||||
sourcepage,
|
||||
sourcePage,
|
||||
panelType,
|
||||
isOneChartPerQuery = false,
|
||||
}: {
|
||||
query: Query | null;
|
||||
sourcepage: DataSource;
|
||||
sourcePage: ExplorerActionsSource;
|
||||
panelType?: PANEL_TYPES;
|
||||
isOneChartPerQuery?: boolean;
|
||||
}): JSX.Element {
|
||||
@@ -40,9 +40,9 @@ function AddToDashboardButton({
|
||||
return;
|
||||
}
|
||||
void logEvent(
|
||||
EXPLORER_ACTION_EVENTS[sourcepage].addToDashboard,
|
||||
EXPLORER_ACTION_EVENTS[sourcePage].addToDashboard,
|
||||
getExplorerActionEventPayload({
|
||||
sourcepage,
|
||||
sourcePage,
|
||||
panelType: contextPanelType,
|
||||
isOneChartPerQuery,
|
||||
}),
|
||||
@@ -59,9 +59,9 @@ function AddToDashboardButton({
|
||||
}
|
||||
const exportPanelType = panelType ?? getExportPanelType(contextPanelType);
|
||||
|
||||
void logEvent(EXPLORER_ACTION_EVENTS[sourcepage].exported, {
|
||||
void logEvent(EXPLORER_ACTION_EVENTS[sourcePage].exported, {
|
||||
...getExplorerActionEventPayload({
|
||||
sourcepage,
|
||||
sourcePage,
|
||||
panelType: contextPanelType,
|
||||
isOneChartPerQuery,
|
||||
}),
|
||||
|
||||
@@ -5,21 +5,21 @@ import logEvent from 'api/common/logEvent';
|
||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
import { useAppNavigate } from 'lib/router/useAppNavigate';
|
||||
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
import {
|
||||
EXPLORER_ACTION_EVENTS,
|
||||
ExplorerActionsSource,
|
||||
getCreateAlertLink,
|
||||
getExplorerActionEventPayload,
|
||||
} from './utils';
|
||||
|
||||
function CreateAlertButton({
|
||||
query,
|
||||
sourcepage,
|
||||
sourcePage,
|
||||
isOneChartPerQuery = false,
|
||||
}: {
|
||||
query: Query | null;
|
||||
sourcepage: DataSource;
|
||||
sourcePage: ExplorerActionsSource;
|
||||
isOneChartPerQuery?: boolean;
|
||||
}): JSX.Element {
|
||||
const navigate = useAppNavigate();
|
||||
@@ -30,8 +30,8 @@ function CreateAlertButton({
|
||||
return;
|
||||
}
|
||||
void logEvent(
|
||||
EXPLORER_ACTION_EVENTS[sourcepage].createAlert,
|
||||
getExplorerActionEventPayload({ sourcepage, panelType, isOneChartPerQuery }),
|
||||
EXPLORER_ACTION_EVENTS[sourcePage].createAlert,
|
||||
getExplorerActionEventPayload({ sourcePage, panelType, isOneChartPerQuery }),
|
||||
);
|
||||
navigate(getCreateAlertLink({ query, panelType }));
|
||||
};
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
import AddToDashboardButton from './AddToDashboardButton';
|
||||
import CreateAlertButton from './CreateAlertButton';
|
||||
import { ExplorerActionsSource } from './utils';
|
||||
|
||||
function ExplorerActions({
|
||||
query,
|
||||
dashboardQuery = query,
|
||||
sourcepage,
|
||||
sourcePage,
|
||||
panelType,
|
||||
isOneChartPerQuery,
|
||||
}: {
|
||||
query: Query | null;
|
||||
// When the dashboard export differs from the alert one (traces list injects columns).
|
||||
dashboardQuery?: Query | null;
|
||||
sourcepage: DataSource;
|
||||
sourcePage: ExplorerActionsSource;
|
||||
panelType?: PANEL_TYPES;
|
||||
isOneChartPerQuery?: boolean;
|
||||
}): JSX.Element {
|
||||
@@ -23,12 +23,12 @@ function ExplorerActions({
|
||||
<>
|
||||
<CreateAlertButton
|
||||
query={query}
|
||||
sourcepage={sourcepage}
|
||||
sourcePage={sourcePage}
|
||||
isOneChartPerQuery={isOneChartPerQuery}
|
||||
/>
|
||||
<AddToDashboardButton
|
||||
query={dashboardQuery}
|
||||
sourcepage={sourcepage}
|
||||
sourcePage={sourcePage}
|
||||
panelType={panelType}
|
||||
isOneChartPerQuery={isOneChartPerQuery}
|
||||
/>
|
||||
|
||||
@@ -17,7 +17,7 @@ import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource, StringOperators } from 'types/common/queryBuilder';
|
||||
|
||||
import AddToDashboardButton from '../AddToDashboardButton';
|
||||
import { getExportPanelType } from '../utils';
|
||||
import { ExplorerActionsSource, getExportPanelType } from '../utils';
|
||||
|
||||
const DASHBOARD = { id: 'dash-1', title: 'Dash 1' };
|
||||
|
||||
@@ -94,7 +94,7 @@ function setPanelType(panelType: PANEL_TYPES): void {
|
||||
|
||||
async function exportTo(
|
||||
query: Query | null,
|
||||
sourcepage: DataSource,
|
||||
sourcePage: ExplorerActionsSource,
|
||||
panelType: PANEL_TYPES,
|
||||
panelTypeProp?: PANEL_TYPES,
|
||||
): Promise<void> {
|
||||
@@ -102,7 +102,7 @@ async function exportTo(
|
||||
render(
|
||||
<AddToDashboardButton
|
||||
query={query}
|
||||
sourcepage={sourcepage}
|
||||
sourcePage={sourcePage}
|
||||
panelType={panelTypeProp}
|
||||
/>,
|
||||
);
|
||||
@@ -128,7 +128,12 @@ describe('AddToDashboardButton', () => {
|
||||
|
||||
it('is disabled without a query and the picker stays closed', () => {
|
||||
setPanelType(PANEL_TYPES.LIST);
|
||||
render(<AddToDashboardButton query={null} sourcepage={DataSource.LOGS} />);
|
||||
render(
|
||||
<AddToDashboardButton
|
||||
query={null}
|
||||
sourcePage={ExplorerActionsSource.LOGS_EXPLORER}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('explorer-add-to-dashboard')).toHaveAttribute(
|
||||
'aria-disabled',
|
||||
@@ -140,7 +145,12 @@ describe('AddToDashboardButton', () => {
|
||||
it('hands the picker the same query it will export', async () => {
|
||||
const query = stagedQuery(DataSource.LOGS);
|
||||
setPanelType(PANEL_TYPES.TIME_SERIES);
|
||||
render(<AddToDashboardButton query={query} sourcepage={DataSource.LOGS} />);
|
||||
render(
|
||||
<AddToDashboardButton
|
||||
query={query}
|
||||
sourcePage={ExplorerActionsSource.LOGS_EXPLORER}
|
||||
/>,
|
||||
);
|
||||
|
||||
await userEvent
|
||||
.setup()
|
||||
@@ -155,19 +165,23 @@ describe('AddToDashboardButton', () => {
|
||||
it("logs the explorer's own open and success events", async () => {
|
||||
const query = stagedQuery(DataSource.TRACES);
|
||||
|
||||
await exportTo(query, DataSource.TRACES, PANEL_TYPES.TABLE);
|
||||
await exportTo(
|
||||
query,
|
||||
ExplorerActionsSource.TRACES_EXPLORER,
|
||||
PANEL_TYPES.TABLE,
|
||||
);
|
||||
|
||||
expect(mockedLogEvent).toHaveBeenCalledWith(
|
||||
'Traces Explorer: Add to dashboard clicked',
|
||||
{
|
||||
sourcepage: DataSource.TRACES,
|
||||
sourcepage: ExplorerActionsSource.TRACES_EXPLORER,
|
||||
panelType: PANEL_TYPES.TABLE,
|
||||
},
|
||||
);
|
||||
expect(mockedLogEvent).toHaveBeenCalledWith(
|
||||
'Traces Explorer: Add to dashboard successful',
|
||||
{
|
||||
sourcepage: DataSource.TRACES,
|
||||
sourcepage: ExplorerActionsSource.TRACES_EXPLORER,
|
||||
panelType: PANEL_TYPES.TABLE,
|
||||
isNewDashboard: undefined,
|
||||
dashboardName: DASHBOARD.title,
|
||||
@@ -181,7 +195,7 @@ describe('AddToDashboardButton', () => {
|
||||
// context says list, the page says time series
|
||||
await exportTo(
|
||||
query,
|
||||
DataSource.METRICS,
|
||||
ExplorerActionsSource.METRICS_EXPLORER,
|
||||
PANEL_TYPES.LIST,
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
);
|
||||
@@ -206,7 +220,11 @@ describe('AddToDashboardButton', () => {
|
||||
PANEL_TYPES.LIST,
|
||||
) as Query;
|
||||
|
||||
await exportTo(exportQuery, DataSource.LOGS, PANEL_TYPES.LIST);
|
||||
await exportTo(
|
||||
exportQuery,
|
||||
ExplorerActionsSource.LOGS_EXPLORER,
|
||||
PANEL_TYPES.LIST,
|
||||
);
|
||||
|
||||
expect(exportQuery.builder.queryData[0].orderBy).toStrictEqual([
|
||||
{ columnName: 'timestamp', order: 'desc' },
|
||||
@@ -221,7 +239,7 @@ describe('AddToDashboardButton', () => {
|
||||
async (panelType) => {
|
||||
const exportQuery = getLogsExportQuery(staged, panelType) as Query;
|
||||
|
||||
await exportTo(exportQuery, DataSource.LOGS, panelType);
|
||||
await exportTo(exportQuery, ExplorerActionsSource.LOGS_EXPLORER, panelType);
|
||||
|
||||
expect(exportQuery).toBe(staged);
|
||||
expect(mockSafeNavigate).toHaveBeenCalledWith(
|
||||
@@ -241,7 +259,11 @@ describe('AddToDashboardButton', () => {
|
||||
options,
|
||||
);
|
||||
|
||||
await exportTo(exportQuery, DataSource.TRACES, PANEL_TYPES.LIST);
|
||||
await exportTo(
|
||||
exportQuery,
|
||||
ExplorerActionsSource.TRACES_EXPLORER,
|
||||
PANEL_TYPES.LIST,
|
||||
);
|
||||
|
||||
const [queryData] = exportQuery.builder.queryData;
|
||||
expect(queryData.selectColumns).toStrictEqual(COLUMNS);
|
||||
@@ -258,7 +280,11 @@ describe('AddToDashboardButton', () => {
|
||||
options,
|
||||
);
|
||||
|
||||
await exportTo(exportQuery, DataSource.TRACES, PANEL_TYPES.TRACE);
|
||||
await exportTo(
|
||||
exportQuery,
|
||||
ExplorerActionsSource.TRACES_EXPLORER,
|
||||
PANEL_TYPES.TRACE,
|
||||
);
|
||||
|
||||
expect(exportQuery.builder.queryData[0].selectColumns).toBeUndefined();
|
||||
expect(mockSafeNavigate).toHaveBeenCalledWith(
|
||||
@@ -278,7 +304,11 @@ describe('AddToDashboardButton', () => {
|
||||
options,
|
||||
);
|
||||
|
||||
await exportTo(exportQuery, DataSource.TRACES, panelType);
|
||||
await exportTo(
|
||||
exportQuery,
|
||||
ExplorerActionsSource.TRACES_EXPLORER,
|
||||
panelType,
|
||||
);
|
||||
|
||||
expect(exportQuery.builder.queryData[0].orderBy).toStrictEqual([]);
|
||||
expect(mockSafeNavigate).toHaveBeenCalledWith(
|
||||
@@ -296,7 +326,11 @@ describe('AddToDashboardButton', () => {
|
||||
options,
|
||||
);
|
||||
|
||||
await exportTo(exportQuery, DataSource.TRACES, panelType);
|
||||
await exportTo(
|
||||
exportQuery,
|
||||
ExplorerActionsSource.TRACES_EXPLORER,
|
||||
panelType,
|
||||
);
|
||||
|
||||
expect(exportQuery).toBe(staged);
|
||||
expect(mockSafeNavigate).toHaveBeenCalledWith(
|
||||
@@ -311,7 +345,7 @@ describe('AddToDashboardButton', () => {
|
||||
|
||||
await exportTo(
|
||||
query,
|
||||
DataSource.METRICS,
|
||||
ExplorerActionsSource.METRICS_EXPLORER,
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
);
|
||||
|
||||
@@ -14,6 +14,7 @@ import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource, StringOperators } from 'types/common/queryBuilder';
|
||||
|
||||
import CreateAlertButton from '../CreateAlertButton';
|
||||
import { ExplorerActionsSource } from '../utils';
|
||||
|
||||
jest.mock('hooks/queryBuilder/useQueryBuilder', () => ({
|
||||
useQueryBuilder: jest.fn(),
|
||||
@@ -60,7 +61,7 @@ function pushedQuery(): Query {
|
||||
const [path, search] = (mockedNavigate.mock.calls[0][0] as string).split('?');
|
||||
expect(path).toBe(ROUTES.ALERTS_NEW);
|
||||
const raw = new URLSearchParams(search).get(QueryParams.compositeQuery);
|
||||
return JSON.parse(raw as string);
|
||||
return JSON.parse(decodeURIComponent(raw as string));
|
||||
}
|
||||
|
||||
function setPanelType(panelType: PANEL_TYPES): void {
|
||||
@@ -71,11 +72,11 @@ function setPanelType(panelType: PANEL_TYPES): void {
|
||||
|
||||
async function clickCreateAlert(
|
||||
query: Query | null,
|
||||
sourcepage: DataSource,
|
||||
sourcePage: ExplorerActionsSource,
|
||||
panelType: PANEL_TYPES,
|
||||
): Promise<void> {
|
||||
setPanelType(panelType);
|
||||
render(<CreateAlertButton query={query} sourcepage={sourcepage} />);
|
||||
render(<CreateAlertButton query={query} sourcePage={sourcePage} />);
|
||||
await userEvent.setup().click(screen.getByTestId('explorer-create-alert'));
|
||||
}
|
||||
|
||||
@@ -86,7 +87,11 @@ describe('CreateAlertButton', () => {
|
||||
});
|
||||
|
||||
it('is disabled and does nothing without a query', async () => {
|
||||
await clickCreateAlert(null, DataSource.LOGS, PANEL_TYPES.LIST);
|
||||
await clickCreateAlert(
|
||||
null,
|
||||
ExplorerActionsSource.LOGS_EXPLORER,
|
||||
PANEL_TYPES.LIST,
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('explorer-create-alert')).toHaveAttribute(
|
||||
'aria-disabled',
|
||||
@@ -98,10 +103,14 @@ describe('CreateAlertButton', () => {
|
||||
it("logs the explorer's own create alert event", async () => {
|
||||
const query = stagedQuery(DataSource.TRACES, StringOperators.COUNT);
|
||||
|
||||
await clickCreateAlert(query, DataSource.TRACES, PANEL_TYPES.TIME_SERIES);
|
||||
await clickCreateAlert(
|
||||
query,
|
||||
ExplorerActionsSource.TRACES_EXPLORER,
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
);
|
||||
|
||||
expect(mockedLogEvent).toHaveBeenCalledWith('Traces Explorer: Create alert', {
|
||||
sourcepage: DataSource.TRACES,
|
||||
sourcepage: ExplorerActionsSource.TRACES_EXPLORER,
|
||||
panelType: PANEL_TYPES.TIME_SERIES,
|
||||
});
|
||||
});
|
||||
@@ -111,7 +120,7 @@ describe('CreateAlertButton', () => {
|
||||
render(
|
||||
<CreateAlertButton
|
||||
query={stagedQuery(DataSource.METRICS, StringOperators.COUNT)}
|
||||
sourcepage={DataSource.METRICS}
|
||||
sourcePage={ExplorerActionsSource.METRICS_EXPLORER}
|
||||
isOneChartPerQuery
|
||||
/>,
|
||||
);
|
||||
@@ -123,7 +132,7 @@ describe('CreateAlertButton', () => {
|
||||
expect(mockedLogEvent).toHaveBeenCalledWith(
|
||||
'Metrics Explorer: Add to alert clicked',
|
||||
{
|
||||
sourcepage: DataSource.METRICS,
|
||||
sourcepage: ExplorerActionsSource.METRICS_EXPLORER,
|
||||
panelType: PANEL_TYPES.TIME_SERIES,
|
||||
tab: 'explorer',
|
||||
oneChartPerQueryEnabled: true,
|
||||
@@ -146,7 +155,11 @@ describe('CreateAlertButton', () => {
|
||||
PANEL_TYPES.LIST,
|
||||
) as Query;
|
||||
|
||||
await clickCreateAlert(exportQuery, DataSource.LOGS, PANEL_TYPES.LIST);
|
||||
await clickCreateAlert(
|
||||
exportQuery,
|
||||
ExplorerActionsSource.LOGS_EXPLORER,
|
||||
PANEL_TYPES.LIST,
|
||||
);
|
||||
|
||||
const [queryData] = pushedQuery().builder.queryData;
|
||||
expect(queryData.aggregateOperator).toBe(StringOperators.COUNT);
|
||||
@@ -165,7 +178,7 @@ describe('CreateAlertButton', () => {
|
||||
|
||||
await clickCreateAlert(
|
||||
exportQuery,
|
||||
DataSource.LOGS,
|
||||
ExplorerActionsSource.LOGS_EXPLORER,
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
);
|
||||
|
||||
@@ -180,7 +193,11 @@ describe('CreateAlertButton', () => {
|
||||
PANEL_TYPES.TABLE,
|
||||
) as Query;
|
||||
|
||||
await clickCreateAlert(exportQuery, DataSource.LOGS, PANEL_TYPES.TABLE);
|
||||
await clickCreateAlert(
|
||||
exportQuery,
|
||||
ExplorerActionsSource.LOGS_EXPLORER,
|
||||
PANEL_TYPES.TABLE,
|
||||
);
|
||||
|
||||
expect(pushedQuery().builder).toStrictEqual(tableStaged.builder);
|
||||
});
|
||||
@@ -194,7 +211,11 @@ describe('CreateAlertButton', () => {
|
||||
async (panelType) => {
|
||||
const exportQuery = getTracesQueryByPanelType(staged, panelType);
|
||||
|
||||
await clickCreateAlert(exportQuery, DataSource.TRACES, panelType);
|
||||
await clickCreateAlert(
|
||||
exportQuery,
|
||||
ExplorerActionsSource.TRACES_EXPLORER,
|
||||
panelType,
|
||||
);
|
||||
|
||||
const [queryData] = pushedQuery().builder.queryData;
|
||||
expect(queryData.aggregateOperator).toBe(StringOperators.COUNT);
|
||||
@@ -211,7 +232,11 @@ describe('CreateAlertButton', () => {
|
||||
expect(staged.builder.queryData[0].orderBy).toStrictEqual(ORDER_BY);
|
||||
const exportQuery = getTracesQueryByPanelType(staged, panelType);
|
||||
|
||||
await clickCreateAlert(exportQuery, DataSource.TRACES, panelType);
|
||||
await clickCreateAlert(
|
||||
exportQuery,
|
||||
ExplorerActionsSource.TRACES_EXPLORER,
|
||||
panelType,
|
||||
);
|
||||
|
||||
expect(pushedQuery().builder.queryData[0].orderBy).toStrictEqual([]);
|
||||
},
|
||||
@@ -223,7 +248,11 @@ describe('CreateAlertButton', () => {
|
||||
const aggStaged = stagedQuery(DataSource.TRACES, StringOperators.COUNT);
|
||||
const exportQuery = getTracesQueryByPanelType(aggStaged, panelType);
|
||||
|
||||
await clickCreateAlert(exportQuery, DataSource.TRACES, panelType);
|
||||
await clickCreateAlert(
|
||||
exportQuery,
|
||||
ExplorerActionsSource.TRACES_EXPLORER,
|
||||
panelType,
|
||||
);
|
||||
|
||||
expect(pushedQuery().builder).toStrictEqual(aggStaged.builder);
|
||||
},
|
||||
@@ -233,7 +262,11 @@ describe('CreateAlertButton', () => {
|
||||
it('metrics: the chart query as is', async () => {
|
||||
const query = stagedQuery(DataSource.METRICS, StringOperators.COUNT);
|
||||
|
||||
await clickCreateAlert(query, DataSource.METRICS, PANEL_TYPES.TIME_SERIES);
|
||||
await clickCreateAlert(
|
||||
query,
|
||||
ExplorerActionsSource.METRICS_EXPLORER,
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
);
|
||||
|
||||
expect(pushedQuery().builder).toStrictEqual(query.builder);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { QueryParams } from 'constants/query';
|
||||
import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import ROUTES from 'constants/routes';
|
||||
import { useGetCompositeQueryParam } from 'hooks/queryBuilder/useGetCompositeQueryParam';
|
||||
import { AllTheProviders, renderHook } from 'tests/test-utils';
|
||||
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { StringOperators } from 'types/common/queryBuilder';
|
||||
|
||||
@@ -22,7 +24,7 @@ function withFirstQuery(
|
||||
function decodeQuery(link: string): Query {
|
||||
const search = link.split('?')[1];
|
||||
const raw = new URLSearchParams(search).get(QueryParams.compositeQuery);
|
||||
return JSON.parse(raw as string);
|
||||
return JSON.parse(decodeURIComponent(raw as string));
|
||||
}
|
||||
|
||||
describe('getExportPanelType', () => {
|
||||
@@ -55,6 +57,26 @@ describe('getCreateAlertLink', () => {
|
||||
expect(decodeQuery(link)).toStrictEqual(query);
|
||||
});
|
||||
|
||||
it.each(["service.name ILIKE 'api%'", "http.route = '/a+b'"])(
|
||||
'the alert page reads back the filter %s unchanged',
|
||||
(expression) => {
|
||||
const link = getCreateAlertLink({
|
||||
query: withFirstQuery(initialQueriesMap.logs, { filter: { expression } }),
|
||||
panelType: PANEL_TYPES.TIME_SERIES,
|
||||
});
|
||||
|
||||
const { result } = renderHook(() => useGetCompositeQueryParam(), {
|
||||
wrapper: ({ children }): JSX.Element => (
|
||||
<AllTheProviders initialRoute={link}>{children}</AllTheProviders>
|
||||
),
|
||||
});
|
||||
|
||||
expect(result.current?.builder.queryData[0].filter?.expression).toBe(
|
||||
expression,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it('logs list: noop becomes count and order by is dropped', () => {
|
||||
const query = withFirstQuery(initialQueriesMap.logs, {
|
||||
aggregateOperator: StringOperators.NOOP,
|
||||
@@ -10,41 +10,57 @@ import { cloneDeep } from 'lodash-es';
|
||||
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource, StringOperators } from 'types/common/queryBuilder';
|
||||
|
||||
// The explorer page, not its DataSource: the AI explorer queries traces but logs its own events.
|
||||
export const ExplorerActionsSource = {
|
||||
LOGS_EXPLORER: DataSource.LOGS,
|
||||
TRACES_EXPLORER: DataSource.TRACES,
|
||||
METRICS_EXPLORER: DataSource.METRICS,
|
||||
AI_OBSERVABILITY_EXPLORER: 'ai_observability',
|
||||
} as const;
|
||||
|
||||
export type ExplorerActionsSource =
|
||||
(typeof ExplorerActionsSource)[keyof typeof ExplorerActionsSource];
|
||||
|
||||
export const EXPLORER_ACTION_EVENTS: Record<
|
||||
DataSource,
|
||||
ExplorerActionsSource,
|
||||
{ createAlert: string; addToDashboard: string; exported: string }
|
||||
> = {
|
||||
[DataSource.LOGS]: {
|
||||
[ExplorerActionsSource.LOGS_EXPLORER]: {
|
||||
createAlert: 'Logs Explorer: Create alert',
|
||||
addToDashboard: 'Logs Explorer: Add to dashboard clicked',
|
||||
exported: 'Logs Explorer: Add to dashboard successful',
|
||||
},
|
||||
[DataSource.TRACES]: {
|
||||
[ExplorerActionsSource.TRACES_EXPLORER]: {
|
||||
createAlert: 'Traces Explorer: Create alert',
|
||||
addToDashboard: 'Traces Explorer: Add to dashboard clicked',
|
||||
exported: 'Traces Explorer: Add to dashboard successful',
|
||||
},
|
||||
[DataSource.METRICS]: {
|
||||
[ExplorerActionsSource.METRICS_EXPLORER]: {
|
||||
createAlert: MetricsExplorerEvents.AddToAlertClicked,
|
||||
addToDashboard: MetricsExplorerEvents.AddToDashboardClicked,
|
||||
exported: MetricsExplorerEvents.AddToDashboardSuccessful,
|
||||
},
|
||||
[ExplorerActionsSource.AI_OBSERVABILITY_EXPLORER]: {
|
||||
createAlert: 'AI Observability Explorer: Create alert',
|
||||
addToDashboard: 'AI Observability Explorer: Add to dashboard clicked',
|
||||
exported: 'AI Observability Explorer: Add to dashboard successful',
|
||||
},
|
||||
};
|
||||
|
||||
export function getExplorerActionEventPayload({
|
||||
sourcepage,
|
||||
sourcePage,
|
||||
panelType,
|
||||
isOneChartPerQuery,
|
||||
}: {
|
||||
sourcepage: DataSource;
|
||||
sourcePage: ExplorerActionsSource;
|
||||
panelType: PANEL_TYPES | null;
|
||||
isOneChartPerQuery: boolean;
|
||||
}): Record<string, unknown> {
|
||||
if (sourcepage !== DataSource.METRICS) {
|
||||
return { sourcepage, panelType };
|
||||
if (sourcePage !== ExplorerActionsSource.METRICS_EXPLORER) {
|
||||
return { sourcepage: sourcePage, panelType };
|
||||
}
|
||||
return {
|
||||
sourcepage,
|
||||
sourcepage: sourcePage,
|
||||
panelType,
|
||||
[MetricsExplorerEventKeys.Tab]: 'explorer',
|
||||
[MetricsExplorerEventKeys.OneChartPerQueryEnabled]: isOneChartPerQuery,
|
||||
@@ -79,7 +95,8 @@ export function getCreateAlertLink({
|
||||
orderBy: isListStyle ? [] : item.orderBy,
|
||||
}));
|
||||
|
||||
// Encoded twice: the alert page decodes it again after the URL does.
|
||||
return `${ROUTES.ALERTS_NEW}?${QueryParams.compositeQuery}=${encodeURIComponent(
|
||||
JSON.stringify(alertQuery),
|
||||
encodeURIComponent(JSON.stringify(alertQuery)),
|
||||
)}`;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
import { ComponentProps } from 'react';
|
||||
import { render, screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import {
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
within,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
import { rest, server } from 'mocks-server/server';
|
||||
import { RestRequest } from 'msw';
|
||||
import type { Region } from 'utils/regions';
|
||||
import type logEvent from '../../../../../api/common/logEvent';
|
||||
|
||||
import CloudAccountSetupModal from '../AddNewAccount/CloudAccountSetupModal';
|
||||
@@ -14,6 +22,24 @@ jest.mock('../../../../../api/common/logEvent', () => ({
|
||||
default: jest.fn() as jest.MockedFunction<typeof logEvent>,
|
||||
}));
|
||||
|
||||
jest.mock('utils/regions', () => {
|
||||
const regions: Region[] = [
|
||||
{
|
||||
id: 'north-america',
|
||||
name: 'North America',
|
||||
subRegions: [
|
||||
{
|
||||
id: 'us-east-1',
|
||||
name: 'us-east-1',
|
||||
displayName: 'US East (N. Virginia)',
|
||||
},
|
||||
{ id: 'us-east-2', name: 'us-east-2', displayName: 'US East (Ohio)' },
|
||||
],
|
||||
},
|
||||
];
|
||||
return { regions };
|
||||
});
|
||||
|
||||
type OnClose = ComponentProps<typeof CloudAccountSetupModal>['onClose'];
|
||||
|
||||
const mockOnClose = (): jest.MockedFunction<OnClose> =>
|
||||
@@ -96,7 +122,7 @@ describe('AWS CloudAccountSetupModal', () => {
|
||||
it('creates the account and shows its setup command', async () => {
|
||||
const api = mockApi();
|
||||
const openSpy = jest.spyOn(window, 'open').mockImplementation(() => null);
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
|
||||
render(<CloudAccountSetupModal onClose={mockOnClose()} />);
|
||||
|
||||
@@ -123,7 +149,7 @@ describe('AWS CloudAccountSetupModal', () => {
|
||||
|
||||
it('asks before closing once a setup command exists', async () => {
|
||||
mockApi();
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onClose = mockOnClose();
|
||||
|
||||
render(<CloudAccountSetupModal onClose={onClose} />);
|
||||
@@ -146,7 +172,7 @@ describe('AWS CloudAccountSetupModal', () => {
|
||||
|
||||
it('closes without asking before a setup command exists', async () => {
|
||||
mockApi();
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onClose = mockOnClose();
|
||||
|
||||
render(<CloudAccountSetupModal onClose={onClose} />);
|
||||
@@ -159,7 +185,7 @@ describe('AWS CloudAccountSetupModal', () => {
|
||||
|
||||
it('resumes polling with Check Again after the connection check fails', async () => {
|
||||
const api = mockApi({ failFirstPoll: true });
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
|
||||
render(<CloudAccountSetupModal onClose={mockOnClose()} />);
|
||||
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
import {
|
||||
SpantypesFieldContextDTO as FieldContext,
|
||||
SpantypesSpanMapperDTO as Mapper,
|
||||
SpantypesSpanMapperOperationDTO as MapperOperation,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import { toast } from '@signozhq/ui/toast';
|
||||
import { rest, server } from 'mocks-server/server';
|
||||
import { render, screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import {
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
within,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
jest.mock('@signozhq/ui/toast', () => ({
|
||||
...jest.requireActual('@signozhq/ui/toast'),
|
||||
@@ -40,7 +48,9 @@ import { DraftGroup } from 'container/LLMObservability/AttributeMapping/types';
|
||||
import AttributeMappingsTab from '../AttributeMappingsTab';
|
||||
import { useAttributeMappingEditor } from '../../hooks/useAttributeMappingEditor';
|
||||
|
||||
function setupGroups(groups = mockGroups): void {
|
||||
const [FIRST_GROUP] = mockGroups;
|
||||
|
||||
function setupGroups(groups = [FIRST_GROUP]): void {
|
||||
server.use(
|
||||
rest.get(GROUPS_ENDPOINT, (_req, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json(makeGroupsResponse(groups))),
|
||||
@@ -155,7 +165,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('renders each group header row with its name, condition count and status', async () => {
|
||||
setupGroups();
|
||||
setupGroups(mockGroups);
|
||||
render(<AttributeMappingsTabWithStore />);
|
||||
|
||||
// Condition filters are no longer shown inline as clauses — the header
|
||||
@@ -179,7 +189,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it("stages a toggle of the group's enabled state via the header switch", async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
setupGroups();
|
||||
render(<AttributeMappingsTabWithStore />);
|
||||
|
||||
@@ -191,7 +201,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('invokes onAddGroup from the toolbar button', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onAddGroup = jest.fn() as jest.MockedFunction<() => void>;
|
||||
setupGroups();
|
||||
render(<AttributeMappingsTabWithStore onAddGroup={onAddGroup} />);
|
||||
@@ -203,7 +213,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('invokes onEditGroup with the group when Edit is chosen from the actions menu', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onEditGroup = jest.fn() as jest.MockedFunction<
|
||||
(group: DraftGroup) => void
|
||||
>;
|
||||
@@ -224,8 +234,8 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('stages a group removal when Delete is chosen from the actions menu', async () => {
|
||||
const user = userEvent.setup();
|
||||
setupGroups();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
setupGroups(mockGroups);
|
||||
render(<AttributeMappingsTabWithStore />);
|
||||
|
||||
await screen.findByTestId('group-name-group-1');
|
||||
@@ -241,7 +251,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it("reveals a group's mappers on expand and hides them on collapse", async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
setupGroups();
|
||||
setupMappers([makeMapper({ id: 'mapper-1' })]);
|
||||
render(<AttributeMappingsTabWithStore />);
|
||||
@@ -271,7 +281,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it("lazily fetches and renders a group's mappers on first expand", async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
setupGroups();
|
||||
setupMappers([
|
||||
makeMapper({ id: 'mapper-1', name: 'gen_ai.request.model', enabled: true }),
|
||||
@@ -300,7 +310,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('shows the mappers error state when the mappers request fails', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
setupGroups();
|
||||
server.use(
|
||||
rest.get(mappersEndpoint('group-1'), (_req, res, ctx) =>
|
||||
@@ -318,7 +328,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('shows the mappers empty state when a group has no mappers', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
setupGroups();
|
||||
setupMappers([]);
|
||||
render(<AttributeMappingsTabWithStore />);
|
||||
@@ -332,7 +342,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('collapses extra mapper sources into a "+N more" label beyond the visible cap', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
setupGroups();
|
||||
setupMappers([
|
||||
makeMapper({
|
||||
@@ -357,7 +367,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('shows a muted placeholder when a mapper has no sources', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
setupGroups();
|
||||
setupMappers([makeMapper({ id: 'mapper-1', config: { sources: [] } })]);
|
||||
render(<AttributeMappingsTabWithStore />);
|
||||
@@ -371,7 +381,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it("re-fetches an open group's mappers on save instead of showing stale rows", async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
setupGroups();
|
||||
|
||||
let mappers = mockMappers;
|
||||
@@ -404,7 +414,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('warns and keeps the working copy when the post-save refresh fails', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
jest.mocked(toast.success).mockClear();
|
||||
jest.mocked(toast.warning).mockClear();
|
||||
|
||||
@@ -413,7 +423,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
rest.get(GROUPS_ENDPOINT, (_req, res, ctx) =>
|
||||
failRefresh
|
||||
? res(ctx.status(500), ctx.json({ status: 'error' }))
|
||||
: res(ctx.status(200), ctx.json(makeGroupsResponse(mockGroups))),
|
||||
: res(ctx.status(200), ctx.json(makeGroupsResponse([FIRST_GROUP]))),
|
||||
),
|
||||
rest.patch(`${GROUPS_ENDPOINT}/:groupId`, (_req, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json({ status: 'ok' })),
|
||||
@@ -435,21 +445,37 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
describe('mapper drawer', () => {
|
||||
async function openGroupWithMapper(
|
||||
async function openGroup(
|
||||
user: ReturnType<typeof userEvent.setup>,
|
||||
mappers: Mapper[],
|
||||
): Promise<void> {
|
||||
setupGroups();
|
||||
setupMappers([makeMapper({ id: 'mapper-1', name: 'gen_ai.request.model' })]);
|
||||
setupMappers(mappers);
|
||||
render(<AttributeMappingsTabWithStore />);
|
||||
|
||||
await screen.findByTestId('group-name-group-1');
|
||||
await expandGroup(user);
|
||||
}
|
||||
|
||||
async function openGroupWithMapper(
|
||||
user: ReturnType<typeof userEvent.setup>,
|
||||
): Promise<void> {
|
||||
await openGroup(user, [
|
||||
makeMapper({ id: 'mapper-1', name: 'gen_ai.request.model' }),
|
||||
]);
|
||||
await screen.findByTestId('mapper-target-mapper-1');
|
||||
}
|
||||
|
||||
async function openEmptyGroup(
|
||||
user: ReturnType<typeof userEvent.setup>,
|
||||
): Promise<void> {
|
||||
await openGroup(user, []);
|
||||
await screen.findByTestId('mappers-empty-group-1');
|
||||
}
|
||||
|
||||
it('opens the add-mapping drawer from a group\'s "Add mapping" button', async () => {
|
||||
const user = userEvent.setup();
|
||||
await openGroupWithMapper(user);
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await openEmptyGroup(user);
|
||||
|
||||
expect(screen.queryByTestId('mapper-form-drawer')).not.toBeInTheDocument();
|
||||
await user.click(screen.getByTestId('add-mapper-group-1'));
|
||||
@@ -461,7 +487,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('opens the edit drawer prefilled and locks the target attribute', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await openGroupWithMapper(user);
|
||||
|
||||
await user.click(screen.getByTestId('mapper-actions-mapper-1'));
|
||||
@@ -479,7 +505,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it("toggles a mapper's enabled state through the store", async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await openGroupWithMapper(user);
|
||||
|
||||
const toggle = screen.getByTestId('mapper-enabled-mapper-1');
|
||||
@@ -493,7 +519,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('removes a mapper via the row action menu', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await openGroupWithMapper(user);
|
||||
|
||||
await user.click(screen.getByTestId('mapper-actions-mapper-1'));
|
||||
@@ -510,8 +536,8 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('creates a new mapping through the drawer and appends it to the group', async () => {
|
||||
const user = userEvent.setup();
|
||||
await openGroupWithMapper(user);
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await openEmptyGroup(user);
|
||||
|
||||
await user.click(screen.getByTestId('add-mapper-group-1'));
|
||||
await screen.findByTestId('mapper-form-drawer');
|
||||
@@ -571,7 +597,7 @@ describe('AttributeMappingsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('renders mappers read-only: no "Add mapping" button or row actions', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
setupGroups();
|
||||
setupMappers([makeMapper({ id: 'mapper-1', name: 'gen_ai.request.model' })]);
|
||||
render(<AttributeMappingsTabWithStore />);
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { useMemo } from 'react';
|
||||
import { TelemetryFieldKey } from 'api/v5/v5';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import ExplorerActions from 'container/ExplorerActions/ExplorerActions';
|
||||
import { ExplorerActionsSource } from 'container/ExplorerActions/utils';
|
||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
|
||||
import { getAlertQuery, getExportQuery } from '../explorerUtils';
|
||||
|
||||
interface AIExplorerActionsProps {
|
||||
panelType: PANEL_TYPES;
|
||||
selectColumns?: TelemetryFieldKey[];
|
||||
}
|
||||
|
||||
function AIExplorerActions({
|
||||
panelType,
|
||||
selectColumns,
|
||||
}: AIExplorerActionsProps): JSX.Element {
|
||||
const { stagedQuery } = useQueryBuilder();
|
||||
|
||||
const alertQuery = useMemo(
|
||||
() => (stagedQuery ? getAlertQuery(stagedQuery, panelType) : null),
|
||||
[stagedQuery, panelType],
|
||||
);
|
||||
|
||||
const dashboardQuery = useMemo(
|
||||
() =>
|
||||
stagedQuery ? getExportQuery(stagedQuery, panelType, selectColumns) : null,
|
||||
[stagedQuery, panelType, selectColumns],
|
||||
);
|
||||
|
||||
return (
|
||||
<ExplorerActions
|
||||
query={alertQuery}
|
||||
dashboardQuery={dashboardQuery}
|
||||
sourcePage={ExplorerActionsSource.AI_OBSERVABILITY_EXPLORER}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default AIExplorerActions;
|
||||
@@ -0,0 +1,301 @@
|
||||
import { logEventMock } from '__tests__/logEventMock';
|
||||
import { safeNavigateMock } from '__tests__/safeNavigateMock';
|
||||
import { TelemetryFieldKey } from 'api/v5/v5';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import {
|
||||
initialFormulaBuilderFormValues,
|
||||
initialQueryAIWithType,
|
||||
PANEL_TYPES,
|
||||
} from 'constants/queryBuilder';
|
||||
import ROUTES from 'constants/routes';
|
||||
import { ExplorerActionsSource } from 'container/ExplorerActions/utils';
|
||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
import { getActiveBuilder } from 'lib/query/builderSlot';
|
||||
import { rest, server } from 'mocks-server/server';
|
||||
import { mockAppNavigate } from 'tests/router-mocks';
|
||||
import { render, screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import { IBuilderQuery, Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { EQueryType } from 'types/common/dashboard';
|
||||
|
||||
import AIExplorerActions from '../AIExplorerActions';
|
||||
|
||||
jest.mock('hooks/queryBuilder/useQueryBuilder', () => ({
|
||||
useQueryBuilder: jest.fn(),
|
||||
}));
|
||||
|
||||
const mockedUseQueryBuilder = jest.mocked(useQueryBuilder);
|
||||
|
||||
const FILTER = "gen_ai.request.model = 'gpt-4o'";
|
||||
|
||||
const USER_COLUMNS: TelemetryFieldKey[] = [
|
||||
{ name: 'gen_ai.request.model', fieldContext: 'attribute' },
|
||||
{ name: 'duration_nano' },
|
||||
];
|
||||
|
||||
function aiStagedQuery(aggregations?: IBuilderQuery['aggregations']): Query {
|
||||
const aiBuilder = getActiveBuilder(initialQueryAIWithType);
|
||||
return {
|
||||
...initialQueryAIWithType,
|
||||
builder_ai_query: {
|
||||
...aiBuilder,
|
||||
queryData: [
|
||||
{
|
||||
...aiBuilder.queryData[0],
|
||||
...(aggregations && { aggregations }),
|
||||
filter: { expression: FILTER },
|
||||
groupBy: [
|
||||
{ key: 'service.name', dataType: DataTypes.String, type: 'resource' },
|
||||
],
|
||||
having: { expression: 'count() > 5' },
|
||||
orderBy: [{ columnName: 'timestamp', order: 'asc' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async function exportFrom(
|
||||
panelType: PANEL_TYPES,
|
||||
stagedQuery: Query = aiStagedQuery(),
|
||||
selectColumns?: TelemetryFieldKey[],
|
||||
): Promise<void> {
|
||||
mockedUseQueryBuilder.mockReturnValue({
|
||||
stagedQuery,
|
||||
panelType,
|
||||
} as ReturnType<typeof useQueryBuilder>);
|
||||
server.use(
|
||||
rest.get('*/api/v2/users/me/dashboards', (_req, res, ctx) =>
|
||||
res(
|
||||
ctx.status(200),
|
||||
ctx.json({ status: 'success', data: { dashboards: [] } }),
|
||||
),
|
||||
),
|
||||
rest.post('*/api/v2/dashboards', (_req, res, ctx) =>
|
||||
res(
|
||||
ctx.status(200),
|
||||
ctx.json({ status: 'success', data: { id: 'dash-1' } }),
|
||||
),
|
||||
),
|
||||
);
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
<AIExplorerActions panelType={panelType} selectColumns={selectColumns} />,
|
||||
);
|
||||
await user.click(screen.getByTestId('explorer-add-to-dashboard'));
|
||||
await user.click(await screen.findByTestId('export-panel-new-dashboard'));
|
||||
|
||||
await waitFor(() => expect(safeNavigateMock).toHaveBeenCalledTimes(1));
|
||||
}
|
||||
|
||||
async function createAlertFrom(
|
||||
panelType: PANEL_TYPES,
|
||||
stagedQuery: Query = aiStagedQuery(),
|
||||
): Promise<Query> {
|
||||
const navigate = mockAppNavigate();
|
||||
mockedUseQueryBuilder.mockReturnValue({
|
||||
stagedQuery,
|
||||
panelType,
|
||||
} as ReturnType<typeof useQueryBuilder>);
|
||||
|
||||
render(<AIExplorerActions panelType={panelType} />);
|
||||
await userEvent.setup().click(screen.getByTestId('explorer-create-alert'));
|
||||
|
||||
expect(navigate).toHaveBeenCalledTimes(1);
|
||||
const [path, search] = (navigate.mock.calls[0][0] as string).split('?');
|
||||
expect(path).toBe(ROUTES.ALERTS_NEW);
|
||||
return JSON.parse(
|
||||
decodeURIComponent(
|
||||
new URLSearchParams(search).get(QueryParams.compositeQuery) ?? '',
|
||||
),
|
||||
) as Query;
|
||||
}
|
||||
|
||||
function exportedPanel(): { panelKind: string | null; query: Query } {
|
||||
const link = safeNavigateMock.mock.calls[0][0] as string;
|
||||
const params = new URLSearchParams(link.split('?')[1]);
|
||||
return {
|
||||
panelKind: params.get('panelKind'),
|
||||
query: JSON.parse(
|
||||
decodeURIComponent(params.get(QueryParams.compositeQuery) ?? ''),
|
||||
) as Query,
|
||||
};
|
||||
}
|
||||
|
||||
describe('AIExplorerActions', () => {
|
||||
it('logs the AI explorer events, not the traces ones', async () => {
|
||||
await exportFrom(PANEL_TYPES.TABLE);
|
||||
|
||||
expect(logEventMock).toHaveBeenCalledWith(
|
||||
'AI Observability Explorer: Add to dashboard clicked',
|
||||
{
|
||||
sourcepage: ExplorerActionsSource.AI_OBSERVABILITY_EXPLORER,
|
||||
panelType: PANEL_TYPES.TABLE,
|
||||
},
|
||||
);
|
||||
expect(logEventMock).toHaveBeenCalledWith(
|
||||
'AI Observability Explorer: Add to dashboard successful',
|
||||
{
|
||||
sourcepage: ExplorerActionsSource.AI_OBSERVABILITY_EXPLORER,
|
||||
panelType: PANEL_TYPES.TABLE,
|
||||
isNewDashboard: true,
|
||||
dashboardName: expect.any(String),
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('list: exports an AI List panel with the user picked columns and no group by, having or order by', async () => {
|
||||
await exportFrom(PANEL_TYPES.LIST, aiStagedQuery(), USER_COLUMNS);
|
||||
|
||||
const { panelKind, query } = exportedPanel();
|
||||
expect(panelKind).toBe('signoz/ListPanel');
|
||||
expect(query.queryType).toBe(EQueryType.AI_QUERY_BUILDER);
|
||||
expect(getActiveBuilder(query).queryData[0]).toMatchObject({
|
||||
filter: { expression: FILTER },
|
||||
groupBy: [],
|
||||
having: { expression: '' },
|
||||
orderBy: [],
|
||||
selectColumns: USER_COLUMNS,
|
||||
});
|
||||
});
|
||||
|
||||
it('trace: exports an AI Time Series panel with no group by, having or order by', async () => {
|
||||
await exportFrom(PANEL_TYPES.TRACE);
|
||||
|
||||
const { panelKind, query } = exportedPanel();
|
||||
expect(panelKind).toBe('signoz/TimeSeriesPanel');
|
||||
expect(query.queryType).toBe(EQueryType.AI_QUERY_BUILDER);
|
||||
const [queryData] = getActiveBuilder(query).queryData;
|
||||
expect(queryData).toMatchObject({
|
||||
filter: { expression: FILTER },
|
||||
groupBy: [],
|
||||
having: { expression: '' },
|
||||
orderBy: [],
|
||||
});
|
||||
expect(queryData.selectColumns).toBeUndefined();
|
||||
});
|
||||
|
||||
it('trace: exports without the formulas, step, limit and legend Timeseries set', async () => {
|
||||
const stagedQuery = aiStagedQuery();
|
||||
const aiBuilder = getActiveBuilder(stagedQuery);
|
||||
await exportFrom(PANEL_TYPES.TRACE, {
|
||||
...stagedQuery,
|
||||
builder_ai_query: {
|
||||
...aiBuilder,
|
||||
queryData: [
|
||||
{
|
||||
...aiBuilder.queryData[0],
|
||||
stepInterval: 300,
|
||||
limit: 10,
|
||||
legend: '{{service.name}}',
|
||||
},
|
||||
],
|
||||
queryFormulas: [
|
||||
{ ...initialFormulaBuilderFormValues, expression: 'A*100' },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const exported = getActiveBuilder(exportedPanel().query);
|
||||
expect(exported.queryFormulas).toStrictEqual([]);
|
||||
expect(exported.queryData[0]).toMatchObject({
|
||||
stepInterval: null,
|
||||
limit: null,
|
||||
legend: '',
|
||||
});
|
||||
});
|
||||
|
||||
it('create alert: logs the AI explorer event, not the traces one', async () => {
|
||||
await createAlertFrom(PANEL_TYPES.TIME_SERIES);
|
||||
|
||||
expect(logEventMock).toHaveBeenCalledWith(
|
||||
'AI Observability Explorer: Create alert',
|
||||
{
|
||||
sourcepage: ExplorerActionsSource.AI_OBSERVABILITY_EXPLORER,
|
||||
panelType: PANEL_TYPES.TIME_SERIES,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('without a staged query: both actions are disabled and create alert goes nowhere', async () => {
|
||||
const navigate = mockAppNavigate();
|
||||
mockedUseQueryBuilder.mockReturnValue({
|
||||
stagedQuery: null,
|
||||
panelType: PANEL_TYPES.LIST,
|
||||
} as ReturnType<typeof useQueryBuilder>);
|
||||
|
||||
render(<AIExplorerActions panelType={PANEL_TYPES.LIST} />);
|
||||
const createAlert = screen.getByTestId('explorer-create-alert');
|
||||
await userEvent.setup().click(createAlert);
|
||||
|
||||
expect(createAlert).toHaveAttribute('aria-disabled', 'true');
|
||||
expect(screen.getByTestId('explorer-add-to-dashboard')).toHaveAttribute(
|
||||
'aria-disabled',
|
||||
'true',
|
||||
);
|
||||
expect(navigate).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it.each([PANEL_TYPES.TIME_SERIES, PANEL_TYPES.TABLE])(
|
||||
'create alert from %s: keeps the aggregation, group by, having and order by',
|
||||
async (panelType) => {
|
||||
const query = await createAlertFrom(
|
||||
panelType,
|
||||
aiStagedQuery([{ expression: 'avg(duration_nano)' }]),
|
||||
);
|
||||
|
||||
expect(query.queryType).toBe(EQueryType.AI_QUERY_BUILDER);
|
||||
expect(getActiveBuilder(query).queryData[0]).toMatchObject({
|
||||
aggregations: [{ expression: 'avg(duration_nano)' }],
|
||||
filter: { expression: FILTER },
|
||||
groupBy: [
|
||||
{ key: 'service.name', dataType: DataTypes.String, type: 'resource' },
|
||||
],
|
||||
having: { expression: 'count() > 5' },
|
||||
orderBy: [{ columnName: 'timestamp', order: 'asc' }],
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it.each([PANEL_TYPES.LIST, PANEL_TYPES.TRACE])(
|
||||
'create alert from %s: a count with no group by, having or order by',
|
||||
async (panelType) => {
|
||||
const query = await createAlertFrom(
|
||||
panelType,
|
||||
aiStagedQuery([{ expression: 'avg(duration_nano)' }]),
|
||||
);
|
||||
|
||||
expect(query.queryType).toBe(EQueryType.AI_QUERY_BUILDER);
|
||||
const [queryData] = getActiveBuilder(query).queryData;
|
||||
expect(queryData).toMatchObject({
|
||||
aggregations: [{ expression: 'count()' }],
|
||||
filter: { expression: FILTER },
|
||||
groupBy: [],
|
||||
having: { expression: '' },
|
||||
orderBy: [],
|
||||
});
|
||||
expect(queryData.selectColumns).toBeUndefined();
|
||||
},
|
||||
);
|
||||
|
||||
it.each([PANEL_TYPES.LIST, PANEL_TYPES.TRACE])(
|
||||
'create alert from %s: only the first query, the one the view shows',
|
||||
async (panelType) => {
|
||||
const stagedQuery = aiStagedQuery();
|
||||
const aiBuilder = getActiveBuilder(stagedQuery);
|
||||
const [first] = aiBuilder.queryData;
|
||||
const query = await createAlertFrom(panelType, {
|
||||
...stagedQuery,
|
||||
builder_ai_query: {
|
||||
...aiBuilder,
|
||||
queryData: [first, { ...first, queryName: 'B', expression: 'B' }],
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
getActiveBuilder(query).queryData.map(({ queryName }) => queryName),
|
||||
).toStrictEqual([first.queryName]);
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -38,6 +38,7 @@ import { GlobalReducer } from 'types/reducer/globalTime';
|
||||
|
||||
import { getListOrderBy, setListOrderBy } from 'utils/explorerUtils';
|
||||
|
||||
import AIExplorerActions from '../AIExplorerActions/AIExplorerActions';
|
||||
import TraceExplorerControls from '../Controls';
|
||||
import { getListViewQuery } from '../explorerUtils';
|
||||
import { PER_PAGE_OPTIONS, TIMESTAMP_FIELD } from './configs';
|
||||
@@ -213,6 +214,10 @@ function ListView({
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<div className="trace-explorer-controls">
|
||||
<AIExplorerActions
|
||||
panelType={PANEL_TYPES.LIST}
|
||||
selectColumns={selectColumns}
|
||||
/>
|
||||
<div className="order-by-container">
|
||||
<div className="order-by-label">
|
||||
Order by <Minus size={14} /> <ArrowUp10 size={14} />
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
useEffect,
|
||||
useMemo,
|
||||
} from 'react';
|
||||
import { QueryKey } from 'react-query';
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { useSelector } from 'react-redux';
|
||||
import Space from 'periscope/components/Space/Space';
|
||||
@@ -24,6 +25,8 @@ import { QueryDataV3 } from 'types/api/widgets/getQuery';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import { GlobalReducer } from 'types/reducer/globalTime';
|
||||
|
||||
import AIExplorerActions from '../AIExplorerActions/AIExplorerActions';
|
||||
|
||||
import './TableView.styles.scss';
|
||||
|
||||
function TableView({
|
||||
@@ -33,7 +36,7 @@ function TableView({
|
||||
}: {
|
||||
setWarning: Dispatch<SetStateAction<Warning | undefined>>;
|
||||
setIsLoadingQueries: Dispatch<SetStateAction<boolean>>;
|
||||
queryKeyRef?: MutableRefObject<any>;
|
||||
queryKeyRef?: MutableRefObject<QueryKey | undefined>;
|
||||
}): JSX.Element {
|
||||
const { stagedQuery, panelType } = useQueryBuilder();
|
||||
|
||||
@@ -101,14 +104,17 @@ function TableView({
|
||||
return (
|
||||
<Space.Compact block direction="vertical">
|
||||
{isError && error && <ErrorInPlace error={error as APIError} />}
|
||||
{!isError && data && (
|
||||
{!isError && (
|
||||
<div className="traces-table-view-header">
|
||||
<ExportMenu
|
||||
dataSource={DataSource.TRACES}
|
||||
data={data}
|
||||
query={stagedQuery || initialQueriesMap.traces}
|
||||
fileName="ai-traces-table"
|
||||
/>
|
||||
<AIExplorerActions panelType={PANEL_TYPES.TABLE} />
|
||||
{data && (
|
||||
<ExportMenu
|
||||
dataSource={DataSource.TRACES}
|
||||
data={data}
|
||||
query={stagedQuery || initialQueriesMap.traces}
|
||||
fileName="ai-traces-table"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{!isError && (
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
useEffect,
|
||||
useMemo,
|
||||
} from 'react';
|
||||
import { QueryKey } from 'react-query';
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { useSelector } from 'react-redux';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
@@ -22,6 +23,8 @@ import APIError from 'types/api/error';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import { GlobalReducer } from 'types/reducer/globalTime';
|
||||
|
||||
import AIExplorerActions from '../AIExplorerActions/AIExplorerActions';
|
||||
|
||||
import './TimeSeriesView.styles.scss';
|
||||
|
||||
function TimeSeriesViewContainer({
|
||||
@@ -128,6 +131,7 @@ function TimeSeriesViewContainer({
|
||||
setWarning={setWarning}
|
||||
allowExport
|
||||
exportFileName="ai-traces-timeseries"
|
||||
headerActions={<AIExplorerActions panelType={PANEL_TYPES.TIME_SERIES} />}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -138,7 +142,7 @@ interface TimeSeriesViewProps {
|
||||
isFilterApplied: boolean;
|
||||
setWarning: Dispatch<SetStateAction<Warning | undefined>>;
|
||||
setIsLoadingQueries: Dispatch<SetStateAction<boolean>>;
|
||||
queryKeyRef?: MutableRefObject<any>;
|
||||
queryKeyRef?: MutableRefObject<QueryKey | undefined>;
|
||||
}
|
||||
|
||||
TimeSeriesViewContainer.defaultProps = {
|
||||
|
||||
@@ -34,6 +34,7 @@ import { Warning } from 'types/api';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import { GlobalReducer } from 'types/reducer/globalTime';
|
||||
|
||||
import AIExplorerActions from '../AIExplorerActions/AIExplorerActions';
|
||||
import TraceExplorerControls from '../Controls';
|
||||
import {
|
||||
TRACE_VIEW_BUILDER_QUERY_TYPE,
|
||||
@@ -191,6 +192,7 @@ function TracesView({
|
||||
<div className={styles.container}>
|
||||
<div className={styles.actionsContainer}>
|
||||
<div className="trace-explorer-controls">
|
||||
<AIExplorerActions panelType={PANEL_TYPES.TRACE} />
|
||||
<div className={styles.orderByContainer}>
|
||||
<div className={styles.orderByLabel}>
|
||||
Order by <Minus size={14} /> <ArrowUp10 size={14} />
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import { ENVIRONMENT } from 'constants/env';
|
||||
import { initialQueryAIWithType, PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { rest, server } from 'mocks-server/server';
|
||||
import { render, screen } from 'tests/test-utils';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
import ListView from '../ListView/ListView';
|
||||
import TableView from '../TableView/TableView';
|
||||
import TimeSeriesView from '../TimeSeriesView/TimeSeriesView';
|
||||
import TracesView from '../TracesView/TracesView';
|
||||
|
||||
const QUERY_RANGE_URL = `${ENVIRONMENT.baseURL}/api/v5/query_range`;
|
||||
|
||||
const VIEWS: [PANEL_TYPES, () => JSX.Element][] = [
|
||||
[
|
||||
PANEL_TYPES.LIST,
|
||||
(): JSX.Element => (
|
||||
<ListView
|
||||
isFilterApplied={false}
|
||||
setWarning={jest.fn()}
|
||||
setIsLoadingQueries={jest.fn()}
|
||||
/>
|
||||
),
|
||||
],
|
||||
[
|
||||
PANEL_TYPES.TRACE,
|
||||
(): JSX.Element => (
|
||||
<TracesView
|
||||
isFilterApplied={false}
|
||||
setWarning={jest.fn()}
|
||||
setIsLoadingQueries={jest.fn()}
|
||||
/>
|
||||
),
|
||||
],
|
||||
[
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
(): JSX.Element => (
|
||||
<TimeSeriesView
|
||||
dataSource={DataSource.TRACES}
|
||||
isFilterApplied={false}
|
||||
setWarning={jest.fn()}
|
||||
setIsLoadingQueries={jest.fn()}
|
||||
/>
|
||||
),
|
||||
],
|
||||
[
|
||||
PANEL_TYPES.TABLE,
|
||||
(): JSX.Element => (
|
||||
<TableView setWarning={jest.fn()} setIsLoadingQueries={jest.fn()} />
|
||||
),
|
||||
],
|
||||
];
|
||||
|
||||
describe('AI explorer views', () => {
|
||||
beforeEach(() => {
|
||||
server.use(
|
||||
rest.post(QUERY_RANGE_URL, (_req, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json({ data: { data: { results: [] } } })),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it.each(VIEWS)(
|
||||
'%s: offers Create an alert and Add to dashboard for the staged query, before data arrives',
|
||||
(panelType, renderView) => {
|
||||
render(
|
||||
renderView(),
|
||||
{},
|
||||
{
|
||||
queryBuilderOverrides: {
|
||||
panelType,
|
||||
stagedQuery: initialQueryAIWithType,
|
||||
currentQuery: initialQueryAIWithType,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('explorer-create-alert')).not.toHaveAttribute(
|
||||
'aria-disabled',
|
||||
'true',
|
||||
);
|
||||
expect(screen.getByTestId('explorer-add-to-dashboard')).not.toHaveAttribute(
|
||||
'aria-disabled',
|
||||
'true',
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -1,9 +1,16 @@
|
||||
import { initialQueriesMap } from 'constants/queryBuilder';
|
||||
import { getActiveBuilder } from 'lib/query/builderSlot';
|
||||
import { TelemetryFieldKey } from 'api/v5/v5';
|
||||
import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import {
|
||||
getActiveBuilder,
|
||||
getBuilderSlotKeyForQueryType,
|
||||
replaceBuilderBySlotKey,
|
||||
} from 'lib/query/builderSlot';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { OrderByPayload, Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { parseListOrderBy } from 'utils/explorerUtils';
|
||||
|
||||
import { defaultSelectedColumns } from './ListView/configs';
|
||||
|
||||
export const getListViewQuery = (
|
||||
stagedQuery: Query,
|
||||
orderBy?: string,
|
||||
@@ -28,3 +35,43 @@ export const getListViewQuery = (
|
||||
|
||||
return query;
|
||||
};
|
||||
|
||||
export const getAlertQuery = (
|
||||
stagedQuery: Query,
|
||||
panelType: PANEL_TYPES,
|
||||
): Query => {
|
||||
if (panelType !== PANEL_TYPES.LIST && panelType !== PANEL_TYPES.TRACE) {
|
||||
return stagedQuery;
|
||||
}
|
||||
const query = getListViewQuery(stagedQuery);
|
||||
const builder = getActiveBuilder(query);
|
||||
// List and Trace show only the first query's filter, so nothing another view set may reach the alert or chart.
|
||||
return replaceBuilderBySlotKey(
|
||||
query,
|
||||
getBuilderSlotKeyForQueryType(query.queryType),
|
||||
{
|
||||
...builder,
|
||||
queryData: builder.queryData.slice(0, 1).map((item) => ({
|
||||
...item,
|
||||
aggregations: [{ expression: 'count()' }],
|
||||
stepInterval: null,
|
||||
limit: null,
|
||||
legend: '',
|
||||
})),
|
||||
queryFormulas: [],
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
export const getExportQuery = (
|
||||
stagedQuery: Query,
|
||||
panelType: PANEL_TYPES,
|
||||
selectColumns: TelemetryFieldKey[] = defaultSelectedColumns,
|
||||
): Query => {
|
||||
const query = getAlertQuery(stagedQuery, panelType);
|
||||
const [queryData] = getActiveBuilder(query).queryData;
|
||||
if (panelType === PANEL_TYPES.LIST && queryData) {
|
||||
queryData.selectColumns = selectColumns;
|
||||
}
|
||||
return query;
|
||||
};
|
||||
|
||||
@@ -5,11 +5,30 @@ import {
|
||||
makeListResponse,
|
||||
makeUnmappedResponse,
|
||||
mockRules,
|
||||
mockUnpricedModels,
|
||||
} from 'container/LLMObservability/Settings/ModelPricing/__tests__/fixtures';
|
||||
import { rest, server } from 'mocks-server/server';
|
||||
import { render, screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import {
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
within,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
import UnpricedModelsTab from '../UnpricedModelsTab';
|
||||
import { usePendingMappingStore } from '../usePendingMappingStore';
|
||||
|
||||
// One antd skeleton renders per placeholder row and per dropdown option on every
|
||||
// load, so fewer of them keep each test's first paint cheap.
|
||||
jest.mock('container/LLMObservability/Settings/ModelPricing/constants', () => ({
|
||||
...jest.requireActual(
|
||||
'container/LLMObservability/Settings/ModelPricing/constants',
|
||||
),
|
||||
SKELETON_ROW_COUNT: 1,
|
||||
RULE_OPTIONS_LIMIT: 2,
|
||||
}));
|
||||
|
||||
const toastSuccess = jest.fn();
|
||||
const toastError = jest.fn();
|
||||
@@ -21,12 +40,20 @@ jest.mock('@signozhq/ui/toast', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
const MODEL = 'gpt-4o-mini-2024-07-18';
|
||||
const [UNPRICED_MODEL] = mockUnpricedModels;
|
||||
const MODEL = UNPRICED_MODEL.modelName;
|
||||
const [TARGET_RULE] = mockRules;
|
||||
|
||||
function stageMapping(): void {
|
||||
usePendingMappingStore.setState({
|
||||
pending: { model: UNPRICED_MODEL, rule: TARGET_RULE },
|
||||
});
|
||||
}
|
||||
|
||||
function setup(): void {
|
||||
server.use(
|
||||
rest.get(LLM_UNMAPPED_ENDPOINT, (_req, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json(makeUnmappedResponse())),
|
||||
res(ctx.status(200), ctx.json(makeUnmappedResponse([UNPRICED_MODEL]))),
|
||||
),
|
||||
rest.get(LLM_PRICING_ENDPOINT, (_req, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json(makeListResponse(mockRules))),
|
||||
@@ -36,8 +63,8 @@ function setup(): void {
|
||||
|
||||
// Picks a billing model in a row's dropdown: open the combobox, wait for the
|
||||
// options (fetched from the rules list mocked above), then arrow down to the
|
||||
// option and press Enter. jsdom cannot deliver the pointer click Base UI
|
||||
// expects on an option.
|
||||
// option and press Enter in its search box. jsdom cannot deliver the pointer
|
||||
// click Base UI expects on an option.
|
||||
async function selectRule(
|
||||
user: ReturnType<typeof userEvent.setup>,
|
||||
modelName: string,
|
||||
@@ -50,10 +77,10 @@ async function selectRule(
|
||||
.findIndex(
|
||||
(option) => option.getAttribute('data-testid') === `map-to-option-${ruleId}`,
|
||||
);
|
||||
await waitFor(() =>
|
||||
expect(screen.getByTestId(`map-to-select-${modelName}-search`)).toHaveFocus(),
|
||||
await user.type(
|
||||
screen.getByTestId(`map-to-select-${modelName}-search`),
|
||||
`${'{ArrowDown}'.repeat(index + 1)}{Enter}`,
|
||||
);
|
||||
await user.keyboard(`${'{ArrowDown}'.repeat(index + 1)}{Enter}`);
|
||||
}
|
||||
|
||||
describe('UnpricedModelsTab (integration)', () => {
|
||||
@@ -64,12 +91,36 @@ describe('UnpricedModelsTab (integration)', () => {
|
||||
|
||||
afterEach(() => {
|
||||
server.resetHandlers();
|
||||
usePendingMappingStore.getState().clearPending();
|
||||
toastSuccess.mockClear();
|
||||
toastError.mockClear();
|
||||
});
|
||||
|
||||
it('cancels the mapping without committing', async () => {
|
||||
const sent: LlmpricingruletypesUpdatableLLMPricingRulesDTO[] = [];
|
||||
server.use(
|
||||
rest.put(LLM_PRICING_ENDPOINT, async (req, res, ctx) => {
|
||||
sent.push(await req.json());
|
||||
return res(ctx.status(200), ctx.json({ status: 'success' }));
|
||||
}),
|
||||
);
|
||||
|
||||
stageMapping();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
render(<UnpricedModelsTab />);
|
||||
|
||||
await user.click(await screen.findByTestId('unpriced-map-cancel-btn'));
|
||||
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.queryByTestId(`unpriced-map-confirm-item-${MODEL}`),
|
||||
).not.toBeInTheDocument(),
|
||||
);
|
||||
expect(sent).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('opens the confirm dialog with the target rule pricing when a model is picked', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
render(<UnpricedModelsTab />);
|
||||
|
||||
await screen.findByTestId(`unpriced-model-name-${MODEL}`);
|
||||
@@ -94,26 +145,20 @@ describe('UnpricedModelsTab (integration)', () => {
|
||||
});
|
||||
|
||||
it('reverts the row trigger to the placeholder when the mapping is cancelled', async () => {
|
||||
const user = userEvent.setup();
|
||||
stageMapping();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
render(<UnpricedModelsTab />);
|
||||
|
||||
await screen.findByTestId(`unpriced-model-name-${MODEL}`);
|
||||
await selectRule(user, MODEL, 'rule-openai');
|
||||
|
||||
const trigger = await screen.findByTestId(`map-to-select-${MODEL}`);
|
||||
expect(
|
||||
within(screen.getByTestId(`map-to-select-${MODEL}`)).getByText(
|
||||
'openai:gpt-4o ($3.00/$9.00)',
|
||||
),
|
||||
within(trigger).getByText('openai:gpt-4o ($3.00/$9.00)'),
|
||||
).toBeInTheDocument();
|
||||
|
||||
await user.click(await screen.findByTestId('unpriced-map-cancel-btn'));
|
||||
await user.click(screen.getByTestId('unpriced-map-cancel-btn'));
|
||||
|
||||
await waitFor(() => {
|
||||
const trigger = screen.getByTestId(`map-to-select-${MODEL}`);
|
||||
expect(
|
||||
within(trigger).getByText('Select / Create a pricing model'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
expect(
|
||||
within(trigger).getByText('Select / Create a pricing model'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('commits the mapping in one request when confirmed', async () => {
|
||||
@@ -125,12 +170,10 @@ describe('UnpricedModelsTab (integration)', () => {
|
||||
}),
|
||||
);
|
||||
|
||||
const user = userEvent.setup();
|
||||
stageMapping();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
render(<UnpricedModelsTab />);
|
||||
|
||||
await screen.findByTestId(`unpriced-model-name-${MODEL}`);
|
||||
await selectRule(user, MODEL, 'rule-openai');
|
||||
|
||||
await user.click(await screen.findByTestId('unpriced-map-confirm-btn'));
|
||||
|
||||
await waitFor(() => expect(sent).toHaveLength(1));
|
||||
@@ -147,33 +190,8 @@ describe('UnpricedModelsTab (integration)', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('cancels the mapping without committing', async () => {
|
||||
const sent: LlmpricingruletypesUpdatableLLMPricingRulesDTO[] = [];
|
||||
server.use(
|
||||
rest.put(LLM_PRICING_ENDPOINT, async (req, res, ctx) => {
|
||||
sent.push(await req.json());
|
||||
return res(ctx.status(200), ctx.json({ status: 'success' }));
|
||||
}),
|
||||
);
|
||||
|
||||
const user = userEvent.setup();
|
||||
render(<UnpricedModelsTab />);
|
||||
|
||||
await screen.findByTestId(`unpriced-model-name-${MODEL}`);
|
||||
await selectRule(user, MODEL, 'rule-openai');
|
||||
|
||||
await user.click(await screen.findByTestId('unpriced-map-cancel-btn'));
|
||||
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.queryByTestId(`unpriced-map-confirm-item-${MODEL}`),
|
||||
).not.toBeInTheDocument(),
|
||||
);
|
||||
expect(sent).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('opens the add-cost drawer prefilled when creating pricing for a model', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
render(<UnpricedModelsTab />);
|
||||
|
||||
await screen.findByTestId(`unpriced-model-name-${MODEL}`);
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import {
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
import { renderListAlertRules } from './_helpers';
|
||||
|
||||
@@ -16,7 +21,7 @@ describe('ListAlertRules — columns selector', () => {
|
||||
});
|
||||
|
||||
it('opens columns popover and lists toggleable columns', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderListAlertRules();
|
||||
|
||||
await screen.findByText('High CPU Alert');
|
||||
@@ -44,7 +49,7 @@ describe('ListAlertRules — columns selector', () => {
|
||||
});
|
||||
|
||||
it('toggling Created At on writes to localStorage and adds the header', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderListAlertRules();
|
||||
|
||||
await screen.findByText('High CPU Alert');
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { getCurrentNuqsSearchParams } from 'tests/nuqs-helpers';
|
||||
import { screen, waitFor } from 'tests/test-utils';
|
||||
import { screen, waitFor, NO_DELAY_USER_EVENT } from 'tests/test-utils';
|
||||
|
||||
import { renderListAlertRules } from './_helpers';
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('ListAlertRules — empty states', () => {
|
||||
});
|
||||
|
||||
it('renders AlertsEmptyState when API returns no rules', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
|
||||
server.use(
|
||||
rest.get('http://localhost/api/v3/rules', (req, res, ctx) =>
|
||||
@@ -49,7 +49,7 @@ describe('ListAlertRules — empty states', () => {
|
||||
});
|
||||
|
||||
it('renders ErrorEmptyState when API returns 500; refresh triggers a refetch', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
|
||||
let callCount = 0;
|
||||
server.use(
|
||||
@@ -76,7 +76,7 @@ describe('ListAlertRules — empty states', () => {
|
||||
});
|
||||
|
||||
it('renders NoResultsEmptyState when the query matches nothing; Clear Search resets it', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
|
||||
server.use(
|
||||
rest.get('http://localhost/api/v3/rules', (req, res, ctx) =>
|
||||
@@ -116,7 +116,7 @@ describe('ListAlertRules — empty states', () => {
|
||||
});
|
||||
|
||||
it('renders NoResultsEmptyState when the states filter matches nothing; Clear Search resets it', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
|
||||
renderListAlertRules({ initialRoute: '/?states=nodata' });
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
} from 'mocks-server/__mockdata__/alert_rules';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { screen, waitFor } from 'tests/test-utils';
|
||||
import { screen, waitFor, NO_DELAY_USER_EVENT } from 'tests/test-utils';
|
||||
import { getCurrentNuqsQueryString } from 'tests/nuqs-helpers';
|
||||
|
||||
import { renderListAlertRules } from './_helpers';
|
||||
@@ -53,7 +53,7 @@ describe('ListAlertRules — pagination', () => {
|
||||
});
|
||||
|
||||
it('navigates to page 2 by requesting the next offset', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderListAlertRules();
|
||||
|
||||
await screen.findByText('Pag Rule 0');
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { safeNavigateMock } from '__tests__/safeNavigateMock';
|
||||
import { useAlertRuleViewsStore } from 'container/ListAlertRules/useAlertRuleViewsStore';
|
||||
import { screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import {
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
import { renderListAlertRules } from './_helpers';
|
||||
|
||||
@@ -13,7 +18,7 @@ describe('ListAlertRules — row click navigation', () => {
|
||||
});
|
||||
|
||||
it('clicking a row calls safeNavigate to alerts/overview with ruleId', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderListAlertRules();
|
||||
|
||||
await user.click(await screen.findByTestId(RULE_NAME_CELL_TEST_ID));
|
||||
@@ -29,7 +34,7 @@ describe('ListAlertRules — row click navigation', () => {
|
||||
});
|
||||
|
||||
it('records an opened rule as recently viewed, most recent first', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
useAlertRuleViewsStore.setState({ recent: ['rule-2', 'rule-1'] });
|
||||
renderListAlertRules();
|
||||
|
||||
@@ -44,7 +49,7 @@ describe('ListAlertRules — row click navigation', () => {
|
||||
});
|
||||
|
||||
it('ctrl+click on a row navigates with newTab option', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderListAlertRules();
|
||||
|
||||
const ruleCell = await screen.findByTestId(RULE_NAME_CELL_TEST_ID);
|
||||
|
||||
@@ -4,7 +4,13 @@ import {
|
||||
} from 'mocks-server/__mockdata__/alert_rules';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import {
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
within,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
import {
|
||||
getCurrentNuqsQueryString,
|
||||
getCurrentNuqsSearchParams,
|
||||
@@ -134,7 +140,7 @@ describe('ListAlertRules — search', () => {
|
||||
});
|
||||
|
||||
it('runs the draft when the search box loses focus', async () => {
|
||||
const user = userEvent.setup({ delay: null, pointerEventsCheck: 0 });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
// jsdom reports no focus once it lands on <body>; a focused browser window does.
|
||||
jest.spyOn(document, 'hasFocus').mockReturnValue(true);
|
||||
renderListAlertRules();
|
||||
@@ -154,7 +160,7 @@ describe('ListAlertRules — search', () => {
|
||||
});
|
||||
|
||||
it('keeps the draft unrun when focus leaves the window', async () => {
|
||||
const user = userEvent.setup({ delay: null, pointerEventsCheck: 0 });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderListAlertRules();
|
||||
|
||||
await screen.findByText('High CPU Alert');
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
userEvent,
|
||||
waitFor,
|
||||
within,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
import { renderListAlertRules, runSearchQuery } from './_helpers';
|
||||
@@ -172,7 +173,7 @@ describe('ListAlertRules — saved views rail', () => {
|
||||
});
|
||||
|
||||
it('Enabled sends every state except disabled', async () => {
|
||||
const user = userEvent.setup({ delay: null, pointerEventsCheck: 0 });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const requests = captureRulesRequests();
|
||||
renderListAlertRules();
|
||||
await screen.findByTestId('alert-row-rule-1-name');
|
||||
@@ -188,7 +189,7 @@ describe('ListAlertRules — saved views rail', () => {
|
||||
});
|
||||
|
||||
it('Recently viewed lists the opened rules in visit order from one large page', async () => {
|
||||
const user = userEvent.setup({ delay: null, pointerEventsCheck: 0 });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const requests = captureRulesRequests();
|
||||
useAlertRuleViewsStore.setState({ recent: ['rule-3', 'rule-1'] });
|
||||
renderListAlertRules();
|
||||
@@ -213,7 +214,7 @@ describe('ListAlertRules — saved views rail', () => {
|
||||
});
|
||||
|
||||
it('an empty Recently viewed keeps the search and says how it fills', async () => {
|
||||
const user = userEvent.setup({ delay: null, pointerEventsCheck: 0 });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderListAlertRules();
|
||||
await screen.findByTestId('alert-row-rule-1-name');
|
||||
|
||||
@@ -564,7 +565,7 @@ describe('ListAlertRules — saved views rail', () => {
|
||||
),
|
||||
),
|
||||
);
|
||||
const user = userEvent.setup({ delay: null, pointerEventsCheck: 0 });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderListAlertRules();
|
||||
await selectView(user, 'view-1');
|
||||
await waitFor(() => expect(urlParam('orderBy')).toBe(VIEW_1_ORDER_BY));
|
||||
|
||||
@@ -42,10 +42,6 @@
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
|
||||
.ant-typography {
|
||||
color: var(--l1-foreground);
|
||||
}
|
||||
|
||||
.loading-gif {
|
||||
height: 72px;
|
||||
margin-left: -24px;
|
||||
|
||||
@@ -3,10 +3,6 @@ import {
|
||||
initialQueryBuilderFormValuesMap,
|
||||
} from 'constants/queryBuilder';
|
||||
import { ORDERBY_FILTERS } from 'container/QueryBuilder/filters/OrderByFilter/config';
|
||||
import {
|
||||
BaseAutocompleteData,
|
||||
DataTypes,
|
||||
} from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import { IBuilderQuery, Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { LogsAggregatorOperator } from 'types/common/queryBuilder';
|
||||
|
||||
@@ -44,9 +40,3 @@ export const liveLogsCompositeQuery = constructCompositeQuery({
|
||||
initialQueryData: initialQueryBuilderFormValuesMap.logs,
|
||||
customQueryData: defaultLiveQueryDataConfig,
|
||||
});
|
||||
|
||||
export const idObject: BaseAutocompleteData = {
|
||||
key: 'id',
|
||||
type: '',
|
||||
dataType: DataTypes.String,
|
||||
};
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
.json-view-container {
|
||||
border-radius: 3px;
|
||||
border: 1px solid var(--l1-border);
|
||||
padding-top: 16px;
|
||||
|
||||
.json-view-footer {
|
||||
height: 36px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-top: 1px solid var(--l1-border);
|
||||
}
|
||||
|
||||
.log-switch {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.wrap-word-switch {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-left: var(--margin-3);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.log-switch-btn {
|
||||
border: 1px solid var(--l1-border);
|
||||
background-color: var(--l2-background);
|
||||
width: 40px;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,6 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.wrap-word-switch {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-left: var(--margin-3);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.log-switch-btn {
|
||||
border: 1px solid var(--l1-border);
|
||||
background-color: var(--l2-background);
|
||||
@@ -53,74 +46,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
.attribute-table {
|
||||
margin-top: var(--margin-1);
|
||||
}
|
||||
|
||||
.ant-collapse {
|
||||
border: 1px solid var(--l1-border);
|
||||
}
|
||||
|
||||
.collapse-content {
|
||||
border-bottom: 1px solid var(--l1-border);
|
||||
|
||||
.ant-collapse-header {
|
||||
align-items: center;
|
||||
border-radius: 2px;
|
||||
background-color: var(--l3-background);
|
||||
border: 1px solid var(--l3-border);
|
||||
|
||||
padding: 8px;
|
||||
|
||||
.ant-collapse-extra {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.action-btn {
|
||||
display: flex;
|
||||
|
||||
.ant-btn {
|
||||
background: color-mix(in srgb, var(--bg-robin-400) 8%, transparent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-collapse-content {
|
||||
padding: 0;
|
||||
background: var(--l2-background);
|
||||
border-top: 1px solid var(--l1-border);
|
||||
|
||||
.ant-collapse-content-box {
|
||||
padding: var(--padding-2) 0 0 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.logs-body-content {
|
||||
padding-top: 12px;
|
||||
}
|
||||
|
||||
[data-slot='badge'] {
|
||||
border-radius: 2px;
|
||||
background: color-mix(in srgb, var(--bg-robin-400) 8%, transparent);
|
||||
}
|
||||
|
||||
.attribute-collapse {
|
||||
.ant-collapse-content {
|
||||
.ant-collapse-content-box {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-table-wrapper .ant-table-cell {
|
||||
padding: 14px 14px;
|
||||
}
|
||||
|
||||
.attribute-tab-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export const DROPDOWN_KEY = {
|
||||
FILTER_IN: 'filterIn',
|
||||
FILTER_OUT: 'filterOut',
|
||||
GROUP_BY: 'groupBy',
|
||||
};
|
||||
@@ -76,9 +76,6 @@ export const generateFieldKeyForArray = (
|
||||
return `body.${newResultNodeKey}`;
|
||||
};
|
||||
|
||||
export const removeObjectFromString = (str: string): string =>
|
||||
str.replace(/\[object Object\]./g, '');
|
||||
|
||||
// Split `str` on the first occurrence of `delimiter`
|
||||
// For example, will return `['a', 'b.c']` when splitting `'a.b.c'` at dots
|
||||
const splitOnce = (str: string, delimiter: string): string[] => {
|
||||
@@ -303,30 +300,6 @@ export const unescapeString = (str: string): string =>
|
||||
String.fromCharCode(parseInt(hex, 16)),
|
||||
); // Replaces Unicode escape sequences
|
||||
|
||||
export function findKeyPath(
|
||||
obj: AnyObject,
|
||||
targetKey: string,
|
||||
currentPath = '',
|
||||
): string | null {
|
||||
let finalPath = null;
|
||||
Object.keys(obj).forEach((key) => {
|
||||
const value = obj[key];
|
||||
const newPath = currentPath ? `${currentPath}.${key}` : key;
|
||||
|
||||
if (key === targetKey) {
|
||||
finalPath = newPath;
|
||||
}
|
||||
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
const result = findKeyPath(value, targetKey, newPath);
|
||||
if (result) {
|
||||
finalPath = result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return finalPath;
|
||||
}
|
||||
|
||||
export const getSanitizedLogBody = (
|
||||
text: string,
|
||||
options: { shouldEscapeHtml?: boolean } = {},
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
.qb-search-view-container {
|
||||
padding: 8px 16px;
|
||||
|
||||
.ant-select-selector {
|
||||
border-radius: 2px;
|
||||
border: 1px solid var(--l1-border) !important;
|
||||
background-color: var(--l1-background) !important;
|
||||
color: var(--l2-foreground);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,6 @@ import { useShareBuilderUrl } from 'hooks/queryBuilder/useShareBuilderUrl';
|
||||
import { ExplorerViews } from 'pages/LogsExplorer/utils';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
import './LogsExplorerQuerySection.styles.scss';
|
||||
|
||||
function LogExplorerQuerySection({
|
||||
selectedView,
|
||||
}: {
|
||||
|
||||
@@ -62,16 +62,6 @@ const SEVERITY_VARIANT_COLORS: Record<string, string> = {
|
||||
PANIC: Color.BG_SAKURA_600,
|
||||
};
|
||||
|
||||
// Simple function to get severity color for any component
|
||||
export function getSeverityColor(severityText: string): string {
|
||||
const variantColor = SEVERITY_VARIANT_COLORS[severityText.trim()];
|
||||
if (variantColor) {
|
||||
return variantColor;
|
||||
}
|
||||
|
||||
return Color.BG_ROBIN_500; // Default fallback
|
||||
}
|
||||
|
||||
export function getColorsForSeverityLabels(
|
||||
label: string,
|
||||
index: number,
|
||||
|
||||
@@ -7,252 +7,6 @@
|
||||
letter-spacing: -0.005em;
|
||||
text-align: left;
|
||||
min-height: 0;
|
||||
|
||||
.logs-list-table-view-container {
|
||||
.data-table-container {
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
table {
|
||||
thead {
|
||||
tr {
|
||||
th {
|
||||
font-size: 12px;
|
||||
color: white !important;
|
||||
|
||||
.cursor-col-resize {
|
||||
width: 24px !important;
|
||||
cursor: col-resize !important;
|
||||
opacity: 1 !important;
|
||||
background-color: transparent !important;
|
||||
border: none !important;
|
||||
|
||||
&:hover {
|
||||
opacity: 1 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
td {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
border-bottom: 1px solid var(--l1-border) !important;
|
||||
}
|
||||
|
||||
border-bottom: 1px solid var(--l1-border) !important;
|
||||
background-color: var(--l2-background) !important;
|
||||
|
||||
tr {
|
||||
&:hover {
|
||||
background-color: var(--l2-background) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
font-size: 12px;
|
||||
padding: 4px !important;
|
||||
|
||||
white-space: pre-wrap !important;
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: var(--l1-border) !important;
|
||||
}
|
||||
|
||||
border-bottom: 1px solid var(--l1-border) !important;
|
||||
}
|
||||
|
||||
tr:has(.active-log) {
|
||||
background-color: rgba(78, 116, 248, 0.5) !important; // same as bg-robin-500
|
||||
color: var(--l1-foreground) !important;
|
||||
}
|
||||
}
|
||||
|
||||
thead {
|
||||
z-index: 2 !important;
|
||||
}
|
||||
|
||||
.log-state-indicator {
|
||||
padding-left: 0 !important;
|
||||
|
||||
.line {
|
||||
margin: 0 0 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sticky-header-table-container {
|
||||
&::-webkit-scrollbar {
|
||||
width: 0.4rem;
|
||||
height: 0.4rem;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--l3-background);
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--l3-background);
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='1'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='2'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='3'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 3;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='4'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 4;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='5'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 5;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='6'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 6;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='7'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 7;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='8'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 8;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='9'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 9;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&[data-max-lines-per-row='10'] {
|
||||
tbody {
|
||||
tr {
|
||||
td {
|
||||
.table-cell-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 10;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.logs-linked-row td {
|
||||
|
||||
@@ -132,16 +132,6 @@
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.order-by-select {
|
||||
width: 100px;
|
||||
|
||||
.ant-select-selector {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import {
|
||||
getQueryByPanelType,
|
||||
} from 'container/LogsExplorerViews/explorerUtils';
|
||||
import ExplorerActions from 'container/ExplorerActions/ExplorerActions';
|
||||
import { ExplorerActionsSource } from 'container/ExplorerActions/utils';
|
||||
import TimeSeriesView from 'container/TimeSeriesView/TimeSeriesView';
|
||||
import { useCopyLogLink } from 'hooks/logs/useCopyLogLink';
|
||||
import { useGetExplorerQueryRange } from 'hooks/queryBuilder/useGetExplorerQueryRange';
|
||||
@@ -136,7 +137,10 @@ function LogsExplorerViewsContainer({
|
||||
|
||||
const explorerActions = useMemo(
|
||||
() => (
|
||||
<ExplorerActions query={exportDefaultQuery} sourcepage={DataSource.LOGS} />
|
||||
<ExplorerActions
|
||||
query={exportDefaultQuery}
|
||||
sourcePage={ExplorerActionsSource.LOGS_EXPLORER}
|
||||
/>
|
||||
),
|
||||
[exportDefaultQuery],
|
||||
);
|
||||
|
||||
@@ -20,17 +20,6 @@
|
||||
font-weight: 400;
|
||||
line-height: 18px;
|
||||
font-family: Inter;
|
||||
|
||||
.ant-typography {
|
||||
background-color: transparent;
|
||||
color: var(--l1-foreground);
|
||||
margin-bottom: 0;
|
||||
font-size: 13px;
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
line-height: 18px;
|
||||
font-family: Inter;
|
||||
}
|
||||
padding: 14px 8px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
|
||||
@@ -21,6 +21,7 @@ import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { MAX_QUERY_RETRIES } from 'constants/reactQuery';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
import ExplorerActions from 'container/ExplorerActions/ExplorerActions';
|
||||
import { ExplorerActionsSource } from 'container/ExplorerActions/utils';
|
||||
import TimeSeriesView from 'container/TimeSeriesView/TimeSeriesView';
|
||||
import { convertDataValueToMs } from 'container/TimeSeriesView/utils';
|
||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
@@ -347,7 +348,7 @@ function TimeSeries({
|
||||
headerActions={
|
||||
<ExplorerActions
|
||||
query={stagedQuery ? exportQuery : null}
|
||||
sourcepage={DataSource.METRICS}
|
||||
sourcePage={ExplorerActionsSource.METRICS_EXPLORER}
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
isOneChartPerQuery={changeLayoutForOneChartPerQuery}
|
||||
/>
|
||||
|
||||
@@ -29,15 +29,6 @@ export const ProcessorTypeContainer = styled.div`
|
||||
gap: 0.313rem;
|
||||
`;
|
||||
|
||||
export const Container = styled.div`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-start;
|
||||
padding: 0rem;
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
export const FormWrapper = styled.div`
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
.sample-logs-notice-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { Badge } from '@signozhq/ui/badge';
|
||||
|
||||
function Tags({ tags }: TagsProps): JSX.Element {
|
||||
return (
|
||||
<span>
|
||||
{tags?.map((tag) => (
|
||||
<Badge
|
||||
textTransform="none"
|
||||
variant="solid"
|
||||
color="highlight-danger"
|
||||
key={tag}
|
||||
>
|
||||
{tag}
|
||||
</Badge>
|
||||
))}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
interface TagsProps {
|
||||
tags: Array<string>;
|
||||
}
|
||||
|
||||
export default Tags;
|
||||
@@ -2,8 +2,6 @@ import { Pipeline, PipelineData } from 'types/api/pipeline/def';
|
||||
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import { TagFilter } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
export const configurationVersion = '1.0';
|
||||
|
||||
export function mockPipelineFilter(
|
||||
key: string,
|
||||
op: string,
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import Tags from 'container/PipelinePage/PipelineListsView/TableComponents/Tags';
|
||||
import { render } from 'tests/test-utils';
|
||||
|
||||
const tags = ['server', 'app'];
|
||||
|
||||
describe('PipelinePage container test', () => {
|
||||
it('should render Tags section', () => {
|
||||
const { asFragment } = render(<Tags tags={tags} />);
|
||||
expect(asFragment()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
@@ -1,42 +0,0 @@
|
||||
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
||||
|
||||
exports[`PipelinePage container test should render Tags section 1`] = `
|
||||
<DocumentFragment>
|
||||
<span>
|
||||
<span
|
||||
class="_badge_1wurm_1"
|
||||
data-color="highlight-danger"
|
||||
data-slot="badge"
|
||||
data-text-overflow="ellipsis"
|
||||
data-text-transform="none"
|
||||
data-trigger-disabled=""
|
||||
data-variant="solid"
|
||||
id="base-ui-:r1:"
|
||||
>
|
||||
<span
|
||||
class="_badge__label_1wurm_141"
|
||||
data-slot="badge-label"
|
||||
>
|
||||
server
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="_badge_1wurm_1"
|
||||
data-color="highlight-danger"
|
||||
data-slot="badge"
|
||||
data-text-overflow="ellipsis"
|
||||
data-text-transform="none"
|
||||
data-trigger-disabled=""
|
||||
data-variant="solid"
|
||||
id="base-ui-:r3:"
|
||||
>
|
||||
<span
|
||||
class="_badge__label_1wurm_141"
|
||||
data-slot="badge-label"
|
||||
>
|
||||
app
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</DocumentFragment>
|
||||
`;
|
||||
@@ -11,7 +11,13 @@ import {
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import type { ErrorType } from 'api/generatedAPIInstance';
|
||||
import { mockAppLocation, mockNavigate } from 'tests/router-mocks';
|
||||
import { render, screen, userEvent, within } from 'tests/test-utils';
|
||||
import {
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
within,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
import { USER_ROLES } from 'types/roles';
|
||||
|
||||
import { PlannedDowntime } from '../PlannedDowntime';
|
||||
@@ -240,14 +246,15 @@ describe('PlannedDowntime Component', () => {
|
||||
});
|
||||
|
||||
it('should filter downtime schedules by name when searching', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderPage();
|
||||
|
||||
await expect(
|
||||
screen.findByText(MOCK_DOWNTIME_1_NAME),
|
||||
).resolves.toBeInTheDocument();
|
||||
|
||||
await user.type(screen.getByTestId(SEARCH_TEST_ID), MOCK_DOWNTIME_1_NAME);
|
||||
await user.click(screen.getByTestId(SEARCH_TEST_ID));
|
||||
await user.paste(MOCK_DOWNTIME_1_NAME);
|
||||
|
||||
await expect(
|
||||
screen.findByText(MOCK_DOWNTIME_1_NAME),
|
||||
@@ -257,7 +264,7 @@ describe('PlannedDowntime Component', () => {
|
||||
});
|
||||
|
||||
it('should filter downtime schedules with partial name match', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderPage();
|
||||
|
||||
await expect(
|
||||
@@ -274,10 +281,11 @@ describe('PlannedDowntime Component', () => {
|
||||
});
|
||||
|
||||
it('should show no results when search term matches nothing', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderPage();
|
||||
|
||||
await user.type(screen.getByTestId(SEARCH_TEST_ID), 'NonExistentDowntime');
|
||||
await user.click(screen.getByTestId(SEARCH_TEST_ID));
|
||||
await user.paste('NonExistentDowntime');
|
||||
|
||||
await expect(
|
||||
screen.findByTestId('no-results-empty-state'),
|
||||
@@ -286,7 +294,7 @@ describe('PlannedDowntime Component', () => {
|
||||
});
|
||||
|
||||
it('opens the delete confirmation from the row actions', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderPage();
|
||||
|
||||
await user.click(await screen.findByTestId('downtime-actions-1'));
|
||||
|
||||
@@ -19,6 +19,7 @@ import { QueryBuilderContext } from 'providers/QueryBuilder';
|
||||
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import { FieldDataType, TelemetryFieldKey } from 'types/api/v5/queryRange';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/test-utils';
|
||||
|
||||
import QueryBuilderSearchV2 from '../QueryBuilderSearchV2';
|
||||
|
||||
@@ -148,7 +149,7 @@ jest.mock('hooks/dashboard/useDynamicVariableSuggestions', () => ({
|
||||
|
||||
describe('Suggestion Key -> Operator -> Value Flow', () => {
|
||||
it('should complete full flow from key selection to value', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderWithContext();
|
||||
|
||||
const combobox = getSearchCombobox();
|
||||
@@ -199,7 +200,7 @@ describe('Suggestion Key -> Operator -> Value Flow', () => {
|
||||
|
||||
describe('Operator suggestions for data types missing from the operators map', () => {
|
||||
it('should fall back to universal operators for a non-canonical data type', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderWithContext();
|
||||
|
||||
const combobox = getSearchCombobox();
|
||||
@@ -226,7 +227,7 @@ describe('Operator suggestions for data types missing from the operators map', (
|
||||
|
||||
describe('Dynamic Variable Suggestions', () => {
|
||||
it('should suggest dynamic variable when key matches a variable attribute', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderWithContext();
|
||||
|
||||
const combobox = getSearchCombobox();
|
||||
@@ -298,7 +299,7 @@ describe('Filter chips', () => {
|
||||
});
|
||||
|
||||
it('removes the filter once when the chip close button is clicked', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderWithContext({ query: queryWithFilter });
|
||||
|
||||
await user.click(
|
||||
@@ -312,7 +313,7 @@ describe('Filter chips', () => {
|
||||
});
|
||||
|
||||
it('moves the filter into the search input when the chip body is clicked', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderWithContext({ query: queryWithFilter });
|
||||
|
||||
await user.click(screen.getByText(CHIP_LABEL));
|
||||
@@ -356,7 +357,7 @@ describe('Key fetch context', () => {
|
||||
|
||||
describe('Keys the legacy filter builders cannot read', () => {
|
||||
it('does not suggest body JSON keys or span search scope selectors', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderWithContext();
|
||||
|
||||
const combobox = getSearchCombobox();
|
||||
@@ -372,7 +373,7 @@ describe('Keys the legacy filter builders cannot read', () => {
|
||||
|
||||
describe('Span field keys', () => {
|
||||
it('marks span fields as columns and looks up their values in the span context', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderWithContext();
|
||||
|
||||
const combobox = getSearchCombobox();
|
||||
|
||||
@@ -135,9 +135,10 @@ describe('ServiceAccountsSettings — FGA', () => {
|
||||
renderPage();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByRole('button', { name: /New Service Account/i }),
|
||||
).toHaveAttribute('aria-disabled', 'true');
|
||||
expect(screen.getByTestId('new-sa-btn')).toHaveAttribute(
|
||||
'aria-disabled',
|
||||
'true',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -160,9 +161,10 @@ describe('ServiceAccountsSettings — FGA', () => {
|
||||
renderPage();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByRole('button', { name: /New Service Account/i }),
|
||||
).not.toHaveAttribute('aria-disabled', 'true');
|
||||
expect(screen.getByTestId('new-sa-btn')).not.toHaveAttribute(
|
||||
'aria-disabled',
|
||||
'true',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import { CSSProperties } from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
export const tableStyles: CSSProperties = {
|
||||
cursor: 'unset',
|
||||
};
|
||||
|
||||
export const Container = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
--typography-color: var(--l1-foreground);
|
||||
`;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { screen, waitFor } from 'tests/test-utils';
|
||||
import { screen, waitFor, NO_DELAY_USER_EVENT } from 'tests/test-utils';
|
||||
|
||||
import { renderTriggeredAlerts } from './_helpers';
|
||||
|
||||
describe('TriggeredAlerts — severity filter', () => {
|
||||
it('filters to only critical-severity rows when "Critical" is selected', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderTriggeredAlerts();
|
||||
|
||||
await waitFor(() =>
|
||||
@@ -30,7 +30,7 @@ describe('TriggeredAlerts — severity filter', () => {
|
||||
});
|
||||
|
||||
it('shows union when multiple severities are selected', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderTriggeredAlerts();
|
||||
|
||||
await waitFor(() =>
|
||||
@@ -55,7 +55,7 @@ describe('TriggeredAlerts — severity filter', () => {
|
||||
});
|
||||
|
||||
it('clearing the filter shows all rows again', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderTriggeredAlerts();
|
||||
|
||||
await waitFor(() =>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import {
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
within,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
import { renderTriggeredAlerts } from './_helpers';
|
||||
|
||||
@@ -13,7 +19,7 @@ describe('TriggeredAlerts — group by', () => {
|
||||
});
|
||||
|
||||
it('groups by service when "service" is selected', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderTriggeredAlerts();
|
||||
|
||||
await waitFor(() =>
|
||||
@@ -38,7 +44,7 @@ describe('TriggeredAlerts — group by', () => {
|
||||
});
|
||||
|
||||
it('expands and collapses a group row to reveal nested alerts', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderTriggeredAlerts();
|
||||
|
||||
await waitFor(() =>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import { triggeredAlertsPaginationFixture } from 'mocks-server/__mockdata__/triggered_alerts';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import {
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
within,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
import { getCurrentNuqsQueryString } from 'tests/nuqs-helpers';
|
||||
|
||||
import { renderTriggeredAlerts } from './_helpers';
|
||||
@@ -50,7 +56,7 @@ describe('TriggeredAlerts — pagination', () => {
|
||||
|
||||
it('navigates to page 2 and shows the next batch of alerts', async () => {
|
||||
usePaginationHandler();
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderTriggeredAlerts();
|
||||
|
||||
await screen.findByText('Pag Alert 14');
|
||||
|
||||
@@ -3,13 +3,13 @@ import { logEventMock } from '__tests__/logEventMock';
|
||||
import { safeNavigateMock } from '__tests__/safeNavigateMock';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { screen, waitFor } from 'tests/test-utils';
|
||||
import { screen, waitFor, NO_DELAY_USER_EVENT } from 'tests/test-utils';
|
||||
|
||||
import { getTriggeredAlertRowTestId, renderTriggeredAlerts } from './_helpers';
|
||||
|
||||
describe('TriggeredAlerts — row click', () => {
|
||||
it('navigates to the alert overview with the rule id from labels on row click', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderTriggeredAlerts();
|
||||
|
||||
await waitFor(() =>
|
||||
@@ -35,7 +35,7 @@ describe('TriggeredAlerts — row click', () => {
|
||||
});
|
||||
|
||||
it('opens in a new tab when ctrl+clicked', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderTriggeredAlerts();
|
||||
|
||||
await waitFor(() =>
|
||||
@@ -83,7 +83,7 @@ describe('TriggeredAlerts — row click', () => {
|
||||
),
|
||||
);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderTriggeredAlerts();
|
||||
|
||||
await waitFor(() =>
|
||||
@@ -125,7 +125,7 @@ describe('TriggeredAlerts — row click', () => {
|
||||
),
|
||||
);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderTriggeredAlerts();
|
||||
|
||||
await waitFor(() =>
|
||||
|
||||
@@ -3,11 +3,6 @@ import { ScalarFieldValue } from 'utils/stringUtils';
|
||||
import { ILog } from 'types/api/logs/log';
|
||||
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
|
||||
export type LogTimeRange = {
|
||||
start: number;
|
||||
end: number;
|
||||
};
|
||||
|
||||
export type UseCopyLogLink = {
|
||||
isHighlighted: boolean;
|
||||
isLogsExplorerPage: boolean;
|
||||
|
||||
@@ -18,7 +18,6 @@ import 'lib/monaco/loader';
|
||||
import './ReactI18';
|
||||
|
||||
import 'styles.scss';
|
||||
import 'lib/uPlotStylesheet';
|
||||
|
||||
installTranslationResilience();
|
||||
configureOverlayScrollbars();
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import href from 'uplot/dist/uPlot.min.css?url';
|
||||
|
||||
// Appended to the end of <body> so uPlot's rules win ties over the app's stylesheets.
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = href;
|
||||
document.body.appendChild(link);
|
||||
@@ -6,7 +6,13 @@ import {
|
||||
import { ChannelKind } from 'container/CreateAlertChannels/types';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { render, screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import {
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
import ChannelForm from '../components/ChannelForm/ChannelForm';
|
||||
|
||||
@@ -51,7 +57,7 @@ describe('ChannelForm save', () => {
|
||||
const onDone = jest.fn();
|
||||
render(<ChannelForm onDone={onDone} />);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await user.type(
|
||||
await screen.findByTestId('channel-name-textbox-field', {}, FIND),
|
||||
'prod alerts',
|
||||
@@ -99,7 +105,7 @@ describe('ChannelForm save', () => {
|
||||
|
||||
render(<ChannelForm onDone={jest.fn()} />);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await pickChannelType(user, ChannelKind.telegram);
|
||||
|
||||
await user.type(
|
||||
@@ -150,7 +156,7 @@ describe('ChannelForm save', () => {
|
||||
|
||||
render(<ChannelForm onDone={jest.fn()} />);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await pickChannelType(user, ChannelKind.webhook);
|
||||
|
||||
await user.type(
|
||||
@@ -212,7 +218,7 @@ describe('ChannelForm save', () => {
|
||||
|
||||
render(<ChannelForm onDone={jest.fn()} />);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await pickChannelType(user, ChannelKind.jira);
|
||||
expect(
|
||||
screen.getByTestId('jira-deployment-radio-item-cloud'),
|
||||
@@ -280,7 +286,7 @@ describe('ChannelForm save', () => {
|
||||
|
||||
render(<ChannelForm onDone={jest.fn()} />);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await user.type(
|
||||
await screen.findByTestId('channel-name-textbox-field', {}, FIND),
|
||||
'slack alerts',
|
||||
@@ -329,7 +335,7 @@ describe('ChannelForm save', () => {
|
||||
);
|
||||
expect(channelName).toBeDisabled();
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await user.clear(screen.getByTestId('slack-channel-textbox-field'));
|
||||
await user.type(
|
||||
screen.getByTestId('slack-channel-textbox-field'),
|
||||
@@ -398,7 +404,7 @@ describe('ChannelForm save', () => {
|
||||
{},
|
||||
FIND,
|
||||
);
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await user.clear(token);
|
||||
await user.type(
|
||||
screen.getByTestId('webhook-bearer-token-textbox-field'),
|
||||
@@ -494,7 +500,7 @@ describe('ChannelForm save', () => {
|
||||
FIND,
|
||||
);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await user.click(testButton);
|
||||
|
||||
await waitFor(() => expect(body).toBeDefined(), FIND);
|
||||
@@ -531,7 +537,7 @@ describe('ChannelForm save', () => {
|
||||
|
||||
// Save is off until something changes, so one edit is what tells a
|
||||
// settled failure apart from a denial
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await user.type(channel, '-edited');
|
||||
|
||||
const save = screen.getByTestId('save-channel-button');
|
||||
@@ -568,7 +574,7 @@ describe('ChannelForm save', () => {
|
||||
const save = screen.getByTestId('save-channel-button');
|
||||
expect(save).toHaveAttribute('aria-disabled', 'true');
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await user.type(
|
||||
screen.getByTestId('slack-channel-textbox-field'),
|
||||
'-edited',
|
||||
@@ -588,7 +594,7 @@ describe('ChannelForm save', () => {
|
||||
const onDone = jest.fn();
|
||||
render(<ChannelForm channelId="3" onDone={onDone} />);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const discard = await screen.findByTestId(
|
||||
'discard-channel-button',
|
||||
{},
|
||||
@@ -663,7 +669,7 @@ describe('ChannelForm save', () => {
|
||||
|
||||
render(<ChannelForm onDone={jest.fn()} />);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await pickChannelType(user, ChannelKind.telegram);
|
||||
|
||||
expect(screen.getByTestId('telegram-title-textarea')).toHaveValue('');
|
||||
@@ -705,7 +711,7 @@ describe('ChannelForm save', () => {
|
||||
async () => {
|
||||
render(<ChannelForm onDone={jest.fn()} />);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await pickChannelType(user, ChannelKind.pagerduty);
|
||||
|
||||
expect(screen.getByTestId('pager-client-url-textarea-field')).toHaveValue(
|
||||
|
||||
@@ -6,7 +6,12 @@ import {
|
||||
setupAuthzGrantByPrefix,
|
||||
} from 'lib/authz/utils/authz-test-utils';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import {
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
import { renderChannels } from './renderChannels';
|
||||
|
||||
@@ -69,7 +74,7 @@ describe('Notification channels list - AuthZ', () => {
|
||||
renderChannels();
|
||||
|
||||
await screen.findByText('Dummy-Channel', {}, FIND);
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await user.click(screen.getByTestId('channel-actions-3'));
|
||||
|
||||
// the label never flips between Edit and View, so it cannot flash the
|
||||
@@ -89,7 +94,7 @@ describe('Notification channels list - AuthZ', () => {
|
||||
renderChannels();
|
||||
|
||||
await screen.findByText('Dummy-Channel', {}, FIND);
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await user.click(screen.getByTestId('channel-actions-3'));
|
||||
|
||||
await expect(
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { setupAuthzAdmin } from 'lib/authz/utils/authz-test-utils';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import {
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
import { renderChannels } from './renderChannels';
|
||||
|
||||
@@ -76,7 +81,7 @@ describe('Notification channels list', () => {
|
||||
|
||||
await screen.findByText('Dummy-Channel', {}, FIND);
|
||||
// the table paints a loading layer over the rows until the fetch settles
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await user.click(screen.getByTestId('channel-actions-3'));
|
||||
// Radix renders the menu into a portal once the trigger is activated
|
||||
await screen.findByRole('menu', {}, FIND);
|
||||
|
||||
@@ -6,7 +6,13 @@ import {
|
||||
} from 'lib/authz/utils/authz-test-utils';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { render, screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import {
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
import ChannelActionsMenu from './ChannelActionsMenu';
|
||||
|
||||
@@ -59,7 +65,7 @@ describe('ChannelActionsMenu - AuthZ', () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await user.click(await screen.findByTestId('channel-actions-3', {}, FIND));
|
||||
|
||||
await screen.findByTestId('channel-actions-3-delete', {}, FIND);
|
||||
@@ -103,7 +109,7 @@ describe('ChannelActionsMenu - AuthZ', () => {
|
||||
});
|
||||
expect(selectors).toHaveLength(0);
|
||||
|
||||
await userEvent.setup({ delay: null }).click(trigger);
|
||||
await userEvent.setup(NO_DELAY_USER_EVENT).click(trigger);
|
||||
|
||||
await waitFor(() => expect(selectors).toContain('3'), FIND);
|
||||
});
|
||||
|
||||
@@ -11,7 +11,14 @@ import { server } from 'mocks-server/server';
|
||||
import { safeNavigateMock } from '__tests__/safeNavigateMock';
|
||||
import { rest } from 'msw';
|
||||
import store from 'store';
|
||||
import { render, screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import {
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
within,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
import AllErrors from '../index';
|
||||
@@ -85,7 +92,7 @@ describe('Exceptions page - run query', () => {
|
||||
};
|
||||
|
||||
it('keeps the filter items in the query when Run Query is clicked', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await renderWithFilter();
|
||||
|
||||
// The button reads Cancel while the list is still fetching.
|
||||
@@ -97,7 +104,7 @@ describe('Exceptions page - run query', () => {
|
||||
});
|
||||
|
||||
it('keeps the filter items in the query on Ctrl+Enter in the search bar', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
await renderWithFilter();
|
||||
|
||||
within(screen.getByTestId('qb-search-select'))
|
||||
|
||||
@@ -289,31 +289,6 @@ export const apiMonitoringMocks = defineStoryMocks({
|
||||
}),
|
||||
),
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v3/autocomplete/attribute_keys',
|
||||
response.json((req) => ({
|
||||
status: 'success',
|
||||
data: {
|
||||
attributeKeys: groupByAttributeKeys(
|
||||
req.url.searchParams.get('searchText') ?? '',
|
||||
),
|
||||
},
|
||||
})),
|
||||
),
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v3/autocomplete/attribute_values',
|
||||
response.json((req) => ({
|
||||
status: 'success',
|
||||
data: {
|
||||
boolAttributeValues: null,
|
||||
numberAttributeValues: null,
|
||||
stringAttributeValues:
|
||||
QUICK_FILTER_VALUES[req.url.searchParams.get('attributeKey') ?? ''] ?? [],
|
||||
},
|
||||
})),
|
||||
),
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v1/fields/keys',
|
||||
response.json((req) =>
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
import { RuletypesRuleTypeDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import ROUTES from 'constants/routes';
|
||||
import { getCreateAlertLink } from 'container/ExplorerActions/utils';
|
||||
import { DEFAULT_PANEL_TYPE } from 'container/LLMObservability/Explorer/constants';
|
||||
import { getAlertQuery } from 'container/LLMObservability/Explorer/explorerUtils';
|
||||
import { rest } from 'msw';
|
||||
import { expect, screen, userEvent, waitFor, within } from 'storybook/test';
|
||||
import { AlertTypes } from 'types/api/alerts/alertTypes';
|
||||
@@ -24,11 +27,12 @@ import {
|
||||
notificationChannelsResponse,
|
||||
CHANNEL_MAX,
|
||||
} from '../../AlertList/stories/__story_mockdata__/alerts';
|
||||
import { aiExplorerQuery } from '../../LLMObservability/Explorer/stories/__story_mockdata__/explorer';
|
||||
|
||||
/**
|
||||
* Which alert the page is building. The page reads this off the URL, so the
|
||||
* control is a route rather than a response: with no type at all it stays on
|
||||
* the picker and everything else opens the form.
|
||||
* control is a route rather than a response: with neither a type nor a query it
|
||||
* stays on the picker and everything else opens the form.
|
||||
*/
|
||||
const ALERT_MODES = [
|
||||
'select-type',
|
||||
@@ -36,6 +40,7 @@ const ALERT_MODES = [
|
||||
'logs',
|
||||
'traces',
|
||||
'ai-traces',
|
||||
'ai-traces-explorer',
|
||||
'exceptions',
|
||||
'anomaly',
|
||||
] as const;
|
||||
@@ -52,6 +57,14 @@ const ALERT_TYPE_BY_MODE: Partial<Record<AlertMode, AlertTypes>> = {
|
||||
};
|
||||
|
||||
const routeFor = (mode: AlertMode): string => {
|
||||
// The AI explorer's Create an alert sends only the query; the page reads the type off it.
|
||||
if (mode === 'ai-traces-explorer') {
|
||||
return getCreateAlertLink({
|
||||
query: getAlertQuery(aiExplorerQuery(), DEFAULT_PANEL_TYPE),
|
||||
panelType: DEFAULT_PANEL_TYPE,
|
||||
});
|
||||
}
|
||||
|
||||
const alertType = ALERT_TYPE_BY_MODE[mode];
|
||||
|
||||
if (!alertType) {
|
||||
|
||||
@@ -59,6 +59,11 @@ export const AITracesAlert: Story = {
|
||||
args: { alertMode: 'ai-traces' },
|
||||
};
|
||||
|
||||
/** Create an alert from the AI explorer: an AI traces alert counting the explorer's query. */
|
||||
export const AITracesAlertFromExplorer: Story = {
|
||||
args: { alertMode: 'ai-traces-explorer' },
|
||||
};
|
||||
|
||||
/**
|
||||
* Anomaly detection: the condition is a number of deviations from the seasonal
|
||||
* forecast instead of a fixed threshold, and only builder metric queries apply.
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import type { DashboardtypesPanelDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import type { PanelQueryData } from 'pages/DashboardPage/DashboardContainer/queryV5/types';
|
||||
import { render, screen, userEvent } from 'tests/test-utils';
|
||||
import {
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
NO_DELAY_USER_EVENT,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
import type { DashboardSection } from '../../../../utils';
|
||||
import PanelActionsMenu from '../PanelActionsMenu';
|
||||
@@ -112,7 +117,8 @@ type User = ReturnType<typeof userEvent.setup>;
|
||||
|
||||
// skipHover: simulated pointer travel fires pointerleave on the subtrigger and
|
||||
// Base UI's safe-polygon math (zero rects in jsdom) closes the submenu.
|
||||
const setupUser = (): User => userEvent.setup({ skipHover: true });
|
||||
const setupUser = (): User =>
|
||||
userEvent.setup({ ...NO_DELAY_USER_EVENT, skipHover: true });
|
||||
|
||||
async function openSubmenu(user: User, value: string): Promise<void> {
|
||||
await user.click(screen.getByTestId(MENU_TEST_ID));
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user