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
1 change: 1 addition & 0 deletions apps/e2e/scripts/run-all.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const ALWAYS = [
'src/tests/lazy-loading.test.ts',
'src/tests/sql-editor-result-edit.test.ts',
'src/tests/sql-editor-run-rail.test.ts',
'src/tests/redis-editor.test.ts',
'src/tests/sql-editor-peek-row-form.test.ts',
'src/tests/sql-editor-peek-stacking.test.ts',
'src/tests/sql-editor-compare-multi-target.test.ts',
Expand Down
12 changes: 12 additions & 0 deletions apps/e2e/src/generated/test-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,8 @@ export const TestIds = {
sqlGridCtxCopyValues: 'sql-grid-ctx-copy-values',
/** button · Open row */
sqlGridCtxOpenRow: 'sql-grid-ctx-open-row',
/** div */
sqlGridError: 'sql-grid-error',
/** button · Export CSV */
sqlGridExportBtn: 'sql-grid-export-btn',
/** button · Export CSV */
Expand Down Expand Up @@ -2255,6 +2257,8 @@ export const TestIds = {
sqlResultCredMaximizedHint: (connectionId: string | number) => `sql-result-cred-maximized-hint-${connectionId}`,
/** div */
sqlResultCredModal: (connectionId: string | number) => `sql-result-cred-modal-${connectionId}`,
/** div */
sqlResultError: 'sql-result-error',
/** button · Maximize results */
sqlResultMaximize: (statementIndex: string | number) => `sql-result-maximize-${statementIndex}`,
/** p */
Expand Down Expand Up @@ -2287,6 +2291,8 @@ export const TestIds = {
sqlResultsSideBySide: 'sql-results-side-by-side',
/** div */
sqlResultsWarnings: 'sql-results-warnings',
/** div */
sqlRunError: 'sql-run-error',
},
SelectColumnPicker: {
/** button · SELECT * */
Expand Down Expand Up @@ -2418,6 +2424,8 @@ export const TestIds = {
/** button */
sqlExplorerParamInsert: (name: string | number, name2: string | number) => `sql-explorer-param-insert-${name}-${name2}`,
/** span */
sqlExplorerStoreType: (name: string | number) => `sql-explorer-store-type-${name}`,
/** span */
sqlExplorerTableStats: (name: string | number) => `sql-explorer-table-stats-${name}`,
/** button */
sqlExplorerToggle: (name: string | number) => `sql-explorer-toggle-${name}`,
Expand Down Expand Up @@ -4700,6 +4708,7 @@ export type TestId =
| `sql-explorer-from-${string}`
| `sql-explorer-object-${string}`
| `sql-explorer-param-insert-${string}-${string}`
| `sql-explorer-store-type-${string}`
| `sql-explorer-table-stats-${string}`
| `sql-explorer-toggle-${string}`
| `sql-filter-op-${string}`
Expand Down Expand Up @@ -4734,6 +4743,7 @@ export type TestId =
| 'sql-grid-ctx-copy-headers-only'
| 'sql-grid-ctx-copy-values'
| 'sql-grid-ctx-open-row'
| 'sql-grid-error'
| 'sql-grid-export-btn'
| 'sql-grid-export-csv'
| 'sql-grid-export-json'
Expand Down Expand Up @@ -4807,6 +4817,7 @@ export type TestId =
| `sql-result-cred-maximize-${string}`
| `sql-result-cred-maximized-hint-${string}`
| `sql-result-cred-modal-${string}`
| 'sql-result-error'
| `sql-result-maximize-${string}`
| `sql-result-maximized-hint-${string}`
| `sql-result-modal-${string}`
Expand All @@ -4828,6 +4839,7 @@ export type TestId =
| `sql-row-selected-${string}`
| `sql-row-sync-check-${string}`
| 'sql-run-btn'
| 'sql-run-error'
| 'sql-runs-clear'
| 'sql-runs-close'
| 'sql-runs-drawer'
Expand Down
66 changes: 66 additions & 0 deletions apps/e2e/src/helpers/redis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* Fox Schema (foxschema)
* Copyright 2024-2026 Huy Phan <huyplb@gmail.com>
* SPDX-License-Identifier: Apache-2.0
*
* The dev container's Redis (`foxschema-redis`), from a spec: seed keys, read
* them back, and clean up. Through `docker exec … redis-cli`, so a spec checks
* what Redis holds rather than what the app says it holds.
*/
import { execFileSync } from 'node:child_process';

const CONTAINER = 'foxschema-redis';

/** One redis-cli command in database `db`; its output, trimmed. */
export function redisCli(db: number, ...args: string[]): string {
return execFileSync('docker', ['exec', '-i', CONTAINER, 'redis-cli', '-n', String(db), ...args], {
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'pipe'],
}).trim();
}

/**
* Many commands in database `db` through one process (`redis-cli --pipe`),
* sent as the wire protocol so a JSON value needs no quoting. Throws when
* Redis reports an error for any of them.
*/
export function redisBatch(db: number, commands: string[][]): void {
if (commands.length === 0) return;
const resp = commands
.map((args) => `*${args.length}\r\n${args.map((a) => `$${Buffer.byteLength(a)}\r\n${a}\r\n`).join('')}`)
.join('');
const out = execFileSync('docker', ['exec', '-i', CONTAINER, 'redis-cli', '-n', String(db), '--pipe'], {
input: resp,
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'pipe'],
});
if (!/errors: 0,/.test(out)) throw new Error(`redis-cli --pipe reported errors: ${out.trim()}`);
}

/** Whether the container answers at all; specs skip without it. */
export function redisReachable(): boolean {
try {
return redisCli(0, 'PING') === 'PONG';
} catch {
return false;
}
}

/** Every key in `db` matching `pattern` (SCAN, not KEYS), sorted. */
export function redisKeys(db: number, pattern: string): string[] {
const out = redisCli(db, '--scan', '--pattern', pattern);
return out ? out.split('\n').filter(Boolean).sort() : [];
}

/** A hash as an object. */
export function redisHash(db: number, key: string): Record<string, string> {
const flat = redisCli(db, 'HGETALL', key).split('\n').filter((l) => l !== '');
const out: Record<string, string> = {};
for (let i = 0; i + 1 < flat.length; i += 2) out[flat[i]!] = flat[i + 1]!;
return out;
}

/** Delete these keys from `db` in one command. */
export function redisDel(db: number, keys: readonly string[]): void {
if (keys.length) redisBatch(db, [['DEL', ...keys]]);
}
15 changes: 12 additions & 3 deletions apps/e2e/src/pages/SqlEditorPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,12 @@ export class SqlEditorPage {
}

/** Open Data Peek for a table from the Schema tree (modifier-click the row). */
async openDataPeek(tableName: string): Promise<void> {
/**
* Cmd/Ctrl-click a table in the explorer and wait for its Data Peek. By
* default waits for the row-editing controls, which render once rows load;
* a read-only object (a Redis list) has none, so wait for `rows` instead.
*/
async openDataPeek(tableName: string, opts: { waitFor?: 'crud' | 'rows' } = {}): Promise<void> {
await this.dismissOverlays();
// The v3 sidebar collapses every section, and a collapsed section renders
// no explorer at all — open Schema before reaching into its tree.
Expand All @@ -525,8 +530,12 @@ export class SqlEditorPage {
const modifier = process.platform === 'darwin' ? 'Meta' : 'Control';
await label.click({ modifiers: [modifier] });
await waitFor(this.page, byTestId('data-peek'), 30_000);
// Wait for the grid, since the CRUD controls only render once rows load.
await this.page.waitForSelector('[data-testid^="data-peek-crud-"]', { timeout: 30_000 });
await this.page.waitForSelector(
opts.waitFor === 'rows'
? '[data-testid^="data-peek-grid-"] [data-testid="sql-row-num"]'
: '[data-testid^="data-peek-crud-"]',
{ timeout: 30_000 }
);
}

/** Click Add row on the first open Data Peek panel. */
Expand Down
Loading
Loading