mirror of
https://github.com/SigNoz/signoz.git
synced 2026-11-27 02:30:42 +00:00
Compare commits
24 Commits
perf/uplot
...
fix/flaky-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36b19c06a2 | ||
|
|
215d4f51e4 | ||
|
|
d2a4bed78e | ||
|
|
2e0184d5d1 | ||
|
|
558d95d4df | ||
|
|
899ccd479d | ||
|
|
219ecd1edd | ||
|
|
c5fe5c7231 | ||
|
|
eb41a6652f | ||
|
|
8e13e41366 | ||
|
|
c78c9f7267 | ||
|
|
944bb27ae5 | ||
|
|
53b43d221e | ||
|
|
9c503e67c2 | ||
|
|
d9f0b1da13 | ||
|
|
13535e5143 | ||
|
|
d9f2338a9a | ||
|
|
2bde1fa9e0 | ||
|
|
0552b828fe | ||
|
|
73cd9a1fec | ||
|
|
168dfb3577 | ||
|
|
33519311c5 | ||
|
|
4881edf414 | ||
|
|
e8e448de3a |
@@ -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 that replaces org-wide settings puts them back.** Quick filters, org preferences and similar settings are shared by every spec on the stack. Read what the seed replaces and restore it in the layer's teardown, as `quickFilters.seed` does: `quick-filters/settings` TC-01 once left the logs filters changed, and `query-builder/filter` TC-16 failed later on the same stack. Only the instance that seeded knows what to put back, so a driver that seeds through its own `quickFiltersDriver(page)` keeps that instance and restores it in its own layer's teardown: `logsRail.ensureSeeded` once seeded through a throwaway instance, and the `quickFilters` layer's restore never saw it.
|
||||
- **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/noDelayUserEvent`; 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' }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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,11 +100,7 @@ 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 [input, setInput] = useEditorDraft(having?.expression || '');
|
||||
|
||||
const [isFocused, setIsFocused] = useState(false);
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import {
|
||||
} from 'types/common/queryBuilder';
|
||||
|
||||
import { useQueryBuilderV2Context } from '../../QueryBuilderV2Context';
|
||||
import { useEditorDraft } from '../useEditorDraft';
|
||||
|
||||
import './QueryAggregation.styles.scss';
|
||||
|
||||
@@ -175,14 +176,10 @@ function QueryAggregationSelect({
|
||||
[],
|
||||
);
|
||||
|
||||
const [input, setInput] = useState(
|
||||
const [input, setInput] = useEditorDraft(
|
||||
formatAggregations(queryData?.aggregations),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setInput(formatAggregations(queryData?.aggregations));
|
||||
}, [queryData?.aggregations, formatAggregations]);
|
||||
|
||||
const [cursorPos, setCursorPos] = useState(0);
|
||||
const [functionArgPairs, setFunctionArgPairs] = useState<
|
||||
{ func: string; arg: string }[]
|
||||
|
||||
@@ -9,6 +9,7 @@ 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 { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
import type { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
import DistributionFieldSelect from '../DistributionFieldSelect';
|
||||
@@ -74,7 +75,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 +98,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 +120,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,35 @@
|
||||
import { act, renderHook } from 'tests/test-utils';
|
||||
|
||||
import { useEditorDraft } from '../useEditorDraft';
|
||||
|
||||
function setup(external = ''): {
|
||||
result: { current: ReturnType<typeof useEditorDraft> };
|
||||
rerender: (props: { external: string }) => void;
|
||||
} {
|
||||
return renderHook(
|
||||
({ external: value }: { external: string }) => useEditorDraft(value),
|
||||
{ initialProps: { external } },
|
||||
);
|
||||
}
|
||||
|
||||
describe('useEditorDraft', () => {
|
||||
it('keeps newer typing when an older edit comes back', () => {
|
||||
const { result, rerender } = setup();
|
||||
|
||||
act(() => result.current[1]('count() > 1'));
|
||||
act(() => result.current[1]('count() > 10'));
|
||||
rerender({ external: 'count() > 1' });
|
||||
|
||||
expect(result.current[0]).toBe('count() > 10');
|
||||
});
|
||||
|
||||
it('takes a value set outside the editor', () => {
|
||||
const { result, rerender } = setup('count() > 1');
|
||||
|
||||
act(() => result.current[1]('count() > 10'));
|
||||
rerender({ external: 'count() > 10' });
|
||||
rerender({ external: 'count() < 5' });
|
||||
|
||||
expect(result.current[0]).toBe('count() < 5');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
// Bounds the history when no parent ever echoes the edits back.
|
||||
const MAX_SENT = 200;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export function useEditorDraft(
|
||||
external: string,
|
||||
): [string, (value: string) => void] {
|
||||
const [draft, setDraft] = useState(external);
|
||||
const sent = useRef<string[]>([]);
|
||||
|
||||
// `sent` holds the edits whose echo has not come back yet. 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" sent [c, co, cou] draft "cou"
|
||||
// echo "c" sent [co, cou] ignored, draft stays "cou"
|
||||
// echo "cou" (skipped co) sent [] 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 = sent.current.indexOf(external);
|
||||
if (index === -1) {
|
||||
sent.current = [];
|
||||
setDraft(external);
|
||||
return;
|
||||
}
|
||||
sent.current = sent.current.slice(index + 1);
|
||||
}, [external]);
|
||||
|
||||
const edit = useCallback((value: string): void => {
|
||||
sent.current.push(value);
|
||||
if (sent.current.length > MAX_SENT) {
|
||||
sent.current.shift();
|
||||
}
|
||||
setDraft(value);
|
||||
}, []);
|
||||
|
||||
return [draft, edit];
|
||||
}
|
||||
@@ -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,
|
||||
@@ -18,6 +20,7 @@ import {
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { render, screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
import { TelemetryFieldKey } from 'types/api/v5/queryRange';
|
||||
import { QueryBuilderContextType } from 'types/common/queryBuilder';
|
||||
|
||||
@@ -32,6 +35,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 +59,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 +83,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 +140,7 @@ function renderSettings(): void {
|
||||
<QuickFiltersSettings
|
||||
savedFiltersSource={QuickfiltertypesSourceDTO.logs}
|
||||
setIsSettingsOpen={jest.fn()}
|
||||
customFilters={savedFilters}
|
||||
customFilters={smallSavedFilters}
|
||||
refetchCustomFilters={jest.fn()}
|
||||
/>,
|
||||
);
|
||||
@@ -180,12 +186,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 +201,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 +228,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 +250,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 +280,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 +291,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 +303,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 +335,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 +369,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 +391,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 +443,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 +455,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 +473,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 +496,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 +511,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 +553,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 +655,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 +697,7 @@ describe('Quick Filters refetch behavior', () => {
|
||||
),
|
||||
);
|
||||
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
render(
|
||||
<TestQuickFilters quickFilterSource={QuickFiltersSource.LOGS_EXPLORER} />,
|
||||
);
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
GetQueryResultsProps,
|
||||
} from 'lib/dashboard/getQueryResults';
|
||||
import { render, screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
import { MetricQueryRangeSuccessResponse } from 'types/api/metrics/getQueryRange';
|
||||
|
||||
import EndPointPicker from '../Explorer/Domains/DomainDetails/components/EndPointPicker';
|
||||
@@ -65,7 +66,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 +84,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
|
||||
>;
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
waitFor,
|
||||
within,
|
||||
} from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
import { SPAN_ATTRIBUTES } from '../Explorer/Domains/DomainDetails/constants';
|
||||
@@ -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,7 +1,9 @@
|
||||
import { ComponentProps } from 'react';
|
||||
import { render, screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
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 +16,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 +116,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 +143,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 +166,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 +179,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,12 @@
|
||||
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 { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
jest.mock('@signozhq/ui/toast', () => ({
|
||||
...jest.requireActual('@signozhq/ui/toast'),
|
||||
@@ -40,7 +42,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 +159,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 +183,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 +195,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 +207,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 +228,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 +245,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 +275,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 +304,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 +322,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 +336,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 +361,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 +375,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 +408,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 +417,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 +439,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 +481,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 +499,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 +513,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 +530,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 +591,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 />);
|
||||
|
||||
@@ -5,11 +5,24 @@ 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 { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
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 +34,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 +57,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 +71,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)', () => {
|
||||
@@ -68,8 +89,31 @@ describe('UnpricedModelsTab (integration)', () => {
|
||||
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 +138,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 +163,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 +183,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,5 @@
|
||||
import { screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
import { renderListAlertRules } from './_helpers';
|
||||
|
||||
@@ -16,7 +17,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 +45,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');
|
||||
|
||||
@@ -9,6 +9,7 @@ import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { getCurrentNuqsSearchParams } from 'tests/nuqs-helpers';
|
||||
import { screen, waitFor } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
import { renderListAlertRules } from './_helpers';
|
||||
|
||||
@@ -18,7 +19,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 +50,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 +77,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 +117,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' });
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { screen, waitFor } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
import { getCurrentNuqsQueryString } from 'tests/nuqs-helpers';
|
||||
|
||||
import { renderListAlertRules } from './_helpers';
|
||||
@@ -53,7 +54,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,7 @@
|
||||
import { safeNavigateMock } from '__tests__/safeNavigateMock';
|
||||
import { useAlertRuleViewsStore } from 'container/ListAlertRules/useAlertRuleViewsStore';
|
||||
import { screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
import { renderListAlertRules } from './_helpers';
|
||||
|
||||
@@ -13,7 +14,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 +30,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 +45,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);
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
import {
|
||||
getCurrentNuqsQueryString,
|
||||
getCurrentNuqsSearchParams,
|
||||
@@ -134,7 +135,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 +155,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');
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
waitFor,
|
||||
within,
|
||||
} from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
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));
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
import type { ErrorType } from 'api/generatedAPIInstance';
|
||||
import { mockAppLocation, mockNavigate } from 'tests/router-mocks';
|
||||
import { render, screen, userEvent, within } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
import { USER_ROLES } from 'types/roles';
|
||||
|
||||
import { PlannedDowntime } from '../PlannedDowntime';
|
||||
@@ -240,14 +241,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 +259,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 +276,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 +289,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/noDelayUserEvent';
|
||||
|
||||
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,11 +1,12 @@
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { screen, waitFor } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
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 +31,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 +56,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,5 @@
|
||||
import { screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
import { renderTriggeredAlerts } from './_helpers';
|
||||
|
||||
@@ -13,7 +14,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 +39,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(() =>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { triggeredAlertsPaginationFixture } from 'mocks-server/__mockdata__/trig
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
import { getCurrentNuqsQueryString } from 'tests/nuqs-helpers';
|
||||
|
||||
import { renderTriggeredAlerts } from './_helpers';
|
||||
@@ -50,7 +51,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');
|
||||
|
||||
@@ -4,12 +4,13 @@ import { safeNavigateMock } from '__tests__/safeNavigateMock';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { screen, waitFor } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
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 +36,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 +84,7 @@ describe('TriggeredAlerts — row click', () => {
|
||||
),
|
||||
);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderTriggeredAlerts();
|
||||
|
||||
await waitFor(() =>
|
||||
@@ -125,7 +126,7 @@ describe('TriggeredAlerts — row click', () => {
|
||||
),
|
||||
);
|
||||
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderTriggeredAlerts();
|
||||
|
||||
await waitFor(() =>
|
||||
|
||||
@@ -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>, as the static link was, so uPlot's rules keep winning ties over the app's stylesheets.
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = href;
|
||||
document.body.appendChild(link);
|
||||
@@ -7,6 +7,7 @@ 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 { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
import ChannelForm from '../components/ChannelForm/ChannelForm';
|
||||
|
||||
@@ -51,7 +52,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 +100,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 +151,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 +213,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 +281,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 +330,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 +399,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 +495,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 +532,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 +569,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 +589,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 +664,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 +706,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(
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
} from 'lib/authz/utils/authz-test-utils';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
import { renderChannels } from './renderChannels';
|
||||
|
||||
@@ -69,7 +70,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 +90,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,7 @@
|
||||
import { setupAuthzAdmin } from 'lib/authz/utils/authz-test-utils';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
import { renderChannels } from './renderChannels';
|
||||
|
||||
@@ -76,7 +77,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);
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { render, screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
import ChannelActionsMenu from './ChannelActionsMenu';
|
||||
|
||||
@@ -59,7 +60,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 +104,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);
|
||||
});
|
||||
|
||||
@@ -12,6 +12,7 @@ import { safeNavigateMock } from '__tests__/safeNavigateMock';
|
||||
import { rest } from 'msw';
|
||||
import store from 'store';
|
||||
import { render, screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
import AllErrors from '../index';
|
||||
@@ -85,7 +86,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 +98,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'))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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 { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
import type { DashboardSection } from '../../../../utils';
|
||||
import PanelActionsMenu from '../PanelActionsMenu';
|
||||
@@ -112,7 +113,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));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { render } from '@testing-library/react';
|
||||
import { screen, userEvent } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
import type { ReactElement } from 'react';
|
||||
import { QueryClient, QueryClientProvider } from 'react-query';
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
@@ -223,7 +224,7 @@ const renderHarness = (): void => {
|
||||
// the field values these never recover from a context swap that lands after mount.
|
||||
describe('View modal, builder add-on rows', () => {
|
||||
it('shows the opened panel add-ons, not the previous panel ones', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderHarness();
|
||||
|
||||
await user.click(screen.getByTestId('open-grouped'));
|
||||
@@ -237,7 +238,7 @@ describe('View modal, builder add-on rows', () => {
|
||||
});
|
||||
|
||||
it('shows add-ons the opened panel has after a panel without them', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderHarness();
|
||||
|
||||
await user.click(screen.getByTestId('open-plain'));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { render } from '@testing-library/react';
|
||||
import { screen, userEvent } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
import type { ReactElement } from 'react';
|
||||
import { QueryClient, QueryClientProvider } from 'react-query';
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
@@ -157,7 +158,7 @@ const renderHarness = (): void => {
|
||||
|
||||
describe('View modal, PromQL panels', () => {
|
||||
it('shows the opened panel query, not the previously viewed one', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderHarness();
|
||||
|
||||
await user.click(screen.getByTestId('open-a'));
|
||||
|
||||
@@ -23,6 +23,9 @@ import {
|
||||
updateTaggedAccount,
|
||||
} from './CloudIntegration.stories.mocks';
|
||||
import {
|
||||
closePendingAwsSetup,
|
||||
closePendingAzureSetup,
|
||||
closePendingGcpSetup,
|
||||
openAccountSelect,
|
||||
openAccountSettings,
|
||||
openConnectDialog,
|
||||
@@ -285,13 +288,7 @@ export const AwsAgentConnectionError: Story = {
|
||||
*/
|
||||
export const AwsAgentCloseConfirm: Story = {
|
||||
args: { accounts: 0, newAccountCheckIn: 'pending' },
|
||||
play: async ({ canvasElement }): Promise<void> => {
|
||||
await connectAwsAccount(canvasElement);
|
||||
await userEvent.click(
|
||||
await screen.findByTestId('aws-cancel-btn', undefined, untilLoaded),
|
||||
);
|
||||
await screen.findByTestId('aws-close-setup-btn', undefined, untilLoaded);
|
||||
},
|
||||
play: closePendingAwsSetup,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -329,13 +326,7 @@ export const AzureAgentConnectionError: Story = {
|
||||
*/
|
||||
export const AzureAgentCloseConfirm: Story = {
|
||||
args: { provider: 'azure', accounts: 0, newAccountCheckIn: 'pending' },
|
||||
play: async ({ canvasElement }): Promise<void> => {
|
||||
await connectAzureAccount(canvasElement);
|
||||
await userEvent.click(
|
||||
await screen.findByTestId('azure-cancel-btn', undefined, untilLoaded),
|
||||
);
|
||||
await screen.findByTestId('azure-close-setup-btn', undefined, untilLoaded);
|
||||
},
|
||||
play: closePendingAzureSetup,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -417,13 +408,7 @@ export const GcpAgentConnectionError: Story = {
|
||||
*/
|
||||
export const GcpAgentCloseConfirm: Story = {
|
||||
args: { provider: 'gcp', accounts: 0, newAccountCheckIn: 'pending' },
|
||||
play: async ({ canvasElement }): Promise<void> => {
|
||||
await generateGcpAgentCommand(canvasElement);
|
||||
await userEvent.click(
|
||||
await screen.findByTestId('gcp-cancel-btn', undefined, untilLoaded),
|
||||
);
|
||||
await screen.findByTestId('gcp-close-setup-btn', undefined, untilLoaded);
|
||||
},
|
||||
play: closePendingGcpSetup,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,9 @@ import { screen, userEvent } from 'storybook/test';
|
||||
|
||||
import {
|
||||
type CloudIntegrationArgs,
|
||||
connectAwsAccount,
|
||||
connectAzureAccount,
|
||||
generateGcpAgentCommand,
|
||||
offersIntegrateNow,
|
||||
openConnectFlow,
|
||||
openEditAccount,
|
||||
@@ -105,3 +108,52 @@ export const openDisconnectConfirm = async ({
|
||||
);
|
||||
blurActiveElement();
|
||||
};
|
||||
|
||||
/**
|
||||
* Cancel closes the drawer outright until the setup command exists, so the play
|
||||
* waits for the command before it asks to leave.
|
||||
*/
|
||||
const confirmClosingPendingSetup = async (
|
||||
provider: 'aws' | 'azure' | 'gcp',
|
||||
args: CloudIntegrationArgs,
|
||||
): Promise<void> => {
|
||||
if (
|
||||
args.accountCreate !== 'success' ||
|
||||
args.newAccountCheckIn === 'checked-in'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
await screen.findByTestId(`${provider}-agent-command`, undefined, untilLoaded);
|
||||
await userEvent.click(
|
||||
await screen.findByTestId(`${provider}-cancel-btn`, undefined, untilLoaded),
|
||||
);
|
||||
await screen.findByTestId(
|
||||
`${provider}-close-setup-btn`,
|
||||
undefined,
|
||||
untilLoaded,
|
||||
);
|
||||
};
|
||||
|
||||
export const closePendingAwsSetup = async ({
|
||||
canvasElement,
|
||||
args,
|
||||
}: PlayContext): Promise<void> => {
|
||||
await connectAwsAccount(canvasElement);
|
||||
await confirmClosingPendingSetup('aws', args);
|
||||
};
|
||||
|
||||
export const closePendingAzureSetup = async ({
|
||||
canvasElement,
|
||||
args,
|
||||
}: PlayContext): Promise<void> => {
|
||||
await connectAzureAccount(canvasElement);
|
||||
await confirmClosingPendingSetup('azure', args);
|
||||
};
|
||||
|
||||
export const closePendingGcpSetup = async ({
|
||||
canvasElement,
|
||||
args,
|
||||
}: PlayContext): Promise<void> => {
|
||||
await generateGcpAgentCommand(canvasElement);
|
||||
await confirmClosingPendingSetup('gcp', args);
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@ import { screen, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import ROUTES from 'constants/routes';
|
||||
import { render } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
import { SpanV3 } from 'types/api/trace/getTraceV3';
|
||||
|
||||
import { SpanDetailVariant } from '../constants';
|
||||
@@ -154,7 +155,7 @@ describe('SpanDetailsPanel – span summary', () => {
|
||||
|
||||
describe('SpanDetailsPanel – tabs', () => {
|
||||
it('shows Overview by default and switches content on tab change', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderPanel(400);
|
||||
|
||||
// Overview active by default.
|
||||
@@ -203,7 +204,7 @@ describe('SpanDetailsPanel – Open in Logs Explorer footer', () => {
|
||||
});
|
||||
|
||||
it('appears only while the Logs tab is active', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderPanel(400);
|
||||
|
||||
expect(
|
||||
@@ -220,7 +221,7 @@ describe('SpanDetailsPanel – Open in Logs Explorer footer', () => {
|
||||
});
|
||||
|
||||
it('opens Logs Explorer in a new tab filtered to the span trace when clicked', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderPanel(400);
|
||||
|
||||
await user.click(screen.getByRole('tab', { name: /logs/i }));
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { SpantypesGettableTraceSummaryDTO } from 'api/generated/services/si
|
||||
import { NuqsTestingAdapter } from 'nuqs/adapters/testing';
|
||||
import ROUTES from 'constants/routes';
|
||||
import { fireEvent, render, screen, userEvent } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
import { TraceDetailsTab } from '../../constants';
|
||||
import { TraceDetailEvents } from '../../events';
|
||||
@@ -99,7 +100,7 @@ describe('TraceDetailsHeader – back button', () => {
|
||||
|
||||
it('pushes to the AI observability explorer when opened directly on another tab', async () => {
|
||||
mockHasInAppHistory.mockReturnValue(false);
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
render(
|
||||
<NuqsTestingAdapter searchParams="?tab=thread">
|
||||
<TraceDetailsHeader {...baseProps} />
|
||||
@@ -296,7 +297,7 @@ describe('TraceDetailsHeader – trace metadata row', () => {
|
||||
});
|
||||
|
||||
it('is shown by default and can be hidden / shown again via the Trace options menu', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
mockSummary(traceMetadata);
|
||||
render(<TraceDetailsHeader {...baseProps} showTraceDetailsHeaderOptions />);
|
||||
|
||||
@@ -365,7 +366,7 @@ describe('TraceDetailsHeader – tabs', () => {
|
||||
});
|
||||
|
||||
it('keeps only the metadata row on the Thread tab', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderHeader();
|
||||
|
||||
await user.click(screen.getByTestId('trace-details-tab-thread'));
|
||||
@@ -380,7 +381,7 @@ describe('TraceDetailsHeader – tabs', () => {
|
||||
});
|
||||
|
||||
it('shows the metadata row on the Thread tab even when hidden on Overview', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderHeader();
|
||||
|
||||
await user.click(screen.getByTestId('trace-options-button'));
|
||||
@@ -414,7 +415,7 @@ describe('TraceDetailsHeader – tabs', () => {
|
||||
});
|
||||
|
||||
it('clears the filter result when switching to the Thread tab', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderHeader();
|
||||
baseProps.onFilteredSpansChange.mockClear();
|
||||
|
||||
@@ -424,7 +425,7 @@ describe('TraceDetailsHeader – tabs', () => {
|
||||
});
|
||||
|
||||
it('closes the Analytics panel when switching to the Thread tab', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderHeader();
|
||||
|
||||
await user.click(screen.getByTestId('trace-analytics-button'));
|
||||
@@ -442,7 +443,7 @@ describe('TraceDetailsHeader – tabs', () => {
|
||||
});
|
||||
|
||||
it('logs the tab change with the previous and next tab', async () => {
|
||||
const user = userEvent.setup({ delay: null });
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
renderHeader();
|
||||
jest.mocked(logEvent).mockClear();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import userEvent from '@testing-library/user-event';
|
||||
import { fetchExportData } from 'api/v1/download/downloadExportData';
|
||||
import { downloadFile } from 'lib/exportData/downloadFile';
|
||||
import { render } from 'tests/test-utils';
|
||||
import { NO_DELAY_USER_EVENT } from 'tests/noDelayUserEvent';
|
||||
|
||||
import TraceDownloadPanel from '../TraceDownloadPanel';
|
||||
import TraceOptionsMenu from '../TraceOptionsMenu';
|
||||
@@ -52,7 +53,7 @@ function renderFeature(
|
||||
// Base UI's safe-polygon math (zero rects in jsdom) closes the submenu.
|
||||
function setupUser(): ReturnType<typeof userEvent.setup> {
|
||||
return userEvent.setup({
|
||||
delay: null,
|
||||
...NO_DELAY_USER_EVENT,
|
||||
skipHover: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ The full list is [`.claude/rules/frontend-tests.md`](../../../.claude/rules/fron
|
||||
|
||||
- Import from `tests/test-utils` only.
|
||||
- Prefer `userEvent` for real interactions; use `fireEvent` only for low-level events (scroll/resize/setting `scrollTop`).
|
||||
- `userEvent.setup(NO_DELAY_USER_EVENT)` (from `tests/noDelayUserEvent`) skips the timer wait after each key and click; `user.paste` long values. Keep the default delay when the test checks what happens between two actions (a debounce per key).
|
||||
- One behaviour per test, rendering the smallest component that owns it; each test under 500 ms (`pnpm jest <file> --verbose`).
|
||||
- Never call `*ByRole` inside `waitFor`; never raise a timeout to make a slow test pass.
|
||||
- Use MSW to mock network calls; large JSON goes in `mocks-server/__mockdata__`.
|
||||
|
||||
10
frontend/src/tests/noDelayUserEvent.ts
Normal file
10
frontend/src/tests/noDelayUserEvent.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import type userEvent from '@testing-library/user-event';
|
||||
|
||||
type SetupOptions = NonNullable<Parameters<typeof userEvent.setup>[0]>;
|
||||
|
||||
// The default `delay: 0` still awaits a timer after every key and click.
|
||||
// Keep it when a test checks what happens between two actions, such as a
|
||||
// debounce per key: with `null` that code runs only after the whole action.
|
||||
export const NO_DELAY_USER_EVENT = {
|
||||
delay: null,
|
||||
} as const satisfies SetupOptions;
|
||||
@@ -133,6 +133,30 @@ uses the same layout: `k8s.namespace.name` came out as `8s.namespace.namek`.
|
||||
the expression, and the colour checks use `toHaveCSS`, which retries, instead
|
||||
of a fixed wait for the highlighter.
|
||||
|
||||
The query builder driver's `editorAt(...).type` does not retype, so
|
||||
`qb.openExplorer` waits for the scrollbar viewport, as
|
||||
`tracesExplorerDriver.goto` does.
|
||||
|
||||
## The having and aggregation editors dropped keys
|
||||
|
||||
Both editors copied the query state back into CodeMirror after every edit. When
|
||||
that copy arrived late it held an older text, replaced the newer typing and
|
||||
moved the caret to the start: `count() NOT IN [1, 2]` was sent as
|
||||
`, 2]count() NOT IN []`, and `count_distinct(service.name)` as
|
||||
`count_distinct(service)`. After #13735 removed a re-render from the quick
|
||||
filter headers, the copy arrived late often enough to fail `addons` TC-22 and
|
||||
`aggregation` TC-17 on most CI runs. `useEditorDraft` now ignores the copies of
|
||||
the editor's own edits. Keys typed while the traces explorer loads could still
|
||||
go missing (`count()` as `c()`), so `editorAt(...).type` retypes until the
|
||||
editor holds exactly the text, like `querySearch.apply`.
|
||||
|
||||
## Run after a cancel re-sends the cancelled query
|
||||
|
||||
Since #13735, clicking Run in the logs explorer after a cancel first re-sends
|
||||
the cancelled query, aborts it, then sends the new one. `qb.run()` returned on
|
||||
the aborted request, so `run` TC-34 read the old filter. `firedBy` now waits
|
||||
for a request that gets a response.
|
||||
|
||||
## Typing an expression logs parser errors
|
||||
|
||||
`parser/analyzeQuery.ts` builds an ANTLR parser without removing the default
|
||||
@@ -276,3 +300,89 @@ The health check button passes `loading` to an antd 5.11 `Button` while the
|
||||
three onboarding status queries fetch, and a loading antd button ignores clicks
|
||||
without being disabled, so Playwright clicks it and nothing opens.
|
||||
`openHealthCheck` clicks again until the dialog shows.
|
||||
|
||||
## A route handler still fetching when the context closes fails a passed test
|
||||
|
||||
`onboarding/redirect` TC-06 failed its first attempt in 7 of 40 CI jobs with
|
||||
`route.fetch: Target page, context or browser has been closed`. `stubFirstRun`
|
||||
answers `/api/v2/users` through `route.fetch()`; a request that lands as the
|
||||
test ends is still inside the handler when `authedPage` closes its context, and
|
||||
Playwright reports the rejection against the test. `authedPage` and `guestPage`
|
||||
now call `unrouteAll({ behavior: 'ignoreErrors' })` before closing, which covers
|
||||
every spec that fetches inside a handler. A spec that fires five page fetches at
|
||||
`/api/v2/users` and ends failed 10 of 15 runs before and 0 of 15 after; TC-06
|
||||
itself failed 1 of 30 locally before and 0 of 30 after.
|
||||
|
||||
## The release-changelog CMS is blocked in the browser
|
||||
|
||||
`AppLayout` asks `cms.signoz.cloud` for the changelog on every logged-in page
|
||||
load. When that request fails with a CORS or network error the console gets two
|
||||
errors, which failed `query-builder/url` TC-03 once in the merge queue. The
|
||||
chromium project now fails its DNS the same way it does for Google Fonts, so no
|
||||
spec depends on an external service: a `/home` load logs no console error and the
|
||||
request fails with `ERR_NAME_NOT_RESOLVED`, where before it reached the CMS.
|
||||
|
||||
## Services overview 400s were a product race, fixed on main
|
||||
|
||||
`services/list` TC-02 and `services/detail` TC-04 asserted a clean network and
|
||||
saw `400 POST /api/v5/query_range` in 26 of 45 shard-10 CI jobs between
|
||||
2026-11-17 and 2026-11-25; ten of them failed all three attempts. `WidgetCard`
|
||||
kept a copy of its query in state and refreshed it one render late, so when the
|
||||
top-level operations arrived the latency chart first sent the previous query with
|
||||
`name in []`. [#13722](https://github.com/SigNoz/signoz/pull/13722) sends the
|
||||
widget query directly. The specs needed no change: the six runs after it (60
|
||||
jobs) had no such 400, and a pinned local shard 10 passes. Do not widen
|
||||
`withoutMissingMetadata` to hide a 400 on `query_range`.
|
||||
|
||||
## wheelTo retries a wheel the page drops
|
||||
|
||||
`alerts/create` TC-08, TC-10 and TC-11 failed with "the wheel did not move the
|
||||
target" in 5 of 39 shard-1 jobs, always at the same row position, so the event
|
||||
was dropped rather than the layout clipped. `wheelTo` sent one wheel and polled
|
||||
for 2 s. It now sends the wheel again every second for up to 6 s; a genuinely
|
||||
clipped container still fails with the same message. It could not be reproduced
|
||||
locally in 24 runs at 4x CPU throttle.
|
||||
|
||||
## Escape after a multiple combobox pick can close the dialog around it
|
||||
|
||||
`onboarding/get-started` TC-09 failed its first attempt in 3 of about 50 shard-6
|
||||
CI jobs, and 1 of 40 local runs, with the role trigger still `aria-expanded="true"`
|
||||
for a moment and then "element(s) not found". The role select is multiple, so it
|
||||
stays open after a pick and `comboboxAt().pick` pressed Escape. When that Escape
|
||||
also reached the invite modal, the modal closed, and a loop that pressed Escape
|
||||
again closed the whole Get Started page (the failure screenshot shows `/home`).
|
||||
`pick` now toggles the combobox shut with a click near the right edge of its
|
||||
trigger, where the chevron sits. 1 of 40 local runs failed before and 0 of 120 after; an Escape loop
|
||||
failed 1 of 15 and was dropped.
|
||||
|
||||
## A spec that rewrites org settings must put them back
|
||||
|
||||
`quick-filters/settings` TC-01 replaces the org's logs quick filters with two
|
||||
fields and never restored them, so every later spec on that stack lost the
|
||||
Severity Text filter. `query-builder/filter` TC-16 then failed all three
|
||||
attempts, with a 60 s timeout on `checkbox-Severity Text-ERROR`. CI never saw it
|
||||
because the two specs land in different shards (7 and 8) and each shard has its
|
||||
own stack; one test more or fewer before them would put both on one stack. The
|
||||
`quickFilters` layer now reads the stored filters through
|
||||
`/api/v2/quick_filters/{source}` before `seed` replaces them and writes them back
|
||||
after the test. On a stack left in that state, TC-16 failed 2 of 2 before and
|
||||
passed 3 of 3 after. `logs-explorer/quick-filters` seeds the same filters
|
||||
through `logsRail.ensureSeeded`, which used its own driver instance, so the
|
||||
`logsRail` layer restores that instance too.
|
||||
|
||||
## Chrome's compute-pressure policy message is console noise
|
||||
|
||||
`Permissions policy violation: compute-pressure is not allowed in this document.`
|
||||
reached the console of the logs pipelines page twice, once in CI
|
||||
(`app-shell/routes` TC-06) and once locally (`logs-pipelines` TC-01, which
|
||||
retried the whole serial group). It names no source, so `HARNESS_CONSOLE_NOISE`
|
||||
drops it.
|
||||
|
||||
## Run the suite shard by shard
|
||||
|
||||
A single 560-test pass on one stack failed `dashboards/page/variables` TC-03 and
|
||||
`query-builder/url` TC-05 late in the run; both passed when their shard ran on a
|
||||
freshly seeded stack. The likely cause is the golden dataset, which `global.setup`
|
||||
rebases to the moment it runs: its newest log is 15 minutes old and its newest
|
||||
span 30, so a spec that reads it through a short window only sees it for a while
|
||||
after the seed. Reproduce CI with `--shard=N/10` per shard, not with one long run.
|
||||
|
||||
20
tests/e2e/drivers/combobox.ts
generated
20
tests/e2e/drivers/combobox.ts
generated
@@ -25,10 +25,22 @@ export function comboboxAt(page: Page, trigger: Locator): Combobox {
|
||||
});
|
||||
await popup.locator('[data-slot="combobox-search-input"]').fill(label);
|
||||
await popup.getByRole('option', { name: label, exact: true }).click();
|
||||
if ((await trigger.getAttribute('aria-expanded')) === 'true') {
|
||||
await page.keyboard.press('Escape');
|
||||
}
|
||||
await expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
||||
// A multiple combobox stays open after a pick. Escape can also close the
|
||||
// dialog around it, so toggle it shut from its chevron instead.
|
||||
await expect(async () => {
|
||||
if ((await trigger.getAttribute('aria-expanded')) === 'true') {
|
||||
const box = await trigger.boundingBox();
|
||||
await trigger.click({
|
||||
position: {
|
||||
x: Math.max(1, (box?.width ?? 24) - 12),
|
||||
y: (box?.height ?? 2) / 2,
|
||||
},
|
||||
});
|
||||
}
|
||||
await expect(trigger).toHaveAttribute('aria-expanded', 'false', {
|
||||
timeout: 2_000,
|
||||
});
|
||||
}).toPass({ timeout: 10_000 });
|
||||
},
|
||||
async clear() {
|
||||
const removers = trigger.locator('[data-slot="combobox-chip-remove"]');
|
||||
|
||||
2
tests/e2e/drivers/console.ts
generated
2
tests/e2e/drivers/console.ts
generated
@@ -29,6 +29,8 @@ const HARNESS_CONSOLE_NOISE = [
|
||||
'ErrorResponseHandler: unclassified error',
|
||||
// Google Fonts, which the chromium project fails at DNS (playwright.config.ts).
|
||||
'Failed to load resource: net::ERR_NAME_NOT_RESOLVED',
|
||||
// Chrome's own report of a blocked Compute Pressure observer; it names no source.
|
||||
'Permissions policy violation: compute-pressure is not allowed in this document.',
|
||||
];
|
||||
|
||||
export interface ConsoleWatch {
|
||||
|
||||
30
tests/e2e/drivers/explorers.ts
generated
30
tests/e2e/drivers/explorers.ts
generated
@@ -43,6 +43,8 @@ export interface QuickFilters {
|
||||
signal: QuickFilterSignal,
|
||||
filters?: QuickFilterDefinition[],
|
||||
): Promise<void>;
|
||||
/** Put back what `seed` replaced; the layer runs it after every test. */
|
||||
restore(): Promise<void>;
|
||||
/** Hide the one-off announcement tooltip so it cannot swallow the gear click. */
|
||||
dismissAnnouncement(): Promise<void>;
|
||||
gotoExplorer(path: string): Promise<void>;
|
||||
@@ -62,17 +64,35 @@ export function quickFiltersDriver(page: Page): QuickFilters {
|
||||
.filter({ hasText: SETTINGS_PANEL_TITLE });
|
||||
const gearContainer = (): Locator => page.getByTestId(SETTINGS_ICON_CONTAINER);
|
||||
|
||||
const replaced = new Map<QuickFilterSignal, unknown[]>();
|
||||
|
||||
const filters: QuickFilters = {
|
||||
rail: () => page.locator('.quick-filters'),
|
||||
settingsPanel: panel,
|
||||
|
||||
seed: async (signal, definitions = DEFAULT_CUSTOM_FILTERS) => {
|
||||
await apiDriver(page).put('/api/v1/orgs/me/filters', {
|
||||
const api = apiDriver(page);
|
||||
if (!replaced.has(signal)) {
|
||||
const stored = await api.get<{ data: { filters: unknown[] } }>(
|
||||
`/api/v2/quick_filters/${signal}`,
|
||||
);
|
||||
replaced.set(signal, stored.data.filters);
|
||||
}
|
||||
await api.put('/api/v1/orgs/me/filters', {
|
||||
signal,
|
||||
filters: definitions,
|
||||
});
|
||||
},
|
||||
|
||||
restore: async () => {
|
||||
const api = apiDriver(page);
|
||||
for (const [signal, stored] of replaced) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await api.put(`/api/v2/quick_filters/${signal}`, { filters: stored });
|
||||
}
|
||||
replaced.clear();
|
||||
},
|
||||
|
||||
dismissAnnouncement: () => dismissQuickFiltersAnnouncement(page),
|
||||
|
||||
gotoExplorer: async (path) => {
|
||||
@@ -192,9 +212,11 @@ export const withExplorers: Layer<{
|
||||
editor: QueryEditor;
|
||||
}> = (base) =>
|
||||
driver('editor', ({ page }) => queryEditorDriver(page))(
|
||||
driver('quickFilters', ({ page }) => quickFiltersDriver(page))(
|
||||
driver('logs', ({ page }) => logsExplorerDriver(page))(base),
|
||||
),
|
||||
driver(
|
||||
'quickFilters',
|
||||
({ page }) => quickFiltersDriver(page),
|
||||
(quickFilters) => quickFilters.restore(),
|
||||
)(driver('logs', ({ page }) => logsExplorerDriver(page))(base)),
|
||||
);
|
||||
|
||||
/** The explorers `test`. */
|
||||
|
||||
4
tests/e2e/drivers/kit.ts
generated
4
tests/e2e/drivers/kit.ts
generated
@@ -320,6 +320,7 @@ export const kit = base.extend<
|
||||
const ctx = await browser.newContext({ baseURL });
|
||||
const page = await ctx.newPage();
|
||||
await use(page);
|
||||
await page.unrouteAll({ behavior: 'ignoreErrors' });
|
||||
await ctx.close();
|
||||
},
|
||||
|
||||
@@ -349,6 +350,9 @@ export const kit = base.extend<
|
||||
});
|
||||
}
|
||||
await use(page);
|
||||
// A handler still inside `route.fetch` when the context closes would
|
||||
// otherwise fail an already-passed test.
|
||||
await page.unrouteAll({ behavior: 'ignoreErrors' });
|
||||
await ctx.close();
|
||||
},
|
||||
|
||||
|
||||
6
tests/e2e/drivers/logs/index.ts
generated
6
tests/e2e/drivers/logs/index.ts
generated
@@ -12,7 +12,11 @@ export const withLogs: Layer<{
|
||||
pipelines: Pipelines;
|
||||
logsRail: LogsRail;
|
||||
}> = (base) =>
|
||||
driver('logsRail', ({ page }) => logsRailDriver(page))(
|
||||
driver(
|
||||
'logsRail',
|
||||
({ page }) => logsRailDriver(page),
|
||||
(logsRail) => logsRail.restore(),
|
||||
)(
|
||||
driver('pipelines', ({ page }) => pipelinesDriver(page))(
|
||||
driver('views', ({ page }) => logsViewsDriver(page))(
|
||||
driver('logs', ({ page }) => logsExplorerDriver(page))(base),
|
||||
|
||||
9
tests/e2e/drivers/logs/rail.ts
generated
9
tests/e2e/drivers/logs/rail.ts
generated
@@ -9,15 +9,20 @@ import { SEEDED_DATA_TIMEOUT } from '../kit';
|
||||
export interface LogsRail {
|
||||
/** The same payload the settings spec seeds, so parallel seeding agrees. */
|
||||
ensureSeeded(): Promise<void>;
|
||||
/** Put back what `ensureSeeded` replaced; the layer runs it after every test. */
|
||||
restore(): Promise<void>;
|
||||
section(key: string): Locator;
|
||||
/** Filter the list to `value` only, through the value row's Only action. */
|
||||
only(key: string, value: string): Promise<void>;
|
||||
}
|
||||
|
||||
export function logsRailDriver(page: Page): LogsRail {
|
||||
const quickFilters = quickFiltersDriver(page);
|
||||
|
||||
const rail: LogsRail = {
|
||||
ensureSeeded: () =>
|
||||
quickFiltersDriver(page).seed('logs', DEFAULT_CUSTOM_FILTERS),
|
||||
ensureSeeded: () => quickFilters.seed('logs', DEFAULT_CUSTOM_FILTERS),
|
||||
|
||||
restore: () => quickFilters.restore(),
|
||||
|
||||
section: (key) => page.locator(`[data-filter-key="${key}"]`),
|
||||
|
||||
|
||||
40
tests/e2e/drivers/query-builder.ts
generated
40
tests/e2e/drivers/query-builder.ts
generated
@@ -40,16 +40,44 @@ function queryBuilderDriver(page: Page): QueryBuilderDriver {
|
||||
|
||||
// Waits on a request the action started: a response to one already in
|
||||
// flight (e.g. after a structural edit) would end the wait too early.
|
||||
// An aborted request has no response and does not count: Run after a
|
||||
// cancel re-sends the cancelled query and aborts it for the new one.
|
||||
const firedBy = async (action: () => Promise<void>): Promise<V5Body[]> => {
|
||||
const before = bodies.length;
|
||||
const answered = page
|
||||
.waitForRequest((r) => isQueryRange(r.url()) && r.method() === 'POST')
|
||||
.then((request) => request.response());
|
||||
await action();
|
||||
await answered;
|
||||
let onRequest: (request: Request) => void = () => undefined;
|
||||
const answered = new Promise<void>((resolve) => {
|
||||
onRequest = (request): void => {
|
||||
if (!isQueryRange(request.url()) || request.method() !== 'POST') {
|
||||
return;
|
||||
}
|
||||
void request.response().then((response) => {
|
||||
if (response) {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
page.on('request', onRequest);
|
||||
try {
|
||||
await action();
|
||||
await answered;
|
||||
} finally {
|
||||
page.off('request', onRequest);
|
||||
}
|
||||
return bodies.slice(before);
|
||||
};
|
||||
|
||||
// Every explorer's content pane has a scrollbar that initialises on idle
|
||||
// and re-parents the query editors. Keys typed across that move land at
|
||||
// position 0.
|
||||
const scrollbarSettled = async (): Promise<void> => {
|
||||
await expect(
|
||||
page
|
||||
.getByTestId('quick-filters-layout-content')
|
||||
.locator('[data-overlayscrollbars-viewport]'),
|
||||
).toBeAttached();
|
||||
};
|
||||
|
||||
const qb: QueryBuilderDriver = {
|
||||
async openExplorer(path, { query, raw, view } = {}) {
|
||||
await dismissQuickFiltersAnnouncement(page);
|
||||
@@ -74,12 +102,14 @@ function queryBuilderDriver(page: Page): QueryBuilderDriver {
|
||||
page.goto(url),
|
||||
]);
|
||||
await expect(qb.query('A').filter.content()).toBeVisible();
|
||||
await scrollbarSettled();
|
||||
return [];
|
||||
}
|
||||
const fired = await firedBy(async () => {
|
||||
await page.goto(url);
|
||||
});
|
||||
await expect(qb.query('A').filter.content()).toBeVisible();
|
||||
await scrollbarSettled();
|
||||
return fired;
|
||||
},
|
||||
query(name) {
|
||||
|
||||
10
tests/e2e/drivers/query-builder/editor.ts
generated
10
tests/e2e/drivers/query-builder/editor.ts
generated
@@ -26,8 +26,14 @@ export function editorAt(page: Page, root: () => Locator): FilterEditor {
|
||||
root,
|
||||
content,
|
||||
async type(text) {
|
||||
await editor.clear();
|
||||
await page.keyboard.type(text);
|
||||
// Keys typed while the explorer settles can be lost or land at
|
||||
// position 0 (`count()` came out `c()`), so retype until the editor
|
||||
// holds exactly the text.
|
||||
await expect(async () => {
|
||||
await editor.clear();
|
||||
await page.keyboard.type(text);
|
||||
await expect.poll(() => EDITOR_DOC(root()), { timeout: 1_000 }).toBe(text);
|
||||
}).toPass({ timeout: 15_000 });
|
||||
},
|
||||
async append(text) {
|
||||
await content().click();
|
||||
|
||||
19
tests/e2e/drivers/scroll.ts
generated
19
tests/e2e/drivers/scroll.ts
generated
@@ -32,15 +32,16 @@ export async function wheelTo(target: Locator): Promise<void> {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await page.mouse.move(next.x, next.y);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await page.mouse.wheel(next.deltaX, next.deltaY);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await expect
|
||||
.poll(position, {
|
||||
message:
|
||||
'the wheel did not move the target: a container clips it instead of scrolling',
|
||||
timeout: 2_000,
|
||||
})
|
||||
.not.toBe(before);
|
||||
await expect(async () => {
|
||||
await page.mouse.wheel(next.deltaX, next.deltaY);
|
||||
await expect
|
||||
.poll(position, {
|
||||
message:
|
||||
'the wheel did not move the target: a container clips it instead of scrolling',
|
||||
timeout: 1_000,
|
||||
})
|
||||
.not.toBe(before);
|
||||
}).toPass({ timeout: 6_000, intervals: [0] });
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await target.evaluate(settled);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,11 @@ export default defineConfig({
|
||||
// Google Fonts CSS blocks the app script and `load` until it settles,
|
||||
// so a stalled request blanks the page. Failing DNS settles it at once;
|
||||
// a `route` would too, but routing turns off the HTTP cache.
|
||||
args: ['--host-resolver-rules=MAP fonts.googleapis.com ~NOTFOUND'],
|
||||
// The release-changelog CMS is external; a CORS or network failure on
|
||||
// it logs a console error in whichever spec asserts a clean console.
|
||||
args: [
|
||||
'--host-resolver-rules=MAP fonts.googleapis.com ~NOTFOUND, MAP cms.signoz.cloud ~NOTFOUND',
|
||||
],
|
||||
},
|
||||
},
|
||||
dependencies: ['setup'],
|
||||
|
||||
11
tests/fixtures/http.py
vendored
11
tests/fixtures/http.py
vendored
@@ -18,6 +18,13 @@ from fixtures.logger import setup_logger
|
||||
logger = setup_logger(__name__)
|
||||
|
||||
|
||||
class PatientWireMockContainer(WireMockContainer):
|
||||
# The stock check gives the JVM 10 one-second pings and its failure is not
|
||||
# retried, which a loaded CI runner can outlast.
|
||||
def server_running(self, retry_count: int = 60, retry_delay: int = 1) -> bool:
|
||||
return super().server_running(retry_count=retry_count, retry_delay=retry_delay)
|
||||
|
||||
|
||||
@pytest.fixture(name="zeus", scope="package")
|
||||
def zeus(
|
||||
network: Network,
|
||||
@@ -26,7 +33,7 @@ def zeus(
|
||||
) -> types.TestContainerDocker:
|
||||
|
||||
def create() -> types.TestContainerDocker:
|
||||
container = WireMockContainer(image="wiremock/wiremock:2.35.1-1", secure=False)
|
||||
container = PatientWireMockContainer(image="wiremock/wiremock:2.35.1-1", secure=False)
|
||||
container.with_network(network)
|
||||
container.start()
|
||||
|
||||
@@ -75,7 +82,7 @@ def gateway(
|
||||
) -> types.TestContainerDocker:
|
||||
|
||||
def create() -> types.TestContainerDocker:
|
||||
container = WireMockContainer(image="wiremock/wiremock:2.35.1-1", secure=False)
|
||||
container = PatientWireMockContainer(image="wiremock/wiremock:2.35.1-1", secure=False)
|
||||
container.with_exposed_ports(8080)
|
||||
container.with_network(network)
|
||||
container.start()
|
||||
|
||||
2
tests/fixtures/signoz.py
vendored
2
tests/fixtures/signoz.py
vendored
@@ -130,7 +130,7 @@ def create_signoz(
|
||||
container.start()
|
||||
|
||||
def ready(container: DockerContainer) -> None:
|
||||
for attempt in range(10):
|
||||
for attempt in range(60):
|
||||
try:
|
||||
response = requests.get(
|
||||
f"http://{container.get_container_host_ip()}:{container.get_exposed_port(8080)}/api/v2/healthz",
|
||||
|
||||
Reference in New Issue
Block a user