Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions apps/e2e/src/generated/test-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2521,6 +2521,12 @@ export const TestIds = {
sqlSidebarResize: 'sql-sidebar-resize',
/** button */
sqlSidebarToggle: (id: string | number) => `sql-sidebar-toggle-${id}`,
/** button · Expand SQL editor pane (75%) */
sqlSplitEditorMax: 'sql-split-editor-max',
/** button · Balanced split (48% / 52%) */
sqlSplitEqual: 'sql-split-equal',
/** button · Expand results grid pane (78%) */
sqlSplitResultsMax: 'sql-split-results-max',
},
SqlRunsDrawer: {
/** button · Clear recent */
Expand Down Expand Up @@ -3727,10 +3733,28 @@ export const TestIds = {
pipeCredentialOption: (id: string | number) => `pipe-credential-option-${id}`,
/** button · Filter by name, kind, id… */
pipeCredentialTrigger: 'pipe-credential-trigger',
/** Button */
workflowAggregateAddMetric: 'workflow-aggregate-add-metric',
/** Input · Output field */
workflowAggregateAs: (idx: string | number) => `workflow-aggregate-as-${idx}`,
/** Input */
workflowAggregateField: (idx: string | number) => `workflow-aggregate-field-${idx}`,
/** Select */
workflowAggregateFn: (idx: string | number) => `workflow-aggregate-fn-${idx}`,
/** Input · Aggregate group by fields */
workflowAggregateGroupBy: 'workflow-aggregate-group-by',
/** Button */
workflowAggregateRemove: (idx: string | number) => `workflow-aggregate-remove-${idx}`,
/** Select · Dedupe keep occurrence */
workflowDedupeKeep: 'workflow-dedupe-keep',
/** Input · Dedupe key fields */
workflowDedupeKeys: 'workflow-dedupe-keys',
/** input */
workflowInspectorConcurrency: 'workflow-inspector-concurrency',
/** select */
workflowInspectorField: (name: string | number) => `workflow-inspector-field-${name}`,
/** button · Format JSON */
workflowInspectorFormatRaw: 'workflow-inspector-format-raw',
/** input */
workflowInspectorHttpRetryAttempts: 'workflow-inspector-http-retry-attempts',
/** input */
Expand Down Expand Up @@ -3761,6 +3785,14 @@ export const TestIds = {
workflowInspectorTrigger: 'workflow-inspector-trigger',
/** select */
workflowInspectorType: 'workflow-inspector-type',
/** Input · Redact fields */
workflowRedactFields: 'workflow-redact-fields',
/** Select · Redact strategy */
workflowRedactStrategy: 'workflow-redact-strategy',
/** button */
workflowScriptExpand: 'workflow-script-expand',
/** Button */
workflowScriptSnippet: (id: string | number) => `workflow-script-snippet-${id}`,
},
MultiHttpEditor: {
/** Button */
Expand Down Expand Up @@ -3821,6 +3853,10 @@ export const TestIds = {
workflowRunAnswerForKey: (key: string | number) => `workflow-run-answer-${key}`,
/** Button */
workflowRunCancel: 'workflow-run-cancel',
/** Button · Open this workflow in Designer */
workflowRunOpenWorkflow: 'workflow-run-open-workflow',
/** Button */
workflowRunRerun: 'workflow-run-rerun',
/** Button */
workflowRunResume: 'workflow-run-resume',
/** aside · Run */
Expand Down Expand Up @@ -3855,10 +3891,20 @@ export const TestIds = {
workflowSqlAddColumnMapping: 'workflow-sql-add-column-mapping',
/** Button · Populate columns from selected table */
workflowSqlAutomap: 'workflow-sql-automap',
/** input */
workflowSqlCreateTableIfMissing: 'workflow-sql-create-table-if-missing',
/** Input · null */
workflowSqlDefault: (index: string | number) => `workflow-sql-default-${index}`,
/** button */
workflowSqlExpand: 'workflow-sql-expand',
/** button · Format SQL */
workflowSqlFormat: 'workflow-sql-format',
/** Button · Insert bound record parameter placeholder */
workflowSqlInsertRecordToken: 'workflow-sql-insert-record-token',
/** Input · Upsert key */
workflowSqlInsertUpsertKey: 'workflow-sql-insert-upsert-key',
/** Button · Insert bound workflow variable parameter placeholder */
workflowSqlInsertVarToken: 'workflow-sql-insert-var-token',
/** button */
workflowSqlKeyCol: (index: string | number) => `workflow-sql-key-col-${index}`,
/** tr */
Expand All @@ -3875,6 +3921,12 @@ export const TestIds = {
workflowSqlTable: 'workflow-sql-table',
/** Input · e.g. user_id */
workflowSqlTargetCol: (index: string | number) => `workflow-sql-target-col-${index}`,
/** Button · Insert DBA schema catalog inspection query */
workflowSqlTemplateCatalog: 'workflow-sql-template-catalog',
/** Button · Insert DBA table row-count verification query */
workflowSqlTemplateCounts: 'workflow-sql-template-counts',
/** input */
workflowSqlTransaction: 'workflow-sql-transaction',
/** Input · value.trim() */
workflowSqlTransform: (index: string | number) => `workflow-sql-transform-${index}`,
/** Input · Update condition */
Expand Down Expand Up @@ -3973,6 +4025,8 @@ export const TestIds = {
workflowDesignerStageSelect: 'workflow-designer-stage-select',
/** Button */
workflowDesignerTriggers: 'workflow-designer-triggers',
/** span · This workflow has unsaved changes */
workflowDesignerUnsavedBadge: 'workflow-designer-unsaved-badge',
},
WorkflowLogPanel: {
/** div · Log · */
Expand Down Expand Up @@ -4005,12 +4059,16 @@ export const TestIds = {
workflowEmptyAddSamples: 'workflow-empty-add-samples',
/** input */
workflowListFile: 'workflow-list-file',
/** button */
workflowListFilter: (key: string | number) => `workflow-list-filter-${key}`,
/** button · Open this workflow's log */
workflowListLastRun: (id: string | number) => `workflow-list-last-run-${id}`,
/** Button · Log: runs, failures and what to check */
workflowListLogs: (id: string | number) => `workflow-list-logs-${id}`,
/** button · Open in designer */
workflowListOpenInDesigner: (id: string | number) => `workflow-list-open-in-designer-${id}`,
/** Button */
workflowListRun: (id: string | number) => `workflow-list-run-${id}`,
},
WorkflowView: {
/** nav · Workflow */
Expand Down Expand Up @@ -5559,6 +5617,9 @@ export type TestId =
| `sql-sidebar-resize-${string}`
| `sql-sidebar-toggle-${string}`
| 'sql-sidebar-utilities'
| 'sql-split-editor-max'
| 'sql-split-equal'
| 'sql-split-results-max'
| `sql-statement-copy-${string}`
| 'sql-statement-gutter'
| `sql-statement-include-${string}`
Expand Down Expand Up @@ -5778,6 +5839,12 @@ export type TestId =
| 'view-workflow-btn'
| 'warning-banner'
| 'workflow-add-sample'
| 'workflow-aggregate-add-metric'
| `workflow-aggregate-as-${string}`
| `workflow-aggregate-field-${string}`
| `workflow-aggregate-fn-${string}`
| 'workflow-aggregate-group-by'
| `workflow-aggregate-remove-${string}`
| 'workflow-cron-sql'
| 'workflow-cron-sql-connection-backdrop'
| 'workflow-cron-sql-connection-clear'
Expand All @@ -5789,6 +5856,8 @@ export type TestId =
| 'workflow-cron-sql-only-when-rows'
| 'workflow-cron-sql-script'
| 'workflow-cron-sql-transaction'
| 'workflow-dedupe-keep'
| 'workflow-dedupe-keys'
| 'workflow-designer-add-sample'
| 'workflow-designer-auto-layout'
| 'workflow-designer-breadcrumb-workflows'
Expand All @@ -5806,6 +5875,7 @@ export type TestId =
| `workflow-designer-stage-overview-${string}`
| 'workflow-designer-stage-select'
| 'workflow-designer-triggers'
| 'workflow-designer-unsaved-badge'
| 'workflow-empty-add-samples'
| 'workflow-engine'
| `workflow-engine-${string}`
Expand Down Expand Up @@ -5854,6 +5924,7 @@ export type TestId =
| 'workflow-http-variables'
| 'workflow-inspector-concurrency'
| `workflow-inspector-field-${string}`
| 'workflow-inspector-format-raw'
| 'workflow-inspector-http-retry-attempts'
| 'workflow-inspector-intent'
| `workflow-inspector-json-${string}`
Expand All @@ -5870,9 +5941,11 @@ export type TestId =
| 'workflow-inspector-trigger'
| 'workflow-inspector-type'
| 'workflow-list-file'
| `workflow-list-filter-${string}`
| `workflow-list-last-run-${string}`
| `workflow-list-logs-${string}`
| `workflow-list-open-in-designer-${string}`
| `workflow-list-run-${string}`
| 'workflow-logs'
| `workflow-logs-all-events-${string}`
| 'workflow-logs-back'
Expand Down Expand Up @@ -5909,9 +5982,13 @@ export type TestId =
| 'workflow-palette-search-pipes'
| 'workflow-palette-show-advanced'
| `workflow-pipe-node-${string}`
| 'workflow-redact-fields'
| 'workflow-redact-strategy'
| 'workflow-run-answer'
| `workflow-run-answer-${string}`
| 'workflow-run-cancel'
| 'workflow-run-open-workflow'
| 'workflow-run-rerun'
| 'workflow-run-resume'
| 'workflow-runs-detail'
| 'workflow-runs-download-json'
Expand All @@ -5920,6 +5997,8 @@ export type TestId =
| 'workflow-runs-filter-workflow'
| 'workflow-runs-live'
| 'workflow-runs-problems-only'
| 'workflow-script-expand'
| `workflow-script-snippet-${string}`
| `workflow-sink-${string}`
| 'workflow-source-add-column'
| 'workflow-source-add-delimiter'
Expand Down Expand Up @@ -5955,8 +6034,13 @@ export type TestId =
| 'workflow-source-trim'
| 'workflow-sql-add-column-mapping'
| 'workflow-sql-automap'
| 'workflow-sql-create-table-if-missing'
| `workflow-sql-default-${string}`
| 'workflow-sql-expand'
| 'workflow-sql-format'
| 'workflow-sql-insert-record-token'
| 'workflow-sql-insert-upsert-key'
| 'workflow-sql-insert-var-token'
| `workflow-sql-key-col-${string}`
| `workflow-sql-mapping-row-${string}`
| 'workflow-sql-pipe-browse'
Expand All @@ -5965,6 +6049,9 @@ export type TestId =
| `workflow-sql-source-prop-${string}`
| 'workflow-sql-table'
| `workflow-sql-target-col-${string}`
| 'workflow-sql-template-catalog'
| 'workflow-sql-template-counts'
| 'workflow-sql-transaction'
| `workflow-sql-transform-${string}`
| 'workflow-sql-upsert-condition'
| 'workflow-sql-upsert-keys'
Expand Down
19 changes: 19 additions & 0 deletions apps/web/src/frontend/features/auth/components/AuthPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,23 @@ describe('an emailed link in a browser that is already signed in', () => {
});
expect(screen.getByTestId('auth-link-signed-in')).toBeTruthy();
});

it('does not leak non-DOM capsLock prop onto password inputs', () => {
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
const modSpy = vi.spyOn(KeyboardEvent.prototype, 'getModifierState').mockImplementation((k) => k === 'CapsLock');
try {
useAuthStore.setState({ status: 'anon', user: null, setupState: null });
const { unmount } = render(<AuthPage />);
const passwordInput = screen.getByLabelText(/^password$/i) as HTMLInputElement;
expect(passwordInput.hasAttribute('capsLock')).toBe(false);
expect(passwordInput.hasAttribute('capslock')).toBe(false);
fireEvent.keyDown(passwordInput, { key: 'A' });
expect(screen.getByTestId('caps-lock-hint')).toBeTruthy();
expect(errorSpy).not.toHaveBeenCalled();
unmount();
} finally {
modSpy.mockRestore();
errorSpy.mockRestore();
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ const SignInForm: React.FC<{
required
value={password}
onChange={(e) => setPassword(e.target.value)}
{...caps}
{...caps.inputProps}
placeholder="••••••••"
autoComplete="current-password"
className={`w-full ${authInputCls}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function useCapsLock() {
const onKey = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (typeof e.getModifierState === 'function') setOn(e.getModifierState('CapsLock'));
};
return { capsLock: on, onKeyDown: onKey, onKeyUp: onKey };
return { capsLock: on, inputProps: { onKeyDown: onKey, onKeyUp: onKey } };
}

export const CapsLockHint: React.FC<{ on: boolean }> = ({ on }) =>
Expand Down Expand Up @@ -147,7 +147,7 @@ export const NewPasswordFields: React.FC<Props> = ({
if (generated && e.target.value !== generated) setGenerated(null);
onPassword(e.target.value);
}}
{...caps}
{...caps.inputProps}
placeholder={`At least ${PASSWORD_MIN_LENGTH} characters`}
autoComplete="new-password"
aria-describedby="auth-password-rules"
Expand Down Expand Up @@ -197,7 +197,7 @@ export const NewPasswordFields: React.FC<Props> = ({
required
value={confirm}
onChange={(e) => onConfirm(e.target.value)}
{...caps}
{...caps.inputProps}
autoComplete="new-password"
aria-invalid={mismatch || undefined}
className={`w-full ${authInputCls}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,32 @@ import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { EditorTabBar } from './EditorTabBar';
import type { SqlTab } from '@/features/sql-editor/state/sqlEditorTabLogic';
import { quoteSqlIdentifier, splitSqlStatements } from '@/shared/lib/sql-splitter';
import { formatSql, loadSqlFormatter } from '@/shared/utils/formatSql';

const ALL_CONNECTIONS = [
{ id: 'c-pg', name: 'Postgres', dialect: 'postgres' },
{ id: 'c-crdb', name: 'Cockroach', dialect: 'cockroachdb' },
{ id: 'c-yb', name: 'Yugabyte', dialect: 'yugabytedb' },
{ id: 'c-rs', name: 'Redshift', dialect: 'redshift' },
{ id: 'c-my', name: 'MySQL', dialect: 'mysql' },
{ id: 'c-maria', name: 'MariaDB', dialect: 'mariadb' },
{ id: 'c-tidb', name: 'TiDB', dialect: 'tidb' },
{ id: 'c-sqlite', name: 'SQLite', dialect: 'sqlite' },
{ id: 'c-duck', name: 'DuckDB', dialect: 'duckdb' },
{ id: 'c-ms', name: 'SQL Server', dialect: 'sqlserver' },
{ id: 'c-azure', name: 'Azure SQL', dialect: 'azuresql' },
{ id: 'c-ora', name: 'Oracle', dialect: 'oracle' },
{ id: 'c-db2', name: 'Db2', dialect: 'db2' },
{ id: 'c-ch', name: 'ClickHouse', dialect: 'clickhouse' },
{ id: 'c-rds', name: 'Redis', dialect: 'redis' },
{ id: 'c-mgo', name: 'MongoDB', dialect: 'mongodb' },
];

vi.mock('@/features/compare', () => ({
useSyncStore: (selector: (state: Record<string, unknown>) => unknown) =>
selector({
connections: [
{ id: 'c-pg', name: 'Postgres', dialect: 'postgres' },
{ id: 'c-crdb', name: 'Cockroach', dialect: 'cockroachdb' },
{ id: 'c-azure', name: 'Azure SQL', dialect: 'azuresql' },
{ id: 'c-duck', name: 'DuckDB', dialect: 'duckdb' },
],
connections: ALL_CONNECTIONS,
}),
}));

Expand Down Expand Up @@ -72,4 +88,59 @@ describe('EditorTabBar', () => {
expect(screen.queryByTitle('Unsaved changes')).toBeNull();
expect(screen.queryByText('●')).toBeNull();
});

it('renders distinct badges, quotes identifiers, splits statements, and formats SQL across all dialects', async () => {
await loadSqlFormatter();
const expectedBadges: Array<[string, string, string]> = [
['c-pg', 'postgres', 'PG'],
['c-crdb', 'cockroachdb', 'CRDB'],
['c-yb', 'yugabytedb', 'YB'],
['c-rs', 'redshift', 'RS'],
['c-my', 'mysql', 'MY'],
['c-maria', 'mariadb', 'MARIA'],
['c-tidb', 'tidb', 'TIDB'],
['c-sqlite', 'sqlite', 'LITE'],
['c-duck', 'duckdb', 'DUCK'],
['c-ms', 'sqlserver', 'MS'],
['c-azure', 'azuresql', 'AZURE'],
['c-ora', 'oracle', 'ORA'],
['c-db2', 'db2', 'DB2'],
['c-ch', 'clickhouse', 'CH'],
['c-rds', 'redis', 'RDS'],
['c-mgo', 'mongodb', 'MGO'],
];

const tabs = expectedBadges.map(([connId, dialect], i) =>
makeTab(`tab-${i}`, `${dialect} query`, 'SELECT id, name FROM users WHERE active = 1;', [connId]),
);
render(
<EditorTabBar
tabs={tabs}
activeTabId="tab-0"
onSelect={vi.fn()}
onClose={vi.fn()}
onAdd={vi.fn()}
onRename={vi.fn()}
onMove={vi.fn()}
/>,
);

for (const [index, [, dialect, badge]] of expectedBadges.entries()) {
expect(screen.getByTestId(`sql-tab-dialect-tab-${index}`).textContent).toBe(badge);
if (dialect === 'redis' || dialect === 'mongodb') continue;

const quoted = quoteSqlIdentifier('audit_table', dialect);
if (dialect === 'mysql' || dialect === 'mariadb' || dialect === 'tidb' || dialect === 'clickhouse') {
expect(quoted).toBe('`audit_table`');
} else if (dialect === 'sqlserver' || dialect === 'azuresql') {
expect(quoted).toBe('[audit_table]');
} else {
expect(quoted).toBe('"audit_table"');
}

const formatted = formatSql('select id, name from audit_table where id = 1;', dialect);
expect(formatted).toMatch(/SELECT/i);
expect(splitSqlStatements(formatted)).toHaveLength(1);
}
});
});
Loading
Loading