mirror of
https://github.com/SigNoz/signoz.git
synced 2026-11-24 09:10:42 +00:00
Compare commits
2 Commits
test/jest-
...
perf/web-i
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
649c3a250c | ||
|
|
f7b1383427 |
@@ -9,14 +9,12 @@ paths:
|
||||
Examples and the harness API live in [`frontend/src/tests/README.md`](../../frontend/src/tests/README.md).
|
||||
|
||||
- **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` computes the accessibility tree on every call and is the slowest query. 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, which walks `getComputedStyle` up the tree on every action; never turn it back on. `fireEvent` only for events `userEvent` has no equivalent for: scroll, resize, setting `scrollTop`.
|
||||
- **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` computes the accessibility tree on every call and is the slowest query.
|
||||
- **Interact like a user.** `const user = userEvent.setup({ pointerEventsCheck: 0 })`, then an awaited `user.click`, `hover`, `keyboard` or `type`. `fireEvent` only for events `userEvent` has no equivalent for: scroll, resize, setting `scrollTop`.
|
||||
- **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`.
|
||||
- **Mock only business boundaries.** Local `jest.mock` for API modules, custom hooks and domain components. Never re-mock what the harness provides (`@floating-ui/dom`, `@testing-library/user-event` and antd's `collectScroller` in `jest.setup.ts`) or what `jest.config.ts` maps (`uplot`, `@signozhq/icons`, `useSafeNavigate`, `logEvent`).
|
||||
- **Mock only business boundaries.** Local `jest.mock` for API modules, custom hooks and domain components. Never re-mock what the harness provides or what `jest.config.ts` maps (`uplot`, `@signozhq/icons`, `useSafeNavigate`, `logEvent`).
|
||||
- **Type mocks and fixtures.** `jest.mocked(fn)` for module mocks, `jest.fn() as jest.MockedFunction<T>` for a standalone mock you configure or assert on. Fixtures carry their real type, from `src/api/generated` where it exists. No `any`, no `as unknown as`. An inline `onX={jest.fn()}` on a typed prop that is never asserted needs no annotation.
|
||||
- **One behaviour per test, at the smallest render.** Render the component that owns the behaviour, not the page around it, unless the page wiring is the behaviour. A flow of steps (a wizard, a multi-step form) becomes one test per step that starts at that step through props, store or route. A full click-through belongs in the e2e suite (`tests/e2e`).
|
||||
- **Each test under 500 ms.** `pnpm jest <file> --verbose` prints each test's time. CI runs about four times slower than a laptop, and the timeout is 5 s. Never raise a timeout (`jest.setTimeout`, a third argument to `it`) to make a slow test pass; slim the test instead.
|
||||
- **A test fails without its change.** At the gate in [`frontend/AGENTS.md`](../../frontend/AGENTS.md), revert the change, or break the line under test, and run the test: it must fail, and each test must stay under 500 ms. Assert the specific outcome (exact text, request payload, call arguments), never only that an element exists.
|
||||
- **A test fails without its change.** Revert the change, or break the line under test, and run the test before you finish: it must fail. Assert the specific outcome (exact text, request payload, call arguments), never only that an element exists.
|
||||
- **No limit on tests per file.** Split a file when it mixes unrelated behaviour, not to hit a count.
|
||||
|
||||
2
.github/workflows/e2eci.yaml
vendored
2
.github/workflows/e2eci.yaml
vendored
@@ -94,7 +94,7 @@ jobs:
|
||||
postgres:15 \
|
||||
clickhouse/clickhouse-server:25.12.5 \
|
||||
clickhouse/clickhouse-keeper:25.12.5 \
|
||||
signoz/signoz-otel-collector:v0.144.17 \
|
||||
signoz/signoz-otel-collector:v0.144.16-rc.1 \
|
||||
wiremock/wiremock:2.35.1-1 \
|
||||
| xargs -P 0 -n 1 docker pull -q
|
||||
- name: python
|
||||
|
||||
7
.github/workflows/integrationci.yaml
vendored
7
.github/workflows/integrationci.yaml
vendored
@@ -85,18 +85,13 @@ jobs:
|
||||
- wal
|
||||
clickhouse-version:
|
||||
- 25.12.5
|
||||
- 26.8.34
|
||||
signoz-otel-collector-version:
|
||||
- v0.144.17
|
||||
- v0.144.16-rc.1
|
||||
postgres-version:
|
||||
- 15
|
||||
exclude:
|
||||
- sqlstore-provider: postgres
|
||||
clickhouse-version: 26.8.34
|
||||
if: |
|
||||
((github.event_name == 'pull_request' && ! github.event.pull_request.head.repo.fork && github.event.pull_request.user.login != 'dependabot[bot]' && ! contains(github.event.pull_request.labels.*.name, 'safe-to-test')) ||
|
||||
(github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe-to-test'))) && contains(github.event.pull_request.labels.*.name, 'safe-to-integrate')
|
||||
continue-on-error: ${{ matrix.clickhouse-version == '26.8.34' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
|
||||
@@ -474,14 +474,6 @@ auditor:
|
||||
compression: lz4
|
||||
# The maximum time to drain buffered events on shutdown. Undelivered events are dropped after it.
|
||||
shutdown_timeout: 30s
|
||||
tls:
|
||||
# Whether to connect to the brokers over TLS.
|
||||
enabled: false
|
||||
# The PEM CA bundle that verifies broker certificates. Empty uses the system roots.
|
||||
ca_file: ""
|
||||
# The client certificate and key, for brokers that require client auth. Set both or neither.
|
||||
cert_file: ""
|
||||
key_file: ""
|
||||
|
||||
##################### Cloud Integration #####################
|
||||
cloudintegration:
|
||||
|
||||
@@ -2,10 +2,7 @@ package kafkaauditor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
"github.com/twmb/franz-go/pkg/kgo"
|
||||
"github.com/twmb/franz-go/plugin/kslog"
|
||||
@@ -13,7 +10,6 @@ import (
|
||||
|
||||
"github.com/SigNoz/signoz/pkg/auditor"
|
||||
"github.com/SigNoz/signoz/pkg/auditor/auditorserver"
|
||||
"github.com/SigNoz/signoz/pkg/errors"
|
||||
"github.com/SigNoz/signoz/pkg/factory"
|
||||
"github.com/SigNoz/signoz/pkg/licensing"
|
||||
"github.com/SigNoz/signoz/pkg/types/audittypes"
|
||||
@@ -43,25 +39,13 @@ func newProvider(_ context.Context, providerSettings factory.ProviderSettings, c
|
||||
|
||||
// Acks from all in-sync replicas, idempotent writes and unbounded record retries are franz-go defaults and are kept as is.
|
||||
// A delivery timeout or retry limit lets franz-go < v1.22.2 ack a record that was never written (twmb/franz-go#1484).
|
||||
opts := []kgo.Opt{
|
||||
client, err := kgo.NewClient(
|
||||
kgo.SeedBrokers(config.Kafka.Brokers...),
|
||||
kgo.ClientID(config.Kafka.ClientID),
|
||||
kgo.ProducerBatchCompression(compressionCodec(config.Kafka.Compression)),
|
||||
kgo.ProducerLinger(0),
|
||||
kgo.WithLogger(kslog.New(settings.Logger())),
|
||||
}
|
||||
|
||||
if config.Kafka.TLS.Enabled {
|
||||
tlsConfig, err := newTLSConfig(config.Kafka.TLS)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// franz-go sets ServerName per broker from the dialed address.
|
||||
opts = append(opts, kgo.DialTLSConfig(tlsConfig))
|
||||
}
|
||||
|
||||
client, err := kgo.NewClient(opts...)
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -146,30 +130,3 @@ func compressionCodec(name string) kgo.CompressionCodec {
|
||||
return kgo.NoCompression()
|
||||
}
|
||||
}
|
||||
|
||||
func newTLSConfig(config auditor.TLSConfig) (*tls.Config, error) {
|
||||
tlsConfig := &tls.Config{}
|
||||
|
||||
if config.CAFile != "" {
|
||||
caPEM, err := os.ReadFile(config.CAFile)
|
||||
if err != nil {
|
||||
return nil, errors.WrapInvalidInputf(err, errors.CodeInvalidInput, "cannot read auditor::kafka::tls::ca_file")
|
||||
}
|
||||
|
||||
tlsConfig.RootCAs = x509.NewCertPool()
|
||||
if !tlsConfig.RootCAs.AppendCertsFromPEM(caPEM) {
|
||||
return nil, errors.NewInvalidInputf(errors.CodeInvalidInput, "auditor::kafka::tls::ca_file %q holds no PEM certificate", config.CAFile)
|
||||
}
|
||||
}
|
||||
|
||||
if config.CertFile != "" {
|
||||
cert, err := tls.LoadX509KeyPair(config.CertFile, config.KeyFile)
|
||||
if err != nil {
|
||||
return nil, errors.WrapInvalidInputf(err, errors.CodeInvalidInput, "cannot load auditor::kafka::tls::cert_file and auditor::kafka::tls::key_file")
|
||||
}
|
||||
|
||||
tlsConfig.Certificates = []tls.Certificate{cert}
|
||||
}
|
||||
|
||||
return tlsConfig, nil
|
||||
}
|
||||
|
||||
@@ -1,269 +0,0 @@
|
||||
package kafkaauditor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"crypto/elliptic"
|
||||
"crypto/rand"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"crypto/x509/pkix"
|
||||
"encoding/pem"
|
||||
"math/big"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/twmb/franz-go/pkg/kfake"
|
||||
"github.com/twmb/franz-go/pkg/kgo"
|
||||
|
||||
"github.com/SigNoz/signoz/pkg/auditor"
|
||||
"github.com/SigNoz/signoz/pkg/errors"
|
||||
"github.com/SigNoz/signoz/pkg/instrumentation/instrumentationtest"
|
||||
"github.com/SigNoz/signoz/pkg/types/audittypes"
|
||||
"github.com/SigNoz/signoz/pkg/types/coretypes"
|
||||
"github.com/SigNoz/signoz/pkg/version"
|
||||
)
|
||||
|
||||
func TestExport_MutualTLS(t *testing.T) {
|
||||
certificates := newTestCertificates(t)
|
||||
|
||||
cluster, err := kfake.NewCluster(
|
||||
kfake.NumBrokers(1),
|
||||
kfake.SeedTopics(1, "tls_audit"),
|
||||
kfake.TLS(&tls.Config{
|
||||
Certificates: []tls.Certificate{certificates.server},
|
||||
ClientCAs: certificates.caPool,
|
||||
ClientAuth: tls.RequireAndVerifyClientCert,
|
||||
}),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(cluster.Close)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
tls auditor.TLSConfig
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
name: "CAAndClientCertificate_Delivers",
|
||||
tls: certificates.client,
|
||||
},
|
||||
{
|
||||
name: "TLSDisabled_Fails",
|
||||
tls: auditor.TLSConfig{},
|
||||
err: true,
|
||||
},
|
||||
{
|
||||
name: "WithoutClientCertificate_Fails",
|
||||
tls: auditor.TLSConfig{Enabled: true, CAFile: certificates.client.CAFile},
|
||||
err: true,
|
||||
},
|
||||
{
|
||||
name: "WithoutCA_Fails",
|
||||
tls: auditor.TLSConfig{Enabled: true, CertFile: certificates.client.CertFile, KeyFile: certificates.client.KeyFile},
|
||||
err: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
config := auditor.Config{
|
||||
Provider: "kafka",
|
||||
BufferSize: 10,
|
||||
BatchSize: 5,
|
||||
FlushInterval: 50 * time.Millisecond,
|
||||
Kafka: auditor.KafkaConfig{
|
||||
Brokers: cluster.ListenAddrs(),
|
||||
Topic: "tls_audit",
|
||||
ClientID: "signoz-tls-test",
|
||||
Compression: "lz4",
|
||||
ShutdownTimeout: 30 * time.Second,
|
||||
TLS: testCase.tls,
|
||||
},
|
||||
}
|
||||
|
||||
auditor, err := newProvider(context.Background(), instrumentationtest.New().ToProviderSettings(), config, nil, version.Info)
|
||||
require.NoError(t, err)
|
||||
provider := auditor.(*provider)
|
||||
defer provider.client.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
|
||||
err = provider.export(ctx, []audittypes.AuditEvent{newTestEvent(coretypes.ResourceUser, coretypes.VerbCreate, testCase.name)})
|
||||
if testCase.err {
|
||||
assert.True(t, errors.Is(err, context.DeadlineExceeded))
|
||||
return
|
||||
}
|
||||
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
consumerTLS, err := newTLSConfig(certificates.client)
|
||||
require.NoError(t, err)
|
||||
|
||||
consumer, err := kgo.NewClient(
|
||||
kgo.SeedBrokers(cluster.ListenAddrs()...),
|
||||
kgo.DialTLSConfig(consumerTLS),
|
||||
kgo.ConsumeTopics("tls_audit"),
|
||||
kgo.ConsumeResetOffset(kgo.NewOffset().AtStart()),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
defer consumer.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
fetches := consumer.PollFetches(ctx)
|
||||
require.Empty(t, fetches.Errors())
|
||||
assert.Len(t, fetches.Records(), 1)
|
||||
}
|
||||
|
||||
func TestNewTLSConfig(t *testing.T) {
|
||||
certificates := newTestCertificates(t)
|
||||
|
||||
notPEMFile := filepath.Join(t.TempDir(), "not-pem.crt")
|
||||
require.NoError(t, os.WriteFile(notPEMFile, []byte("not a pem"), 0o600))
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
config auditor.TLSConfig
|
||||
err bool
|
||||
wantRootCAs bool
|
||||
wantCertificates int
|
||||
}{
|
||||
{
|
||||
name: "NoFiles_UsesSystemRoots",
|
||||
config: auditor.TLSConfig{Enabled: true},
|
||||
},
|
||||
{
|
||||
name: "CAOnly",
|
||||
config: auditor.TLSConfig{Enabled: true, CAFile: certificates.client.CAFile},
|
||||
wantRootCAs: true,
|
||||
},
|
||||
{
|
||||
name: "CAAndClientCertificate",
|
||||
config: certificates.client,
|
||||
wantRootCAs: true,
|
||||
wantCertificates: 1,
|
||||
},
|
||||
{
|
||||
name: "CAFileMissing",
|
||||
config: auditor.TLSConfig{Enabled: true, CAFile: filepath.Join(t.TempDir(), "missing-ca.crt")},
|
||||
err: true,
|
||||
},
|
||||
{
|
||||
name: "CAFileNotPEM",
|
||||
config: auditor.TLSConfig{Enabled: true, CAFile: notPEMFile},
|
||||
err: true,
|
||||
},
|
||||
{
|
||||
name: "KeyFileMissing",
|
||||
config: auditor.TLSConfig{Enabled: true, CertFile: certificates.client.CertFile, KeyFile: filepath.Join(t.TempDir(), "missing.key")},
|
||||
err: true,
|
||||
},
|
||||
{
|
||||
name: "CertFileNotPEM",
|
||||
config: auditor.TLSConfig{Enabled: true, CertFile: notPEMFile, KeyFile: certificates.client.KeyFile},
|
||||
err: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
tlsConfig, err := newTLSConfig(testCase.config)
|
||||
if testCase.err {
|
||||
assert.True(t, errors.Ast(err, errors.TypeInvalidInput))
|
||||
return
|
||||
}
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, testCase.wantRootCAs, tlsConfig.RootCAs != nil)
|
||||
assert.Len(t, tlsConfig.Certificates, testCase.wantCertificates)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type testCertificates struct {
|
||||
caPool *x509.CertPool
|
||||
server tls.Certificate
|
||||
client auditor.TLSConfig
|
||||
}
|
||||
|
||||
// Issues a CA, a broker certificate for 127.0.0.1 and a client certificate, writing the client side as ca.crt, tls.crt and tls.key.
|
||||
func newTestCertificates(t *testing.T) testCertificates {
|
||||
t.Helper()
|
||||
|
||||
caKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||
require.NoError(t, err)
|
||||
|
||||
caTemplate := &x509.Certificate{
|
||||
SerialNumber: big.NewInt(1),
|
||||
Subject: pkix.Name{CommonName: "test-ca"},
|
||||
NotBefore: time.Now().Add(-time.Hour),
|
||||
NotAfter: time.Now().Add(time.Hour),
|
||||
IsCA: true,
|
||||
BasicConstraintsValid: true,
|
||||
KeyUsage: x509.KeyUsageCertSign,
|
||||
}
|
||||
caDER, err := x509.CreateCertificate(rand.Reader, caTemplate, caTemplate, &caKey.PublicKey, caKey)
|
||||
require.NoError(t, err)
|
||||
ca, err := x509.ParseCertificate(caDER)
|
||||
require.NoError(t, err)
|
||||
|
||||
serverCertPEM, serverKeyPEM := issueTestCertificate(t, ca, caKey, &x509.Certificate{
|
||||
SerialNumber: big.NewInt(2),
|
||||
Subject: pkix.Name{CommonName: "broker"},
|
||||
IPAddresses: []net.IP{net.ParseIP("127.0.0.1")},
|
||||
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
|
||||
})
|
||||
server, err := tls.X509KeyPair(serverCertPEM, serverKeyPEM)
|
||||
require.NoError(t, err)
|
||||
|
||||
clientCertPEM, clientKeyPEM := issueTestCertificate(t, ca, caKey, &x509.Certificate{
|
||||
SerialNumber: big.NewInt(3),
|
||||
Subject: pkix.Name{CommonName: "signoz"},
|
||||
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth},
|
||||
})
|
||||
|
||||
dir := t.TempDir()
|
||||
client := auditor.TLSConfig{
|
||||
Enabled: true,
|
||||
CAFile: filepath.Join(dir, "ca.crt"),
|
||||
CertFile: filepath.Join(dir, "tls.crt"),
|
||||
KeyFile: filepath.Join(dir, "tls.key"),
|
||||
}
|
||||
require.NoError(t, os.WriteFile(client.CAFile, pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: caDER}), 0o600))
|
||||
require.NoError(t, os.WriteFile(client.CertFile, clientCertPEM, 0o600))
|
||||
require.NoError(t, os.WriteFile(client.KeyFile, clientKeyPEM, 0o600))
|
||||
|
||||
caPool := x509.NewCertPool()
|
||||
caPool.AddCert(ca)
|
||||
|
||||
return testCertificates{caPool: caPool, server: server, client: client}
|
||||
}
|
||||
|
||||
func issueTestCertificate(t *testing.T, ca *x509.Certificate, caKey *ecdsa.PrivateKey, template *x509.Certificate) ([]byte, []byte) {
|
||||
t.Helper()
|
||||
|
||||
key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||
require.NoError(t, err)
|
||||
|
||||
template.NotBefore = time.Now().Add(-time.Hour)
|
||||
template.NotAfter = time.Now().Add(time.Hour)
|
||||
template.KeyUsage = x509.KeyUsageDigitalSignature
|
||||
|
||||
der, err := x509.CreateCertificate(rand.Reader, template, ca, &key.PublicKey, caKey)
|
||||
require.NoError(t, err)
|
||||
|
||||
keyDER, err := x509.MarshalECPrivateKey(key)
|
||||
require.NoError(t, err)
|
||||
|
||||
return pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: der}), pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: keyDER})
|
||||
}
|
||||
@@ -99,7 +99,7 @@ is still by hand. The generator never adds a SideNav item; do that in
|
||||
CSS Modules (`docs/css-modules-guide.md`), React Query for server state (prefer
|
||||
`api/generated` hooks), nuqs for URL state, Zustand for client state, `data-testid` on
|
||||
every interactive element.
|
||||
5. **Verify** at the gate in `AGENTS.md` (commit, push or PR), not after each edit; skip it while the user says `no checks`:
|
||||
5. **Verify** before reporting done:
|
||||
```bash
|
||||
pnpm tsgo --noEmit
|
||||
pnpm oxlint src/pages/<Feature>
|
||||
|
||||
3
frontend/.gitignore
vendored
3
frontend/.gitignore
vendored
@@ -1,4 +1,7 @@
|
||||
|
||||
# Vite copies public/ unhashed, and the Go server caches /assets/ as immutable
|
||||
/public/assets/
|
||||
|
||||
# Sentry Config File
|
||||
.env.sentry-build-plugin
|
||||
.qodo
|
||||
|
||||
@@ -28,24 +28,20 @@ You are operating within a constrained context window and strict system prompts.
|
||||
- UI primitives come from `@signozhq/ui` (subpath imports) and icons from `@signozhq/icons`. No new `antd` component or direct icon library (`lucide-react`) where `@signozhq/ui` has an equivalent; `signoz/no-antd-components` enforces part of this list.
|
||||
- Exception: a control added beside `antd` siblings of the same kind (a tab in an `antd` tab strip) matches them until that surface migrates. Say so in the PR.
|
||||
- When `@signozhq/ui` or `@signozhq/icons` lacks what you need, say so in the PR before reaching for another library.
|
||||
- Never override a `@signozhq/ui` component's styles: no `--<component>-*` CSS variables, no `:global` class or `data-*` selectors, no restyling through `className`/`style`. Use its props, and put layout on a wrapper you own. When it can't do what the design needs, file a UI suggestion in `SigNoz/uforge-pod` (`ui-suggestion.yml` template) and link it in the PR.
|
||||
- Before styling a `@signozhq/ui` component, check its props in `node_modules/@signozhq/ui/dist/<component>/*.d.ts` for `className`/`style` support; some omit them. Avoid overriding the component's CSS vars unless explicitly needed.
|
||||
- When writing code that could need authorization checks, read ./src/lib/authz/README.md
|
||||
- A flow that gains a request also gates on that request's permission: a rename that now reads the view first needs `read` as well as `update`.
|
||||
- Identity keys (legend groups, color groups, CSV headers, React keys) come from structured values, never from joined display text: `['us, east', 'prod']` and `['us', 'east, prod']` both join to `us, east, prod`.
|
||||
- A payload saved under another kind or schema copies only the fields that schema accepts, and drops bindings to columns the user removed. The server rejects unknown or stale fields, so the preview works and the save fails.
|
||||
|
||||
3. CHECKS AT THE GATE: Your internal tools mark file writes as successful even if the code does not compile, so the checks below are required, but only at the gate. The gate is when the user says commit, push, raise or update the PR, mark it ready, or "run checks". Never run them after each edit or between the user's iterations.
|
||||
- Between gates, after an edit, run at most the one test file that covers it.
|
||||
- `no checks`: when the user says it (or "don't run tests", "just making changes"), run nothing: no tests, type check, lint, format or build. Make the change and stop. This holds until the user names a gate.
|
||||
|
||||
At the gate, you are FORBIDDEN from reporting a task as complete until you have:
|
||||
3. FORCED VERIFICATION: Your internal tools mark file writes as successful even if the code does not compile. Run these checks once all changes of a task are done, never after each edit. You are FORBIDDEN from reporting a task as complete until you have:
|
||||
- Run `pnpm tsgo --noEmit`
|
||||
- Run `pnpm lint:js --quiet` to find critical errors
|
||||
- Run `pnpm oxlint <file1> <file2>` and fix all warnings
|
||||
- Run `pnpm build`
|
||||
- Find if the file has tests for it, or if there's `__test__` folder or the parent folder has tests, and run. Run them before coding the change or after all changes, never in between.
|
||||
- For e2e, run only the specs you added or changed: the stack is heavy. Leave the full jest and e2e suites to CI unless the user asks.
|
||||
- For every test you added or changed, revert the change it covers and confirm the test fails, and that each test runs under 500 ms (`pnpm jest <file> --verbose`)
|
||||
- For every test you added or changed, revert the change it covers and confirm the test fails
|
||||
- On a stacked branch (`gh stack`), run `pnpm tsgo --noEmit` on every branch above it before pushing: a renamed prop or moved export breaks them
|
||||
- Fixed ALL resulting errors
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
- [ ] No deep class nesting (max 3 class levels; pseudo-classes/elements and parent-reference selectors like `&.active`, `&#bar` are not counted)
|
||||
- [ ] No hardcoded colors - use `--l1/l2/l3-*` semantic tokens (not `--bg-*` primitives)
|
||||
- [ ] No magic numbers - use `--spacing-*` tokens
|
||||
- [ ] Typography uses `--{variant}-{size}-{weight}-*` text style tokens (see Typography)
|
||||
- [ ] No overrides of `@signozhq/ui` components (see below)
|
||||
- [ ] Global escapes only for third-party overrides (`@signozhq/ui` is not third-party)
|
||||
- [ ] Typography uses `--periscope-font-size-*` or `--font-size-*` tokens
|
||||
- [ ] @signozhq/ui overrides use CSS variables, not direct class overrides
|
||||
- [ ] Global escapes only for third-party overrides
|
||||
- [ ] No ID selectors
|
||||
- [ ] No bare element selectors
|
||||
- [ ] Keyframes are declared in the module with plain `@keyframes name` (already local)
|
||||
- [ ] Keyframes use `:local(@keyframes name)` to avoid global collisions
|
||||
|
||||
## Config (vite.config.ts)
|
||||
|
||||
@@ -77,7 +77,7 @@ css: {
|
||||
|
||||
// BAD: Nesting creates separate classes you might not expect
|
||||
.button {
|
||||
.icon { } // -> styles.icon, but the rule is `.button .icon`: it only matches inside .button
|
||||
.icon { } // -> styles.icon (separate class, not scoped under .button)
|
||||
}
|
||||
|
||||
// GOOD: Flat structure
|
||||
@@ -289,32 +289,88 @@ Use L1/L2/L3 semantic tokens - they handle light/dark theme automatically.
|
||||
- L2 = elevated surfaces (cards, panels)
|
||||
- L3 = nested/inset elements
|
||||
|
||||
## @signozhq/ui Components
|
||||
## Overriding @signozhq/ui Components
|
||||
|
||||
Don't override them. That covers setting a component's `--<component>-*` CSS variables, targeting its classes or `data-*` attributes through `:global(...)`, and restyling it with `className` or `style`. An override keeps working until the component changes, then breaks with no type error or lint warning, and the screen drifts from every other one using that component.
|
||||
Components expose CSS variables for customization.
|
||||
|
||||
- Use the component's props (`variant`, `color`, `size`, ...) for how it looks.
|
||||
- Put layout (position, margin, width inside a flex or grid parent) on a wrapper element you own.
|
||||
- If the component can't do what the design needs, file a [UI suggestion](https://github.com/SigNoz/uforge-pod/issues/new?template=ui-suggestion.yml) in `SigNoz/uforge-pod` and ship with the component as it renders until the suggestion is decided. Link the issue in the PR.
|
||||
You can ensure they exist by looking at ./node_modules/@signozhq/ui/dist.
|
||||
Never write a override without confirm it exists.
|
||||
|
||||
Override via:
|
||||
|
||||
### Method 1: CSS Variables (Preferred)
|
||||
|
||||
Each component exposes `--<component>-<property>` variables:
|
||||
|
||||
```scss
|
||||
// BAD: Restyling the component
|
||||
.saveButton {
|
||||
--button-primary-background-color: var(--success-background);
|
||||
// Override Button
|
||||
.customButton {
|
||||
--button-background: var(--success-background);
|
||||
--button-border-radius: var(--radius-2);
|
||||
--button-padding: var(--spacing-4) var(--spacing-8);
|
||||
--button-font-size: var(--label-base-400-font-size);
|
||||
}
|
||||
|
||||
.toolbar :global([data-variant="outlined"]) {
|
||||
--button-variant-outlined-border: 1px solid var(--accent-primary);
|
||||
// Override Input
|
||||
.customInput {
|
||||
--input-height: 2.5rem;
|
||||
--input-border-color: var(--l2-border);
|
||||
--input-padding: var(--spacing-2) var(--spacing-6);
|
||||
--input-placeholder-color: var(--l3-foreground);
|
||||
}
|
||||
|
||||
// GOOD: Layout on your own wrapper, looks from props
|
||||
.toolbarActions {
|
||||
display: flex;
|
||||
gap: var(--spacing-4);
|
||||
margin-left: auto;
|
||||
// Override nested parts
|
||||
.customInput {
|
||||
--input-prefix-padding: 0 var(--spacing-4) 0 var(--spacing-6);
|
||||
--input-suffix-color: var(--accent-primary);
|
||||
}
|
||||
```
|
||||
|
||||
### Method 2: Data Attributes
|
||||
|
||||
Components use data attributes for variants/states. Target them for state-specific overrides:
|
||||
|
||||
```scss
|
||||
// Target variant
|
||||
.wrapper :global([data-variant="outlined"]) {
|
||||
--button-border-color: var(--accent-primary);
|
||||
}
|
||||
|
||||
// Target size
|
||||
.wrapper :global([data-size="sm"]) {
|
||||
--button-font-size: var(--label-small-400-font-size);
|
||||
}
|
||||
|
||||
// Target color
|
||||
.wrapper :global([data-color="destructive"]) {
|
||||
--button-background: var(--danger-background);
|
||||
}
|
||||
|
||||
// Target state (Radix patterns)
|
||||
.popover :global([data-state="open"]) {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.tooltip :global([data-side="top"]) {
|
||||
margin-bottom: var(--spacing-2);
|
||||
}
|
||||
```
|
||||
|
||||
### Common Component CSS Variables
|
||||
|
||||
**Button:**
|
||||
- `--button-background`, `--button-border-radius`, `--button-padding`
|
||||
- `--button-font-size`, `--button-height`, `--button-gap`
|
||||
- `--button-hover-background`, `--button-disabled-opacity`
|
||||
|
||||
**Input:**
|
||||
- `--input-height`, `--input-border-color`, `--input-background`
|
||||
- `--input-padding`, `--input-font-size`, `--input-placeholder-color`
|
||||
- `--input-focus-outline-color`, `--input-hover-border-color`
|
||||
- `--input-prefix-*`, `--input-suffix-*` for adornments
|
||||
|
||||
**General pattern:** `--<component>-<property>` or `--<component>-<state>-<property>`
|
||||
|
||||
## Good Patterns
|
||||
|
||||
### Structure
|
||||
@@ -378,21 +434,24 @@ Don't override them. That covers setting a component's `--<component>-*` CSS var
|
||||
|
||||
### Keyframes (Local Scoping)
|
||||
|
||||
CSS Modules scope `@keyframes` like classes: the build renames `fadeIn` to `_fadeIn_<hash>` and rewrites every `animation` in the same module that names it. Don't wrap it in `:local(...)`; Sass rejects `:local(@keyframes fadeIn)` with `expected selector`.
|
||||
Without `:local()`, keyframe names are global and can clash across modules:
|
||||
|
||||
```scss
|
||||
// GOOD: Local to this module
|
||||
// BAD: Global keyframe - can conflict with other modules
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
// GOOD: Locally scoped keyframe
|
||||
:local(@keyframes fadeIn) {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.modal {
|
||||
animation: fadeIn 200ms ease;
|
||||
}
|
||||
|
||||
// BAD: Doesn't compile
|
||||
:local(@keyframes fadeIn) { }
|
||||
```
|
||||
|
||||
## JS Import Patterns
|
||||
|
||||
@@ -6,8 +6,6 @@ const LOG_EVENT_MOCK_PATH = '<rootDir>/src/__tests__/logEventMock.ts';
|
||||
|
||||
const config: Config.InitialOptions = {
|
||||
silent: true,
|
||||
// CI runners are slow enough that multi-step userEvent tests pass 5s.
|
||||
testTimeout: 10000,
|
||||
clearMocks: true,
|
||||
coverageDirectory: 'coverage',
|
||||
coverageReporters: ['text', 'cobertura', 'html', 'json-summary'],
|
||||
@@ -69,8 +67,6 @@ const config: Config.InitialOptions = {
|
||||
testPathIgnorePatterns: ['/node_modules/', '/public/'],
|
||||
moduleDirectories: ['node_modules', 'src'],
|
||||
testEnvironment: '<rootDir>/jest.environment.cjs',
|
||||
// Local only: the default (cores - 1) workers exhaust RAM when several runs overlap.
|
||||
...(process.env.CI ? {} : { maxWorkers: 4, workerIdleMemoryLimit: '1GB' }),
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
statements: 80,
|
||||
|
||||
@@ -137,8 +137,6 @@ window.getComputedStyle = function (
|
||||
return {
|
||||
display: '',
|
||||
visibility: '',
|
||||
width: '',
|
||||
height: '',
|
||||
opacity: '1',
|
||||
animationName: 'none',
|
||||
getPropertyValue: () => '',
|
||||
@@ -146,39 +144,6 @@ window.getComputedStyle = function (
|
||||
}
|
||||
};
|
||||
|
||||
// jsdom has no layout, and Floating UI's getComputedStyle walk over every
|
||||
// popover ancestor costs up to ~1 s per open.
|
||||
jest.mock('@floating-ui/dom', () => ({
|
||||
...jest.requireActual('@floating-ui/dom'),
|
||||
autoUpdate: (): (() => void) => (): void => {},
|
||||
computePosition: (
|
||||
_reference: unknown,
|
||||
_floating: unknown,
|
||||
{ placement = 'bottom', strategy = 'absolute' } = {},
|
||||
): Promise<unknown> =>
|
||||
Promise.resolve({ x: 0, y: 0, placement, strategy, middlewareData: {} }),
|
||||
}));
|
||||
|
||||
jest.mock('@testing-library/user-event', () =>
|
||||
jest.requireActual('tests/userEventWithDefaults'),
|
||||
);
|
||||
|
||||
// antd popups walk getComputedStyle up every ancestor to find scroll
|
||||
// containers on each open. pnpm keeps the package under antd, not at the root.
|
||||
jest.mock(
|
||||
require.resolve('@rc-component/trigger/lib/util', {
|
||||
paths: [require.resolve('antd')],
|
||||
}),
|
||||
() => ({
|
||||
...jest.requireActual(
|
||||
require.resolve('@rc-component/trigger/lib/util', {
|
||||
paths: [require.resolve('antd')],
|
||||
}),
|
||||
),
|
||||
collectScroller: (): HTMLElement[] => [],
|
||||
}),
|
||||
);
|
||||
|
||||
beforeAll(() => server.listen());
|
||||
|
||||
afterEach(() => server.resetHandlers());
|
||||
|
||||
@@ -56,7 +56,6 @@
|
||||
"@sentry/vite-plugin": "5.3.0",
|
||||
"@signozhq/design-tokens": "2.8.0",
|
||||
"@signozhq/icons": "0.4.0",
|
||||
"@signozhq/noz-client": "1.13.0",
|
||||
"@signozhq/ui": "0.4.0-rc.5",
|
||||
"@tanstack/react-table": "8.21.3",
|
||||
"@tanstack/react-virtual": "3.13.22",
|
||||
|
||||
16
frontend/pnpm-lock.yaml
generated
16
frontend/pnpm-lock.yaml
generated
@@ -82,9 +82,6 @@ importers:
|
||||
'@signozhq/icons':
|
||||
specifier: 0.4.0
|
||||
version: 0.4.0
|
||||
'@signozhq/noz-client':
|
||||
specifier: 1.13.0
|
||||
version: 1.13.0(axios@1.21.1)(react-query@3.39.3(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react@18.2.0)
|
||||
'@signozhq/ui':
|
||||
specifier: 0.4.0-rc.5
|
||||
version: 0.4.0-rc.5(@date-fns/tz@1.4.1)(@signozhq/design-tokens@2.8.0)(@signozhq/icons@0.4.0)(@types/react@18.0.26)(date-fns@4.1.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)
|
||||
@@ -3251,13 +3248,6 @@ packages:
|
||||
'@signozhq/icons@0.4.0':
|
||||
resolution: {integrity: sha512-QctNvNPlQlsefFdIVmSy/P/7a1IcQ3IryKP0KPMqtoqew3q89FGUmFa5IfEJ7Z3CHhtG1zaXwBKqP72QkLyA3g==}
|
||||
|
||||
'@signozhq/noz-client@1.13.0':
|
||||
resolution: {integrity: sha512-130L2xomHnQZK8ZtAst34qFz9d2rSF/JYpg9gKvJkZVS9+46CPZeTW8Va9PNS9Oa5owezVHIXZStTEbsHIxnwg==}
|
||||
peerDependencies:
|
||||
axios: ^1.20.0
|
||||
react: ^18.2.0
|
||||
react-query: ^3.39.3
|
||||
|
||||
'@signozhq/ui@0.4.0-rc.5':
|
||||
resolution: {integrity: sha512-WlJMfeDfvL2hjMpTpHhhND/tuK7X0sfXQlx6E1ZG+6E/DYHpuhYljfvW3E6/BohIlHFlTyCs/ZMl9wnV2k9Zcw==}
|
||||
peerDependencies:
|
||||
@@ -12383,12 +12373,6 @@ snapshots:
|
||||
|
||||
'@signozhq/icons@0.4.0': {}
|
||||
|
||||
'@signozhq/noz-client@1.13.0(axios@1.21.1)(react-query@3.39.3(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react@18.2.0)':
|
||||
dependencies:
|
||||
axios: 1.21.1
|
||||
react: 18.2.0
|
||||
react-query: 3.39.3(react-dom@18.2.0(react@18.2.0))(react@18.2.0)
|
||||
|
||||
'@signozhq/ui@0.4.0-rc.5(@date-fns/tz@1.4.1)(@signozhq/design-tokens@2.8.0)(@signozhq/icons@0.4.0)(@types/react@18.0.26)(date-fns@4.1.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)':
|
||||
dependencies:
|
||||
'@base-ui/react': 1.8.0(@date-fns/tz@1.4.1)(@types/react@18.0.26)(date-fns@4.1.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* to resume, which each return a new executionId to open a fresh SSE stream.
|
||||
*
|
||||
* Types in this file re-use the OpenAPI-generated DTOs in
|
||||
* `@signozhq/noz-client`.
|
||||
* `src/api/ai-assistant/sigNozAIAssistantAPI.schemas.ts`.
|
||||
* Local types are defined only when the UI needs a different shape — for
|
||||
* example, the SSE event union adds a literal `type` discriminator that the
|
||||
* generated event DTOs leave loose.
|
||||
@@ -60,7 +60,7 @@ import type {
|
||||
PageTypeDTO,
|
||||
ToolCallEventDTO,
|
||||
ToolResultEventDTO,
|
||||
} from '@signozhq/noz-client';
|
||||
} from './sigNozAIAssistantAPI.schemas';
|
||||
import { LOCALSTORAGE } from 'constants/localStorage';
|
||||
|
||||
import {
|
||||
|
||||
1998
frontend/src/api/ai-assistant/index.ts
Normal file
1998
frontend/src/api/ai-assistant/index.ts
Normal file
File diff suppressed because it is too large
Load Diff
1520
frontend/src/api/ai-assistant/sigNozAIAssistantAPI.schemas.ts
Normal file
1520
frontend/src/api/ai-assistant/sigNozAIAssistantAPI.schemas.ts
Normal file
File diff suppressed because it is too large
Load Diff
1
frontend/src/auto-import-registry.d.ts
vendored
1
frontend/src/auto-import-registry.d.ts
vendored
@@ -12,5 +12,4 @@
|
||||
|
||||
import '@signozhq/design-tokens';
|
||||
import '@signozhq/icons';
|
||||
import '@signozhq/noz-client';
|
||||
import '@signozhq/ui';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { lazy } from 'react';
|
||||
import { navigate } from 'lib/router/navigation';
|
||||
import { fireEvent, render, screen } from 'tests/test-utils';
|
||||
|
||||
@@ -99,30 +98,4 @@ describe('RouteTab component', () => {
|
||||
fireEvent.click(screen.getByRole('tab', { name: 'Tab2' }));
|
||||
expect(onChangeHandler).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('keeps the tab bar while a lazy tab loads', async () => {
|
||||
let resolveTab: (module: { default: () => JSX.Element }) => void = () => {};
|
||||
const LazyTab = lazy(
|
||||
() =>
|
||||
new Promise<{ default: () => JSX.Element }>((resolve) => {
|
||||
resolveTab = resolve;
|
||||
}),
|
||||
);
|
||||
render(
|
||||
<RouteTab
|
||||
routes={[{ ...testRoutes[0], Component: LazyTab }, testRoutes[1]]}
|
||||
activeKey="Tab1"
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByRole('tab', { name: 'Tab1' })).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByLabelText('loading').closest('.ant-spin')?.parentElement,
|
||||
).toHaveStyle({ height: '100%' });
|
||||
|
||||
resolveTab({ default: DummyComponent1 });
|
||||
await expect(
|
||||
screen.findByText('Dummy Component 1'),
|
||||
).resolves.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { Suspense } from 'react';
|
||||
import { Tabs, TabsProps } from 'antd';
|
||||
import cx from 'classnames';
|
||||
import HeaderRightSection from 'components/HeaderRightSection/HeaderRightSection';
|
||||
import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar';
|
||||
import Spinner from 'components/Spinner';
|
||||
import { buildRoutePath } from 'lib/router/buildRoutePath';
|
||||
import { matchRoute } from 'lib/router/matchRoute';
|
||||
import { navigate } from 'lib/router/navigation';
|
||||
@@ -60,11 +58,7 @@ function RouteTab({
|
||||
tabKey: route,
|
||||
children: (
|
||||
<OverlayScrollbar>
|
||||
<Suspense
|
||||
fallback={<Spinner size="large" tip="Loading..." height="100%" />}
|
||||
>
|
||||
<Component />
|
||||
</Suspense>
|
||||
<Component />
|
||||
</OverlayScrollbar>
|
||||
),
|
||||
}));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PageTypeDTO } from '@signozhq/noz-client';
|
||||
import { PageTypeDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import ROUTES from 'constants/routes';
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
--input-focus-background: transparent;
|
||||
--input-focus-outline-width: 0;
|
||||
--input-box-shadow: none;
|
||||
--input-font-size: var(--label-base-400-font-size);
|
||||
--input-font-size: var(--periscope-font-size-base);
|
||||
--input-line-height: 20px;
|
||||
--input-placeholder-color: color-mix(
|
||||
in srgb,
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
}
|
||||
|
||||
.heading {
|
||||
font-size: var(--label-small-500-font-size);
|
||||
font-weight: var(--label-small-500-font-weight);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
font-weight: var(--font-weight-medium);
|
||||
line-height: 1;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
@@ -34,9 +34,9 @@
|
||||
--button-height: auto;
|
||||
--button-padding: var(--spacing-4) var(--spacing-6);
|
||||
--button-border-radius: var(--radius-3);
|
||||
--button-font-size: var(--label-base-400-font-size);
|
||||
--button-font-size: var(--periscope-font-size-base);
|
||||
--button-size-line-height: var(--line-height-20);
|
||||
--button-font-weight: var(--label-base-400-font-weight);
|
||||
--button-font-weight: var(--font-weight-normal);
|
||||
--button-variant-outlined-background-color: var(--l3-background-60);
|
||||
--button-variant-outlined-border: none;
|
||||
--button-variant-outlined-color: var(--l2-foreground);
|
||||
|
||||
@@ -16,11 +16,11 @@ import {
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { Button } from '@signozhq/ui/button';
|
||||
import { Tooltip } from '@signozhq/ui/tooltip';
|
||||
import type { MessageActionDTO } from '@signozhq/noz-client';
|
||||
import type { MessageActionDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import {
|
||||
ApplyFilterSignalDTO,
|
||||
MessageActionKindDTO,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import {
|
||||
restoreExecution,
|
||||
revertExecution,
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { MessageActionDTO, MessageActionKindDTO } from '@signozhq/noz-client';
|
||||
import {
|
||||
MessageActionDTO,
|
||||
MessageActionKindDTO,
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import logEvent from 'api/common/logEvent';
|
||||
import { getCurrentLocation, navigate } from 'lib/router/navigation';
|
||||
import { act, render, screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { undoExecution } from 'api/ai-assistant/chat';
|
||||
import type { MessageActionDTO } from '@signozhq/noz-client';
|
||||
import type { MessageActionDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import {
|
||||
ApplyFilterSignalDTO,
|
||||
MessageActionKindDTO,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import { Querybuildertypesv5RequestTypeDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApplyFilterSignalDTO } from '@signozhq/noz-client';
|
||||
import { ApplyFilterSignalDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import { Querybuildertypesv5RequestTypeDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
ApplyFilterSignalDTO,
|
||||
MessageActionKindDTO,
|
||||
SavedViewEntityDTO,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import {
|
||||
getSavedView,
|
||||
listSavedViews,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
type MessageActionDTO,
|
||||
MessageActionKindDTO,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
|
||||
import {
|
||||
isSavedViewOpenAction,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
ApplyFilterSignalDTO,
|
||||
type MessageActionDTOQuery,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import { Querybuildertypesv5RequestTypeDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MessageActionDTOQuery } from '@signozhq/noz-client';
|
||||
import type { MessageActionDTOQuery } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import { normalizeTimeToMs } from 'utils/timeUtils';
|
||||
|
||||
export interface ActionTimeRange {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import type { MessageActionDTO } from '@signozhq/noz-client';
|
||||
import { ApplyFilterSignalDTO, SavedViewEntityDTO } from '@signozhq/noz-client';
|
||||
import type { MessageActionDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import {
|
||||
ApplyFilterSignalDTO,
|
||||
SavedViewEntityDTO,
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
import { ResourceType } from './resourceRoute';
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: var(--label-small-500-font-size);
|
||||
font-weight: var(--label-small-500-font-weight);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
font-weight: var(--font-weight-medium);
|
||||
line-height: 18px;
|
||||
letter-spacing: -0.005em;
|
||||
}
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
.soloThought {
|
||||
margin: 0;
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
line-height: var(--line-height-20);
|
||||
letter-spacing: -0.005em;
|
||||
color: var(--l2-foreground);
|
||||
@@ -64,8 +64,8 @@
|
||||
|
||||
// While Noz works, the row names the step it's on.
|
||||
.live .activitySummary {
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-weight: var(--paragraph-base-400-font-weight);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
font-weight: var(--font-weight-normal);
|
||||
line-height: var(--line-height-20);
|
||||
@include shimmer-text(var(--l3-foreground), var(--l1-foreground));
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
border: none;
|
||||
background: none;
|
||||
font: inherit;
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
line-height: var(--line-height-20);
|
||||
letter-spacing: -0.005em;
|
||||
color: var(--l1-foreground);
|
||||
@@ -90,7 +90,7 @@ button.title {
|
||||
}
|
||||
|
||||
.detail {
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
line-height: var(--line-height-20);
|
||||
letter-spacing: -0.005em;
|
||||
color: var(--l2-foreground);
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
}
|
||||
|
||||
.headerLabel {
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--font-size-sm);
|
||||
line-height: var(--line-height-20);
|
||||
letter-spacing: -0.005em;
|
||||
color: var(--l1-foreground);
|
||||
@@ -61,7 +61,7 @@
|
||||
|
||||
.summary {
|
||||
margin: 0;
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
line-height: var(--line-height-20);
|
||||
color: var(--l2-foreground);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Tooltip } from '@signozhq/ui/tooltip';
|
||||
import type {
|
||||
ApprovalEventDTO,
|
||||
ApprovalEventDTODiff,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import {
|
||||
Check,
|
||||
Columns2,
|
||||
|
||||
@@ -134,8 +134,8 @@
|
||||
--button-padding: 7px #{$padding-inline};
|
||||
--button-border-radius: 0;
|
||||
--button-justify-content: flex-start;
|
||||
--button-font-size: var(--label-base-400-font-size);
|
||||
--button-font-weight: var(--label-base-400-font-weight);
|
||||
--button-font-size: var(--periscope-font-size-base);
|
||||
--button-font-weight: var(--font-weight-normal);
|
||||
--button-variant-ghost-color: var(--l2-foreground);
|
||||
--button-variant-ghost-hover-color: var(--l1-foreground);
|
||||
--button-variant-ghost-hover-background-color: var(--l3-background);
|
||||
@@ -180,8 +180,8 @@
|
||||
height: 44px;
|
||||
padding: 0 var(--spacing-7);
|
||||
border-bottom: 1px solid var(--l2-border);
|
||||
font-size: var(--label-small-600-font-size);
|
||||
font-weight: var(--label-small-600-font-weight);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
line-height: 1;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
border-radius: var(--radius-2);
|
||||
background: var(--l3-background-60);
|
||||
color: var(--l2-foreground);
|
||||
font-size: var(--label-small-500-font-size);
|
||||
font-weight: var(--label-small-500-font-weight);
|
||||
font-size: var(--font-size-xs);
|
||||
font-weight: var(--font-weight-medium);
|
||||
line-height: 15px;
|
||||
transition:
|
||||
background-color 0.12s,
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
}
|
||||
|
||||
.headerLabel {
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--font-size-sm);
|
||||
line-height: var(--line-height-20);
|
||||
letter-spacing: -0.005em;
|
||||
color: var(--l1-foreground);
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
.message {
|
||||
margin: 0;
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
line-height: var(--line-height-20);
|
||||
color: var(--l2-foreground);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ import { Input } from '@signozhq/ui/input';
|
||||
import { Select } from '@signozhq/ui/select';
|
||||
import type { SelectItemType } from '@signozhq/ui/select';
|
||||
import logEvent from 'api/common/logEvent';
|
||||
import { ClarificationFieldTypeDTO } from '@signozhq/noz-client';
|
||||
import { ClarificationFieldTypeDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import type {
|
||||
ClarificationEventDTO,
|
||||
ClarificationFieldEventDTO,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import { CircleHelp, Send, X } from '@signozhq/icons';
|
||||
|
||||
import { AIAssistantEvents } from '../../events';
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
line-height: 20px;
|
||||
letter-spacing: -0.005em;
|
||||
color: var(--text-vanilla-400);
|
||||
@@ -73,7 +73,7 @@
|
||||
// Wide enough to hold the action buttons that replace it.
|
||||
min-width: 16px;
|
||||
text-align: right;
|
||||
font-size: var(--paragraph-small-400-font-size);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
line-height: 18px;
|
||||
color: var(--l3-foreground);
|
||||
opacity: calc(1 - var(--actions-opacity, 0));
|
||||
@@ -87,7 +87,7 @@
|
||||
width: 100%;
|
||||
border-bottom: 1px solid var(--accent-primary);
|
||||
--input-padding: 1px 0;
|
||||
--input-font-size: var(--label-base-400-font-size);
|
||||
--input-font-size: var(--periscope-font-size-base);
|
||||
--input-hover-border-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
--button-border-radius: 3px;
|
||||
--button-justify-content: flex-start;
|
||||
--button-gap: var(--spacing-4);
|
||||
--button-font-weight: var(--label-base-400-font-weight);
|
||||
--button-font-weight: var(--font-weight-normal);
|
||||
--button-variant-outlined-background-color: var(--l2-background);
|
||||
--button-variant-outlined-border: 1px solid var(--l1-border);
|
||||
--button-variant-outlined-color: var(--l2-foreground);
|
||||
@@ -144,8 +144,8 @@
|
||||
.groupLabel {
|
||||
display: block;
|
||||
padding: 0 0 7px;
|
||||
font-size: var(--label-small-600-font-size);
|
||||
font-weight: var(--label-small-600-font-weight);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
line-height: 1;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
}
|
||||
|
||||
.note {
|
||||
font-size: var(--label-small-500-font-size);
|
||||
font-weight: var(--label-small-500-font-weight);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
font-weight: var(--font-weight-medium);
|
||||
line-height: 1;
|
||||
font-feature-settings:
|
||||
'tnum' on,
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
align-items: flex-start;
|
||||
background: var(--l2-background);
|
||||
color: var(--l1-foreground);
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
border-bottom-left-radius: var(--radius-2);
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@
|
||||
width: max-content;
|
||||
min-width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: var(--paragraph-base-400-font-size);
|
||||
font-size: var(--periscope-font-size-base);
|
||||
font-variant-numeric: tabular-nums;
|
||||
word-break: normal;
|
||||
|
||||
@@ -286,8 +286,8 @@
|
||||
|
||||
th {
|
||||
padding-block: 13px;
|
||||
font-size: var(--label-small-500-font-size);
|
||||
font-weight: var(--label-small-500-font-weight);
|
||||
font-size: var(--periscope-font-size-small);
|
||||
font-weight: var(--font-weight-medium);
|
||||
line-height: 1;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
|
||||
@@ -5,7 +5,7 @@ import remarkGfm from 'remark-gfm';
|
||||
import { Button } from '@signozhq/ui/button';
|
||||
import { RotateCw, TriangleAlert } from '@signozhq/icons';
|
||||
|
||||
import { RetryActionDTO } from '@signozhq/noz-client';
|
||||
import { RetryActionDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
|
||||
// Side-effect: registers all built-in block types into the BlockRegistry
|
||||
import '../blocks';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import React from 'react';
|
||||
import { render, screen, userEvent } from 'tests/test-utils';
|
||||
import { ErrorCodeDTO, RetryActionDTO } from '@signozhq/noz-client';
|
||||
import {
|
||||
ErrorCodeDTO,
|
||||
RetryActionDTO,
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
|
||||
import { Message } from '../../../types';
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { useTimezone } from 'providers/Timezone';
|
||||
|
||||
import logEvent from 'api/common/logEvent';
|
||||
|
||||
import { FeedbackRatingDTO } from '@signozhq/noz-client';
|
||||
import { FeedbackRatingDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import { AIAssistantEvents } from '../../events';
|
||||
import { useAIAssistantAnalyticsContext } from '../../hooks/useAIAssistantAnalyticsContext';
|
||||
import { useAIAssistantStore } from '../../store/useAIAssistantStore';
|
||||
|
||||
@@ -6,7 +6,7 @@ import remarkGfm from 'remark-gfm';
|
||||
import type {
|
||||
ApprovalEventDTO,
|
||||
ClarificationEventDTO,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
|
||||
import { useVariant } from '../../VariantContext';
|
||||
import { StreamingEventItem } from '../../types';
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
--button-height: 32px;
|
||||
--button-padding: 0 var(--spacing-6);
|
||||
--button-border-radius: var(--radius-round);
|
||||
--button-font-size: var(--label-base-400-font-size);
|
||||
--button-font-weight: var(--label-base-400-font-weight);
|
||||
--button-font-size: var(--periscope-font-size-base);
|
||||
--button-font-weight: var(--font-weight-normal);
|
||||
--button-secondary-background-color: var(--l3-background);
|
||||
--button-secondary-hover-background-color: var(--l3-background-hover);
|
||||
--button-secondary-solid-foreground: var(--l1-foreground);
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ArrowDown } from '@signozhq/icons';
|
||||
import type {
|
||||
ApprovalEventDTO,
|
||||
ClarificationEventDTO,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import logEvent from 'api/common/logEvent';
|
||||
|
||||
import { AIAssistantEvents } from '../../events';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ChipDTO } from '@signozhq/noz-client';
|
||||
import type { ChipDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
|
||||
/** Static empty-state chips used when the contextual chips API is unavailable. */
|
||||
export const EMPTY_STATE_CHIPS_FALLBACK: ChipDTO[] = [
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
||||
import { useQuery } from 'react-query';
|
||||
|
||||
import { getEmptyStateChips } from 'api/ai-assistant/chat';
|
||||
import type { ChipDTO } from '@signozhq/noz-client';
|
||||
import type { ChipDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
|
||||
import { useResolvePageType } from 'hooks/aiAssistant/useResolvePageType';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PageTypeDTO } from '@signozhq/noz-client';
|
||||
import { PageTypeDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import ROUTES from 'constants/routes';
|
||||
import { matchRoute } from 'lib/router/matchRoute';
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
MessageContextDTOType,
|
||||
MessageRoleDTO,
|
||||
RetryActionDTO,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import type {
|
||||
MessageContext,
|
||||
SSEEvent,
|
||||
|
||||
@@ -7,8 +7,8 @@ import { immer } from 'zustand/middleware/immer';
|
||||
import type {
|
||||
MessageActionDTO,
|
||||
MessageSummaryDTOBlocksAnyOfItem,
|
||||
} from '@signozhq/noz-client';
|
||||
import { RetryActionDTO } from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import { RetryActionDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
|
||||
import {
|
||||
approveExecution,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/**
|
||||
* UI types for the AI Assistant.
|
||||
*
|
||||
* Wherever the OpenAPI-generated DTOs in `@signozhq/noz-client`
|
||||
* Wherever the OpenAPI-generated DTOs in
|
||||
* `src/api/ai-assistant/sigNozAIAssistantAPI.schemas.ts`
|
||||
* already capture the right shape, this module re-exports them.
|
||||
*
|
||||
* A type is defined locally only when the UI needs a different shape than
|
||||
@@ -19,7 +20,7 @@ import type {
|
||||
MessageActionDTO,
|
||||
MessageActionKindDTO,
|
||||
RetryActionDTO,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import type { MessageContext } from 'api/ai-assistant/chat';
|
||||
|
||||
/** Client-only file attachment — no API equivalent (uploads happen via data URLs). */
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { AxiosError } from 'axios';
|
||||
import { ErrorCodeDTO, RetryActionDTO } from '@signozhq/noz-client';
|
||||
import {
|
||||
ErrorCodeDTO,
|
||||
RetryActionDTO,
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
|
||||
import { resolveAssistantError } from '../resolveAssistantError';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
RetryActionDTO,
|
||||
type ErrorBodyDTO,
|
||||
type ErrorResponseDTO,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
|
||||
export interface AssistantErrorResolution {
|
||||
/** User-facing copy: code-specific FE copy → backend message → caller fallback. */
|
||||
|
||||
@@ -83,7 +83,6 @@ import { MeterAggregateOperator } from 'types/common/queryBuilder';
|
||||
import { USER_ROLES } from 'types/roles';
|
||||
import { getDaysUntilExpiry } from 'utils/timeUtils';
|
||||
|
||||
import 'components/LearnMore/LearnMore.styles.scss';
|
||||
import './IngestionSettings.styles.scss';
|
||||
|
||||
const { Option } = Select;
|
||||
|
||||
@@ -30,6 +30,10 @@ jest.mock('@signozhq/ui/toast', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('@floating-ui/dom', () =>
|
||||
jest.requireActual('./floatingUiDomMock').floatingUiDomMock(),
|
||||
);
|
||||
|
||||
type AccountSettingsDrawerProps = ComponentProps<typeof AccountSettingsDrawer>;
|
||||
|
||||
const onClose = jest.fn() as jest.MockedFunction<
|
||||
|
||||
@@ -18,6 +18,19 @@ import {
|
||||
|
||||
import { renderListAlertRules, runSearchQuery } from './_helpers';
|
||||
|
||||
// jsdom has no layout, and Floating UI's getComputedStyle walk over every
|
||||
// popover ancestor costs ~1 s per open here, enough to time out under load.
|
||||
jest.mock('@floating-ui/dom', () => ({
|
||||
...jest.requireActual('@floating-ui/dom'),
|
||||
autoUpdate: (): (() => void) => (): void => {},
|
||||
computePosition: (
|
||||
_reference: unknown,
|
||||
_floating: unknown,
|
||||
{ placement = 'bottom', strategy = 'absolute' } = {},
|
||||
): Promise<unknown> =>
|
||||
Promise.resolve({ x: 0, y: 0, placement, strategy, middlewareData: {} }),
|
||||
}));
|
||||
|
||||
jest.setTimeout(15_000);
|
||||
|
||||
const VIEW_1_ORDER_BY = JSON.stringify({ columnName: 'name', order: 'asc' });
|
||||
|
||||
@@ -1,42 +1,13 @@
|
||||
import { QueryClient, QueryClientProvider } from 'react-query';
|
||||
import ROUTES from 'constants/routes';
|
||||
import { customRoleResponse } from 'mocks-server/__mockdata__/roles';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import {
|
||||
act,
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
waitFor,
|
||||
within,
|
||||
} from 'tests/test-utils';
|
||||
import {
|
||||
AUTHZ_CHECK_URL,
|
||||
authzMockResponse,
|
||||
setupAuthzAdmin,
|
||||
} from 'lib/authz/utils/authz-test-utils';
|
||||
import { render, screen, userEvent, waitFor, within } from 'tests/test-utils';
|
||||
import { setupAuthzAdmin } from 'lib/authz/utils/authz-test-utils';
|
||||
import { getCurrentLocation } from 'lib/router/navigation';
|
||||
|
||||
import CreateEditRolePage from '../CreateEditRolePage';
|
||||
|
||||
jest.mock('@monaco-editor/react', () => ({
|
||||
__esModule: true,
|
||||
default: ({
|
||||
value,
|
||||
onChange,
|
||||
}: {
|
||||
value: string;
|
||||
onChange: (next?: string) => void;
|
||||
}): JSX.Element => (
|
||||
<textarea
|
||||
data-testid="monaco-editor"
|
||||
value={value}
|
||||
onChange={(e): void => onChange(e.target.value)}
|
||||
/>
|
||||
),
|
||||
}));
|
||||
|
||||
const CUSTOM_ROLE_ID = '019c24aa-3333-0001-aaaa-111111111111';
|
||||
const rolesApiBase = '*/api/v1/roles';
|
||||
const VIEW_ROLE_URL = `${ROUTES.ROLE_DETAILS.replace(
|
||||
@@ -437,125 +408,4 @@ describe('EditRolePage', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('JSON view opened from the URL', () => {
|
||||
const roleGrants = roleWithTransactionGroups.data.transactionGroups;
|
||||
|
||||
function renderJsonView(client?: QueryClient): ReturnType<typeof render> {
|
||||
const page = <CreateEditRolePage />;
|
||||
return render(
|
||||
client ? (
|
||||
<QueryClientProvider client={client}>{page}</QueryClientProvider>
|
||||
) : (
|
||||
page
|
||||
),
|
||||
undefined,
|
||||
{
|
||||
initialRoute: `/settings/roles/${CUSTOM_ROLE_ID}/edit?name=Custom%20Role&viewMode=json`,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function readBuffer(editor: HTMLElement): unknown {
|
||||
return JSON.parse((editor as HTMLTextAreaElement).value);
|
||||
}
|
||||
|
||||
it('shows the role grants when the role loads after the authz check', async () => {
|
||||
server.use(
|
||||
rest.get(`${rolesApiBase}/:id`, (_req, res, ctx) =>
|
||||
res(ctx.delay(300), ctx.status(200), ctx.json(roleWithTransactionGroups)),
|
||||
),
|
||||
);
|
||||
|
||||
renderJsonView();
|
||||
|
||||
const editor = await screen.findByTestId('monaco-editor');
|
||||
expect(readBuffer(editor)).toStrictEqual(roleGrants);
|
||||
});
|
||||
|
||||
it('shows the role grants when the role loads before the authz check', async () => {
|
||||
server.use(
|
||||
rest.post(AUTHZ_CHECK_URL, async (req, res, ctx) => {
|
||||
const payload = await req.json();
|
||||
return res(
|
||||
ctx.delay(300),
|
||||
ctx.status(200),
|
||||
ctx.json(
|
||||
authzMockResponse(
|
||||
payload,
|
||||
payload.map(() => true),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
renderJsonView();
|
||||
|
||||
const editor = await screen.findByTestId('monaco-editor');
|
||||
expect(readBuffer(editor)).toStrictEqual(roleGrants);
|
||||
});
|
||||
|
||||
it('saves what was typed in the buffer even when the role refetches afterwards', async () => {
|
||||
const updatedBodies: unknown[] = [];
|
||||
let roleReads = 0;
|
||||
server.use(
|
||||
rest.get(`${rolesApiBase}/:id`, (_req, res, ctx) => {
|
||||
roleReads += 1;
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.json(
|
||||
roleReads === 1
|
||||
? roleWithTransactionGroups
|
||||
: {
|
||||
...roleWithTransactionGroups,
|
||||
data: {
|
||||
...roleWithTransactionGroups.data,
|
||||
transactionGroups: [
|
||||
{
|
||||
objectGroup: {
|
||||
resource: { kind: 'role', type: 'role' },
|
||||
selectors: ['*'],
|
||||
},
|
||||
relation: 'update',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
}),
|
||||
rest.put(`${rolesApiBase}/:id`, async (req, res, ctx) => {
|
||||
updatedBodies.push(await req.json());
|
||||
return res(ctx.status(200), ctx.json({ status: 'success' }));
|
||||
}),
|
||||
);
|
||||
|
||||
const user = userEvent.setup();
|
||||
const client = new QueryClient({
|
||||
defaultOptions: { queries: { retry: false } },
|
||||
});
|
||||
renderJsonView(client);
|
||||
|
||||
const editor = await screen.findByTestId('monaco-editor');
|
||||
await user.type(editor, '[[]', {
|
||||
initialSelectionStart: 0,
|
||||
initialSelectionEnd: (editor as HTMLTextAreaElement).value.length,
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
await client.invalidateQueries();
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(roleReads).toBeGreaterThan(1);
|
||||
});
|
||||
|
||||
await user.click(screen.getByTestId('save-button'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(updatedBodies).toHaveLength(1);
|
||||
});
|
||||
expect(updatedBodies[0]).toMatchObject({ transactionGroups: [] });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -86,9 +86,6 @@ export function useCreateEditRolePageActions(
|
||||
const { mutateAsync: updateRole, isLoading: isUpdating } =
|
||||
useUpdateRolePermissions();
|
||||
const isSaving = isCreating || isUpdating;
|
||||
// Editors read their initial value once, so stay loading until the fetched
|
||||
// role has been copied into local state.
|
||||
const isSeedingFromRole = !!rolePermissionsData && !isInitialized;
|
||||
|
||||
useEffect(() => {
|
||||
if (rolePermissionsData && !isInitialized) {
|
||||
@@ -232,7 +229,7 @@ export function useCreateEditRolePageActions(
|
||||
setEditorMode: handleModeChange,
|
||||
resources: localResources,
|
||||
setResources: handleResourcesChange,
|
||||
isLoading: isLoadingPermissions || isSeedingFromRole,
|
||||
isLoading: isLoadingPermissions,
|
||||
isSaving,
|
||||
hasUnsavedChanges,
|
||||
handleSave,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { PageTypeDTO } from '@signozhq/noz-client';
|
||||
import { PageTypeDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import type { AIAssistantVariant } from 'container/AIAssistant/VariantContext';
|
||||
import ROUTES from 'constants/routes';
|
||||
import { mockAppLocation } from 'tests/router-mocks';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
||||
|
||||
import { useAppLocation } from 'lib/router/useAppLocation';
|
||||
|
||||
import { PageTypeDTO } from '@signozhq/noz-client';
|
||||
import { PageTypeDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import { resolvePageType } from 'container/AIAssistant/resolvePageType';
|
||||
import { useVariant } from 'container/AIAssistant/VariantContext';
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--spacing-6);
|
||||
font-size: var(--label-base-500-font-size);
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
.subtitle {
|
||||
padding-left: calc(12px + var(--spacing-3));
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--paragraph-small-400-font-size);
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
.code {
|
||||
flex-shrink: 0;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--paragraph-small-400-font-size);
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
align-items: center;
|
||||
gap: var(--spacing-2);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--paragraph-small-400-font-size);
|
||||
font-size: var(--font-size-xs);
|
||||
letter-spacing: -0.01em;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import type {
|
||||
MessageSummaryDTO,
|
||||
ThreadDetailResponseDTO,
|
||||
ThreadListResponseDTO,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import {
|
||||
ApplyFilterSignalDTO,
|
||||
ApprovalActionTypeDTO,
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
MessageActionKindDTO,
|
||||
MessageContentTypeDTO,
|
||||
MessageRoleDTO,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import type {
|
||||
Conversation,
|
||||
ConversationStreamState,
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
* Do not hand-edit: regenerate instead.
|
||||
*/
|
||||
|
||||
import type { MessageSummaryDTO } from '@signozhq/noz-client';
|
||||
import type { MessageSummaryDTO } from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import {
|
||||
MessageContextDTOSource,
|
||||
MessageContextDTOType,
|
||||
} from '@signozhq/noz-client';
|
||||
} from 'api/ai-assistant/sigNozAIAssistantAPI.schemas';
|
||||
import type { MessageBlock } from 'container/AIAssistant/types';
|
||||
|
||||
/** The opening question's contexts: the thread shows the @-picked ones, not the page it was asked from. */
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import Loadable from 'components/Loadable';
|
||||
import { TabRoutes } from 'components/RouteTab/types';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import ROUTES from 'constants/routes';
|
||||
import AlertHistory from 'container/AlertHistory';
|
||||
import { AlertDetailsTab } from 'container/AlertHistory/types';
|
||||
import useUrlQuery from 'hooks/useUrlQuery';
|
||||
import { buildRoutePath } from 'lib/router/buildRoutePath';
|
||||
import { History, Table } from '@signozhq/icons';
|
||||
import EditRules from 'pages/EditRules';
|
||||
import BetaTag from 'periscope/components/BetaTag/BetaTag';
|
||||
|
||||
const EditRules = Loadable(() => import('pages/EditRules'));
|
||||
const AlertHistory = Loadable(() => import('container/AlertHistory'));
|
||||
|
||||
export const useRouteTabUtils = (): { routes: TabRoutes[] } => {
|
||||
const urlQuery = useUrlQuery();
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
.sizerValue {
|
||||
font-size: 12px;
|
||||
font-weight: var(--label-base-500-font-weight);
|
||||
font-weight: var(--font-weight-medium);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
}
|
||||
|
||||
.tooltipName {
|
||||
font-weight: var(--label-base-500-font-weight);
|
||||
font-weight: var(--font-weight-medium);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
.value {
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
font-weight: var(--label-base-500-font-weight);
|
||||
font-weight: var(--font-weight-medium);
|
||||
color: var(--l1-foreground);
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import ROUTES from 'constants/routes';
|
||||
import { render, screen } from 'tests/test-utils';
|
||||
import { USER_ROLES } from 'types/roles';
|
||||
|
||||
const mockBillingModuleLoaded = jest.fn();
|
||||
|
||||
jest.mock('pages/MembersSettings', () => ({
|
||||
__esModule: true,
|
||||
default: (): JSX.Element => <div data-testid="members-settings-tab" />,
|
||||
}));
|
||||
|
||||
jest.mock('container/BillingContainer/BillingContainer', () => {
|
||||
mockBillingModuleLoaded();
|
||||
return {
|
||||
__esModule: true,
|
||||
default: (): JSX.Element => <div data-testid="billing-settings-tab" />,
|
||||
};
|
||||
});
|
||||
|
||||
describe('SettingsPage tabs', () => {
|
||||
it('loads only the tab of the current route', async () => {
|
||||
const { default: SettingsPage } = await import('pages/Settings/Settings');
|
||||
|
||||
render(<SettingsPage />, undefined, {
|
||||
role: USER_ROLES.ADMIN,
|
||||
initialRoute: ROUTES.MEMBERS_SETTINGS,
|
||||
});
|
||||
|
||||
await expect(
|
||||
screen.findByTestId('members-settings-tab'),
|
||||
).resolves.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('billing-settings-tab')).not.toBeInTheDocument();
|
||||
expect(mockBillingModuleLoaded).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,16 @@
|
||||
import { lazy } from 'react';
|
||||
import Loadable from 'components/Loadable';
|
||||
import { RouteTabProps } from 'components/RouteTab/types';
|
||||
import ROUTES from 'constants/routes';
|
||||
import BillingContainer from 'container/BillingContainer/BillingContainer';
|
||||
import GeneralSettings from 'container/GeneralSettings';
|
||||
import GeneralSettingsCloud from 'container/GeneralSettingsCloud';
|
||||
import IngestionSettings from 'container/IngestionSettings/IngestionSettings';
|
||||
import MultiIngestionSettings from 'container/IngestionSettings/MultiIngestionSettings';
|
||||
import MCPServerSettings from 'container/MCPServerSettings/MCPServerSettings';
|
||||
import MySettings from 'container/MySettings';
|
||||
import OrganizationSettings from 'container/OrganizationSettings';
|
||||
import RolesSettings from 'container/RolesSettings';
|
||||
import CreateEditRolePage from 'container/RolesSettings/CreateEditRolePage';
|
||||
import ViewRolePage from 'container/RolesSettings/ViewRolePage';
|
||||
import { TFunction } from 'i18next';
|
||||
import {
|
||||
Backpack,
|
||||
@@ -15,41 +24,9 @@ import {
|
||||
User,
|
||||
Users,
|
||||
} from '@signozhq/icons';
|
||||
import { lazyRetry } from 'utils/lazyWithRetries';
|
||||
|
||||
const BillingContainer = Loadable(
|
||||
() => import('container/BillingContainer/BillingContainer'),
|
||||
);
|
||||
const GeneralSettings = Loadable(() => import('container/GeneralSettings'));
|
||||
const GeneralSettingsCloud = Loadable(
|
||||
() => import('container/GeneralSettingsCloud'),
|
||||
);
|
||||
const IngestionSettings = Loadable(
|
||||
() => import('container/IngestionSettings/IngestionSettings'),
|
||||
);
|
||||
const MultiIngestionSettings = Loadable(
|
||||
() => import('container/IngestionSettings/MultiIngestionSettings'),
|
||||
);
|
||||
const MCPServerSettings = Loadable(
|
||||
() => import('container/MCPServerSettings/MCPServerSettings'),
|
||||
);
|
||||
const MySettings = Loadable(() => import('container/MySettings'));
|
||||
const OrganizationSettings = Loadable(
|
||||
() => import('container/OrganizationSettings'),
|
||||
);
|
||||
const RolesSettings = Loadable(() => import('container/RolesSettings'));
|
||||
// Loadable's prop type rejects the authz HOC's ComponentType<object>.
|
||||
const CreateEditRolePage = lazy(() =>
|
||||
lazyRetry(() => import('container/RolesSettings/CreateEditRolePage')),
|
||||
);
|
||||
const ViewRolePage = Loadable(
|
||||
() => import('container/RolesSettings/ViewRolePage'),
|
||||
);
|
||||
const MembersSettings = Loadable(() => import('pages/MembersSettings'));
|
||||
const ServiceAccountsSettings = Loadable(
|
||||
() => import('pages/ServiceAccountsSettings'),
|
||||
);
|
||||
const Shortcuts = Loadable(() => import('pages/Shortcuts'));
|
||||
import MembersSettings from 'pages/MembersSettings';
|
||||
import ServiceAccountsSettings from 'pages/ServiceAccountsSettings';
|
||||
import Shortcuts from 'pages/Shortcuts';
|
||||
|
||||
export const organizationSettings = (t: TFunction): RouteTabProps['routes'] => [
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ import MyComponent from '../MyComponent';
|
||||
|
||||
describe('MyComponent', () => {
|
||||
it('renders and interacts', async () => {
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup({ pointerEventsCheck: 0 });
|
||||
|
||||
server.use(
|
||||
rest.get('*/api/v1/example', (_req, res, ctx) => res(ctx.status(200), ctx.json({ value: 42 })))
|
||||
@@ -40,8 +40,6 @@ 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`).
|
||||
- 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__`.
|
||||
- Keep tests type-safe (`jest.MockedFunction<T>`, avoid `any`).
|
||||
- Find elements by test ID (`getByTestId`, `findByTestId`); role or text only for markup the app doesn't own.
|
||||
@@ -50,7 +48,6 @@ The full list is [`.claude/rules/frontend-tests.md`](../../../.claude/rules/fron
|
||||
Repo-specific reasons:
|
||||
- The harness wires Redux, React Query, i18n, timezone, preferences, so importing from RTL directly bypasses critical providers.
|
||||
- Some infra deps are globally mocked (e.g., `uplot`) to keep tests fast and stable.
|
||||
- `jest.setup.ts` turns off user-event's pointer-events check, Floating UI positioning and antd's scroll-container lookup for every test. Each walks `getComputedStyle` up the DOM, which jsdom computes slowly.
|
||||
- For virtualization (react-virtuoso), there is no `userEvent` scroll helper; use `fireEvent.scroll` after setting `element.scrollTop`.
|
||||
|
||||
#### Example patterns (from `components/QuickFilters/tests/QuickFilters.test.tsx`)
|
||||
@@ -76,7 +73,7 @@ jest.mock('hooks/queryBuilder/useQueryBuilder', () => ({
|
||||
|
||||
Interact via test IDs:
|
||||
```ts
|
||||
const user = userEvent.setup();
|
||||
const user = userEvent.setup({ pointerEventsCheck: 0 });
|
||||
await user.click(screen.getByTestId('save-changes'));
|
||||
expect(screen.getByText(/ADDED FILTERS/i)).toBeInTheDocument();
|
||||
```
|
||||
@@ -116,5 +113,5 @@ const navigateSpy = mockNavigate(); // module-level navigate()
|
||||
```
|
||||
|
||||
#### Notes
|
||||
- Global mocks configured in Jest: `uplot` → `__mocks__/uplotMock.ts`; `@floating-ui/dom`, `@testing-library/user-event` and antd's `collectScroller` in `jest.setup.ts`.
|
||||
- Global mocks configured in Jest: `uplot` → `__mocks__/uplotMock.ts`.
|
||||
- If a test needs custom behavior (e.g., different API response), override with `server.use(...)` locally.
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
import { render, screen, userEvent } from 'tests/test-utils';
|
||||
|
||||
describe('userEvent from the harness', () => {
|
||||
const onClick = jest.fn() as jest.MockedFunction<
|
||||
React.MouseEventHandler<HTMLButtonElement>
|
||||
>;
|
||||
|
||||
const renderBlockedButton = (): void => {
|
||||
render(
|
||||
<button
|
||||
type="button"
|
||||
data-testid="blocked"
|
||||
style={{ pointerEvents: 'none' }}
|
||||
onClick={onClick}
|
||||
>
|
||||
Blocked
|
||||
</button>,
|
||||
);
|
||||
};
|
||||
|
||||
it('skips the pointer-events check for setup()', async () => {
|
||||
renderBlockedButton();
|
||||
|
||||
await userEvent.setup().click(screen.getByTestId('blocked'));
|
||||
|
||||
expect(onClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('skips the pointer-events check for the direct API', async () => {
|
||||
renderBlockedButton();
|
||||
|
||||
await userEvent.click(screen.getByTestId('blocked'));
|
||||
|
||||
expect(onClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@@ -1,60 +0,0 @@
|
||||
type UserEventModule = typeof import('@testing-library/user-event');
|
||||
type UserEvent = UserEventModule['default'];
|
||||
type DirectMethod = Exclude<keyof UserEvent, 'setup'>;
|
||||
|
||||
const actual = jest.requireActual<UserEventModule>(
|
||||
'@testing-library/user-event',
|
||||
);
|
||||
const userEvent = actual.default;
|
||||
|
||||
// The pointer-events check walks getComputedStyle up the tree on every action.
|
||||
const DEFAULTS = {
|
||||
pointerEventsCheck: actual.PointerEventsCheckLevel.Never,
|
||||
};
|
||||
|
||||
// Position of the options argument in each direct API call.
|
||||
const OPTIONS_INDEX: Record<Exclude<DirectMethod, 'clear'>, number> = {
|
||||
copy: 0,
|
||||
cut: 0,
|
||||
tab: 0,
|
||||
click: 1,
|
||||
dblClick: 1,
|
||||
tripleClick: 1,
|
||||
hover: 1,
|
||||
unhover: 1,
|
||||
keyboard: 1,
|
||||
pointer: 1,
|
||||
paste: 1,
|
||||
deselectOptions: 2,
|
||||
selectOptions: 2,
|
||||
type: 2,
|
||||
upload: 2,
|
||||
};
|
||||
|
||||
const withDefaults =
|
||||
(name: DirectMethod, optionsIndex: number) =>
|
||||
(...args: unknown[]): Promise<unknown> => {
|
||||
const next = [...args];
|
||||
next[optionsIndex] = {
|
||||
...DEFAULTS,
|
||||
...(next[optionsIndex] as object | undefined),
|
||||
};
|
||||
return Reflect.apply(userEvent[name], userEvent, next);
|
||||
};
|
||||
|
||||
const directApi = Object.fromEntries(
|
||||
Object.entries(OPTIONS_INDEX).map(([name, index]) => [
|
||||
name,
|
||||
withDefaults(name as DirectMethod, index),
|
||||
]),
|
||||
);
|
||||
|
||||
const userEventWithDefaults: UserEvent = {
|
||||
...userEvent,
|
||||
...directApi,
|
||||
clear: (element) => userEvent.setup(DEFAULTS).clear(element),
|
||||
setup: (options) => userEvent.setup({ ...DEFAULTS, ...options }),
|
||||
};
|
||||
|
||||
export const { PointerEventsCheckLevel } = actual;
|
||||
export default userEventWithDefaults;
|
||||
@@ -188,6 +188,15 @@ export default defineConfig(({ mode }): UserConfig => {
|
||||
sourcemap: true,
|
||||
outDir: 'build',
|
||||
cssMinify: 'esbuild',
|
||||
// The Go server caches /assets/ as immutable, so every file there must carry a content hash.
|
||||
assetsDir: 'assets',
|
||||
rolldownOptions: {
|
||||
output: {
|
||||
entryFileNames: 'assets/[name]-[hash].js',
|
||||
chunkFileNames: 'assets/[name]-[hash].js',
|
||||
assetFileNames: 'assets/[name]-[hash].[ext]',
|
||||
},
|
||||
},
|
||||
},
|
||||
server: {
|
||||
open: true,
|
||||
|
||||
@@ -71,20 +71,6 @@ type KafkaConfig struct {
|
||||
|
||||
// ShutdownTimeout bounds draining buffered events on stop; events still undelivered when it expires are dropped.
|
||||
ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout"`
|
||||
|
||||
TLS TLSConfig `mapstructure:"tls"`
|
||||
}
|
||||
|
||||
type TLSConfig struct {
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
|
||||
// CAFile is the PEM bundle that verifies the server certificate. Empty uses the system roots.
|
||||
CAFile string `mapstructure:"ca_file"`
|
||||
|
||||
// CertFile and KeyFile are the client certificate, presented when the server requires client auth.
|
||||
CertFile string `mapstructure:"cert_file"`
|
||||
|
||||
KeyFile string `mapstructure:"key_file"`
|
||||
}
|
||||
|
||||
// RetryConfig configures exponential backoff for the OTLP HTTP exporter.
|
||||
@@ -182,10 +168,6 @@ func (c Config) Validate() error {
|
||||
if c.Kafka.ShutdownTimeout <= 0 {
|
||||
return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "auditor::kafka::shutdown_timeout must be greater than 0")
|
||||
}
|
||||
|
||||
if c.Kafka.TLS.Enabled && (c.Kafka.TLS.CertFile == "") != (c.Kafka.TLS.KeyFile == "") {
|
||||
return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "auditor::kafka::tls::cert_file and auditor::kafka::tls::key_file must be set together")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -30,10 +30,6 @@ func (h *provider) BeforeQuery(ctx context.Context, _ *telemetrystore.QueryEvent
|
||||
|
||||
settings["log_comment"] = ctxtypes.CommentFromContext(ctx).String()
|
||||
|
||||
// The result model has no Variant type: mismatched types must fail with the
|
||||
// no-common-type error rather than become a Variant (the 26.8 default).
|
||||
settings["use_variant_as_common_type"] = 0
|
||||
|
||||
if ctx.Value("enforce_max_result_rows") != nil {
|
||||
settings["max_result_rows"] = h.settings.MaxResultRows
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@ import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/SigNoz/signoz/pkg/errors"
|
||||
"github.com/SigNoz/signoz/pkg/factory"
|
||||
@@ -16,6 +18,11 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
const (
|
||||
assetsPathPrefix = "/assets/"
|
||||
immutableCacheControl = "public, max-age=31536000, immutable"
|
||||
)
|
||||
|
||||
type provider struct {
|
||||
config web.Config
|
||||
indexContents []byte
|
||||
@@ -78,10 +85,10 @@ func (provider *provider) AddToRouter(router *mux.Router) error {
|
||||
|
||||
func (provider *provider) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
// Join internally call path.Clean to prevent directory traversal
|
||||
path := filepath.Join(provider.config.Directory, req.URL.Path)
|
||||
filePath := filepath.Join(provider.config.Directory, req.URL.Path)
|
||||
|
||||
// check whether a file exists or is a directory at the given path
|
||||
fi, err := os.Stat(path)
|
||||
fi, err := os.Stat(filePath)
|
||||
if err != nil {
|
||||
// if the file doesn't exist, serve index.html
|
||||
if os.IsNotExist(err) {
|
||||
@@ -101,6 +108,12 @@ func (provider *provider) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// files under /assets/ are content-hashed, so their URL changes with their content.
|
||||
// A non-canonical URL can name a file outside /assets/ or get a redirect.
|
||||
if req.URL.Path == path.Clean(req.URL.Path) && strings.HasPrefix(req.URL.Path, assetsPathPrefix) {
|
||||
rw.Header().Set("Cache-Control", immutableCacheControl)
|
||||
}
|
||||
|
||||
// otherwise, use http.FileServer to serve the static file
|
||||
provider.fileHandler.ServeHTTP(rw, req)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -251,3 +252,87 @@ func TestServeStaticFilesUnchanged(t *testing.T) {
|
||||
|
||||
assert.Equal(t, string(expected), httpGet(t, base+"/assets/style.css"))
|
||||
}
|
||||
|
||||
func TestServeCacheControl(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
directory := t.TempDir()
|
||||
files := map[string]string{
|
||||
"index.html": "<html>index</html>",
|
||||
"assets/x.js": "console.log('x')",
|
||||
"assets/nested/y.css": "body{}",
|
||||
"assets-legacy/z.js": "console.log('z')",
|
||||
"favicon.ico": "icon",
|
||||
"css/uPlot.min.css": ".uplot{}",
|
||||
"locales/en/main.json": "{}",
|
||||
}
|
||||
for name, content := range files {
|
||||
require.NoError(t, os.MkdirAll(filepath.Join(directory, filepath.Dir(name)), 0o755))
|
||||
require.NoError(t, os.WriteFile(filepath.Join(directory, name), []byte(content), 0o644))
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
basePath string
|
||||
path string
|
||||
expectedStatus int
|
||||
expectedBody string
|
||||
expectedCC string
|
||||
}{
|
||||
{name: "ExistingAsset_Immutable", path: "/assets/x.js", expectedBody: files["assets/x.js"], expectedCC: "public, max-age=31536000, immutable"},
|
||||
{name: "ExistingNestedAsset_Immutable", path: "/assets/nested/y.css", expectedBody: files["assets/nested/y.css"], expectedCC: "public, max-age=31536000, immutable"},
|
||||
{name: "MissingAsset_ServesIndex_NoCache", path: "/assets/missing-AAAA.js", expectedBody: files["index.html"], expectedCC: "max-age=0,no-cache,private,must-revalidate"},
|
||||
{name: "AssetsDirectory_ServesIndex_NoCache", path: "/assets/nested/", expectedBody: files["index.html"], expectedCC: "max-age=0,no-cache,private,must-revalidate"},
|
||||
{name: "Root_ServesIndex_NoCache", path: "/", expectedBody: files["index.html"], expectedCC: "max-age=0,no-cache,private,must-revalidate"},
|
||||
{name: "UnknownRoute_ServesIndex_NoCache", path: "/does-not-exist", expectedBody: files["index.html"], expectedCC: "max-age=0,no-cache,private,must-revalidate"},
|
||||
{name: "NonAssetFile_NoCache", path: "/favicon.ico", expectedBody: files["favicon.ico"], expectedCC: "max-age=0,no-cache,private,must-revalidate"},
|
||||
{name: "NonAssetNestedFile_NoCache", path: "/css/uPlot.min.css", expectedBody: files["css/uPlot.min.css"], expectedCC: "max-age=0,no-cache,private,must-revalidate"},
|
||||
{name: "LocaleFile_NoCache", path: "/locales/en/main.json", expectedBody: files["locales/en/main.json"], expectedCC: "max-age=0,no-cache,private,must-revalidate"},
|
||||
{name: "AssetsPrefixLookalike_NoCache", path: "/assets-legacy/z.js", expectedBody: files["assets-legacy/z.js"], expectedCC: "max-age=0,no-cache,private,must-revalidate"},
|
||||
{name: "BasePath_ExistingAsset_Immutable", basePath: "/signoz", path: "/assets/x.js", expectedBody: files["assets/x.js"], expectedCC: "public, max-age=31536000, immutable"},
|
||||
{name: "BasePath_MissingAsset_ServesIndex_NoCache", basePath: "/signoz", path: "/assets/missing-AAAA.js", expectedBody: files["index.html"], expectedCC: "max-age=0,no-cache,private,must-revalidate"},
|
||||
{name: "BasePath_NonAssetFile_NoCache", basePath: "/signoz", path: "/favicon.ico", expectedBody: files["favicon.ico"], expectedCC: "max-age=0,no-cache,private,must-revalidate"},
|
||||
{name: "AssetTrailingSlash_Redirects_NoCache", path: "/assets/x.js/", expectedStatus: http.StatusMovedPermanently, expectedCC: "max-age=0,no-cache,private,must-revalidate"},
|
||||
{name: "EncodedDotDotOutOfAssets_NoCache", path: "/assets/%2e%2e/locales/en/main.json", expectedBody: files["locales/en/main.json"], expectedCC: "max-age=0,no-cache,private,must-revalidate"},
|
||||
{name: "BasePath_Root_ServesIndex_NoCache", basePath: "/signoz", path: "/", expectedBody: files["index.html"], expectedCC: "max-age=0,no-cache,private,must-revalidate"},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
routerWeb, err := New(
|
||||
context.Background(),
|
||||
factorytest.NewSettings(),
|
||||
web.Config{Index: "index.html", Directory: directory},
|
||||
global.Config{ExternalURL: &url.URL{Path: testCase.basePath}},
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
router := mux.NewRouter().UseEncodedPath()
|
||||
require.NoError(t, routerWeb.AddToRouter(router))
|
||||
|
||||
var handler http.Handler = router
|
||||
if testCase.basePath != "" {
|
||||
handler = http.StripPrefix(testCase.basePath, router)
|
||||
}
|
||||
|
||||
server := httptest.NewServer(handler)
|
||||
t.Cleanup(server.Close)
|
||||
|
||||
client := &http.Client{CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
|
||||
res, err := client.Get(server.URL + testCase.basePath + testCase.path)
|
||||
require.NoError(t, err)
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
|
||||
body, err := io.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedStatus := testCase.expectedStatus
|
||||
if expectedStatus == 0 {
|
||||
expectedStatus = http.StatusOK
|
||||
}
|
||||
assert.Equal(t, expectedStatus, res.StatusCode)
|
||||
assert.Equal(t, testCase.expectedCC, res.Header.Get("Cache-Control"))
|
||||
assert.Equal(t, testCase.expectedBody, string(body))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,6 @@ def pytest_addoption(parser: pytest.Parser):
|
||||
parser.addoption(
|
||||
"--signoz-otel-collector-version",
|
||||
action="store",
|
||||
default="v0.144.17",
|
||||
default="v0.144.16-rc.1",
|
||||
help="signoz-otel-collector version, used to run clickhouse migrations",
|
||||
)
|
||||
|
||||
@@ -144,13 +144,14 @@ def test_timestamp_counting_aggregations_are_numeric(
|
||||
assert raw > 0, f"{expression} returned {raw!r}, expected a positive rate"
|
||||
|
||||
|
||||
# KNOWN GAP, pinned deliberately: ClickHouse rejects sum over DateTime64, and rate_*
|
||||
# KNOWN GAP, pinned deliberately: ClickHouse rejects sum/avg over DateTime64, and rate_*
|
||||
# additionally divides a time by an interval; both surface as the generic 500. They returned
|
||||
# a meaningless seconds number before #5824. Flip to BAD_REQUEST once validated up front.
|
||||
@pytest.mark.parametrize(
|
||||
"expression",
|
||||
[
|
||||
"sum(timestamp)",
|
||||
"avg(timestamp)",
|
||||
"rate_sum(timestamp)",
|
||||
"rate_avg(timestamp)",
|
||||
"rate_min(timestamp)",
|
||||
|
||||
Reference in New Issue
Block a user