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
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { describe, test, expect, vi } from 'vitest';
import { FlowRun } from '../src/lib/FlowRun';
import { FlowStep } from '../src/lib/FlowStep';
import { FlowRunStatus, FlowStepStatus } from '../src/lib/types';
import { toTypedRunEvent, toTypedStepEvent } from '../src/lib/eventAdapters';
import { FlowRun } from '../../src/lib/FlowRun';
import { FlowStep } from '../../src/lib/FlowStep';
import { FlowRunStatus, FlowStepStatus } from '../../src/lib/types';
import { toTypedRunEvent, toTypedStepEvent } from '../../src/lib/eventAdapters';
import {
setupTestEnvironment,
advanceTimersAndFlush,
createEventTracker,
} from './helpers/test-utils';
} from '../helpers/test-utils';
import {
createRunStartedEvent,
createRunCompletedEvent,
createRunFailedEvent,
createStepStartedEvent,
} from './helpers/event-factories';
import { createFlowRun } from './helpers/state-factories';
} from '../helpers/event-factories';
import { createFlowRun } from '../helpers/state-factories';
// Test scenarios have been inlined for clarity
import { RUN_ID, FLOW_SLUG, STEP_SLUG, ANOTHER_STEP_SLUG } from './fixtures';
import { RUN_ID, FLOW_SLUG, STEP_SLUG, ANOTHER_STEP_SLUG } from '../fixtures';

describe('FlowRun', () => {
setupTestEnvironment();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { describe, test, expect, vi } from 'vitest';
import { FlowStep } from '../src/lib/FlowStep';
import { FlowStepStatus } from '../src/lib/types';
import { FlowStep } from '../../src/lib/FlowStep';
import { FlowStepStatus } from '../../src/lib/types';
import {
setupTestEnvironment,
advanceTimersAndFlush,
createEventTracker,
} from './helpers/test-utils';
} from '../helpers/test-utils';
import {
createStepStartedEvent,
createStepCompletedEvent,
createStepFailedEvent,
} from './helpers/event-factories';
import { createFlowStep } from './helpers/state-factories';
} from '../helpers/event-factories';
import { createFlowStep } from '../helpers/state-factories';
// Test scenarios have been inlined for clarity
import { RUN_ID, STEP_SLUG, ANOTHER_STEP_SLUG } from './fixtures';
import { RUN_ID, STEP_SLUG, ANOTHER_STEP_SLUG } from '../fixtures';

describe('FlowStep', () => {
setupTestEnvironment();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { describe, test, expect, vi } from 'vitest';
import { PgflowClient } from '../src/lib/PgflowClient';
import { FlowRunStatus, FlowStepStatus } from '../src/lib/types';
import { PgflowClient } from '../../src/lib/PgflowClient';
import { FlowRunStatus, FlowStepStatus } from '../../src/lib/types';
import {
setupTestEnvironment,
createMockClient,
createRunResponse,
mockRpcCall,
emitBroadcastEvent,
createSyncSchedule,
} from './helpers/test-utils';
} from '../helpers/test-utils';
import {
createRunCompletedEvent,
createStepStartedEvent,
} from './helpers/event-factories';
import { RUN_ID, FLOW_SLUG } from './fixtures';
} from '../helpers/event-factories';
import { RUN_ID, FLOW_SLUG } from '../fixtures';

// Mock uuid.v4 to return a predictable run ID for testing
vi.mock('uuid', () => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { describe, test, expect, vi } from 'vitest';
import { SupabaseBroadcastAdapter } from '../src/lib/SupabaseBroadcastAdapter';
import { SupabaseBroadcastAdapter } from '../../src/lib/SupabaseBroadcastAdapter';
import {
setupTestEnvironment,
createMockClient,
emitBroadcastEvent,
} from './helpers/test-utils';
} from '../helpers/test-utils';
import {
createRunStartedEvent,
createStepStartedEvent,
} from './helpers/event-factories';
} from '../helpers/event-factories';
import {
RUN_ID,
FLOW_SLUG,
STEP_SLUG,
startedRunSnapshot,
startedStepState,
} from './fixtures';
import { mockChannelSubscription } from './mocks';
} from '../fixtures';
import { mockChannelSubscription } from '../mocks';

/**
* This is a simplified test that focuses on the core functionality
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { describe, test, expect, vi, beforeEach, afterEach } from 'vitest';
import { SupabaseBroadcastAdapter } from '../src/lib/SupabaseBroadcastAdapter';
import { SupabaseBroadcastAdapter } from '../../src/lib/SupabaseBroadcastAdapter';
import {
createMockClient,
} from './helpers/test-utils';
import { RUN_ID } from './fixtures';
import { mockChannelSubscription } from './mocks';
} from '../helpers/test-utils';
import { RUN_ID } from '../fixtures';
import { mockChannelSubscription } from '../mocks';

/**
* Tests for configurable stabilization delay
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { describe, test, expect, vi } from 'vitest';
import { SupabaseBroadcastAdapter } from '../src/lib/SupabaseBroadcastAdapter';
import { SupabaseBroadcastAdapter } from '../../src/lib/SupabaseBroadcastAdapter';
import {
setupTestEnvironment,
createMockClient,
emitBroadcastEvent,
createEventTracker,
createEventRoutingTest,
createSyncSchedule,
} from './helpers/test-utils';
} from '../helpers/test-utils';
import {
createRunStartedEvent,
createRunCompletedEvent,
createRunFailedEvent,
createStepStartedEvent,
createStepCompletedEvent,
createStepFailedEvent,
} from './helpers/event-factories';
import { mockChannelSubscription } from './mocks';
} from '../helpers/event-factories';
import { mockChannelSubscription } from '../mocks';
import {
RUN_ID,
FLOW_SLUG,
startedRunSnapshot,
startedStepState,
sampleFlowDefinition,
sampleStepsDefinition,
} from './fixtures';
} from '../fixtures';

describe('SupabaseBroadcastAdapter', () => {
setupTestEnvironment();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect, vi } from 'vitest';
import { createClient, PgflowClient } from '../src/browser';
import { createClient, PgflowClient } from '../../src/browser';
import type { SupabaseClient } from '@supabase/supabase-js';

describe('browser entry point', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect, vi } from 'vitest';
import { PgflowClient } from '../src/lib/PgflowClient';
import { FlowRunStatus, FlowStepStatus } from '../src/lib/types';
import { PgflowClient } from '../../src/lib/PgflowClient';
import { FlowRunStatus, FlowStepStatus } from '../../src/lib/types';
import { Flow } from '@pgflow/dsl';
import {
setupTestEnvironment,
Expand All @@ -12,13 +12,13 @@ import {
setupConcurrentOperations,
createEventTracker,
createSyncSchedule,
} from './helpers/test-utils';
} from '../helpers/test-utils';
import {
createStepStartedEvent,
createStepCompletedEvent,
createRunCompletedEvent,
} from './helpers/event-factories';
import { RUN_ID, FLOW_SLUG, STEP_SLUG, startedRunSnapshot, stepStatesSample } from './fixtures';
} from '../helpers/event-factories';
import { RUN_ID, FLOW_SLUG, STEP_SLUG, startedRunSnapshot, stepStatesSample } from '../fixtures';

// Create a test flow for proper typing
const TestFlow = new Flow<{ test: string }>({ slug: 'test_flow' }).step(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, it, expect, vi } from 'vitest';
import { PgflowClient } from '../src/lib/PgflowClient';
import { FlowRun } from '../src/lib/FlowRun';
import { FlowStep } from '../src/lib/FlowStep';
import { FlowRunStatus, FlowStepStatus } from '../src/lib/types';
import { toTypedRunEvent, toTypedStepEvent } from '../src/lib/eventAdapters';
import { PgflowClient } from '../../src/lib/PgflowClient';
import { FlowRun } from '../../src/lib/FlowRun';
import { FlowStep } from '../../src/lib/FlowStep';
import { FlowRunStatus, FlowStepStatus } from '../../src/lib/types';
import { toTypedRunEvent, toTypedStepEvent } from '../../src/lib/eventAdapters';
import {
setupTestEnvironment,
createMockClient,
Expand All @@ -12,21 +12,21 @@ import {
emitBroadcastEvent,
advanceTimersAndFlush,
createSyncSchedule,
} from './helpers/test-utils';
} from '../helpers/test-utils';
import {
createRunStartedEvent,
createRunCompletedEvent,
createStepStartedEvent,
createStepCompletedEvent,
} from './helpers/event-factories';
import { mockChannelSubscription } from './mocks';
} from '../helpers/event-factories';
import { mockChannelSubscription } from '../mocks';
import {
RUN_ID,
FLOW_SLUG,
STEP_SLUG,
startedRunSnapshot,
stepStatesSample,
} from './fixtures';
} from '../fixtures';

// Mock uuid.v4 to return predictable run ID for testing
vi.mock('uuid', () => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { describe, it, expect, vi } from 'vitest';
import { PgflowClient } from '../src/lib/PgflowClient';
import { FlowRunStatus } from '../src/lib/types';
import { PgflowClient } from '../../src/lib/PgflowClient';
import { FlowRunStatus } from '../../src/lib/types';
import {
setupTestEnvironment,
createMockClient,
mockRpcCall,
createRunResponse,
advanceTimersAndFlush,
createSyncSchedule,
} from './helpers/test-utils';
import { mockChannelSubscription } from './mocks';
} from '../helpers/test-utils';
import { mockChannelSubscription } from '../mocks';
import {
RUN_ID,
FLOW_SLUG,
startedRunSnapshot,
stepStatesSample,
} from './fixtures';
} from '../fixtures';

// Mock uuid.v4 to return predictable run ID for testing
vi.mock('uuid', () => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, test, expect } from 'vitest';
import { createEventTracker } from './helpers/test-utils';
import type { BroadcastRunEvent, BroadcastStepEvent } from '../src/lib/types';
import { createEventTracker } from '../helpers/test-utils';
import type { BroadcastRunEvent, BroadcastStepEvent } from '../../src/lib/types';

/**
* Tests demonstrating the new event matcher patterns
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { describe, it, expect, vi } from 'vitest';
import { SupabaseBroadcastAdapter } from '../src/lib/SupabaseBroadcastAdapter';
import type { BroadcastStepEvent, BroadcastRunEvent } from '../src/lib/types';
import { SupabaseBroadcastAdapter } from '../../src/lib/SupabaseBroadcastAdapter';
import type { BroadcastStepEvent, BroadcastRunEvent } from '../../src/lib/types';
import {
setupTestEnvironment,
createMockClient,
emitBroadcastEvent,
createSyncSchedule,
} from './helpers/test-utils';
import { mockChannelSubscription } from './mocks';
} from '../helpers/test-utils';
import { mockChannelSubscription } from '../mocks';

describe('JSON Parsing in Broadcasts', () => {
setupTestEnvironment();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { describe, it, expect, vi } from 'vitest';
import { SupabaseBroadcastAdapter } from '../src/lib/SupabaseBroadcastAdapter';
import { SupabaseBroadcastAdapter } from '../../src/lib/SupabaseBroadcastAdapter';
import {
setupTestEnvironment,
createMockClient,
mockRpcCall,
createRunResponse,
createSyncSchedule,
} from './helpers/test-utils';
} from '../helpers/test-utils';
import {
createMockSchedule,
} from './mocks';
import { RUN_ID, startedRunSnapshot, stepStatesSample } from './fixtures';
} from '../mocks';
import { RUN_ID, startedRunSnapshot, stepStatesSample } from '../fixtures';

describe('Reconnection Logic', () => {
setupTestEnvironment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import {
FlowStepStatus,
type BroadcastRunStartedEvent,
type BroadcastStepStartedEvent,
} from '../src/lib/types';
} from '../../src/lib/types';
import {
createRunStartedEvent,
createRunCompletedEvent,
createRunFailedEvent,
createStepStartedEvent,
createStepCompletedEvent,
createStepFailedEvent,
} from './helpers/event-factories';
} from '../helpers/event-factories';
import {
RUN_ID,
STEP_SLUG,
} from './fixtures';
} from '../fixtures';

// Create test events
const broadcastRunStarted = createRunStartedEvent({ run_id: RUN_ID });
Expand Down
6 changes: 3 additions & 3 deletions pkgs/client/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"commands": [
"../../scripts/supabase-start-locked.sh .",
"psql 'postgresql://postgres:postgres@localhost:50522/postgres' -c 'SELECT pgflow_tests.reset_db()'",
"vitest run __tests__/integration/ --poolOptions.threads.singleThread"
"vitest run __tests__/e2e/ --config vitest.e2e.config.ts --poolOptions.threads.singleThread"
],
"parallel": false
}
Expand All @@ -160,7 +160,7 @@
"inputs": ["default", "^production"],
"options": {
"cwd": "{projectRoot}",
"commands": ["vitest run __tests__/ --exclude __tests__/integration/"],
"commands": ["vitest run __tests__/unit/"],
"parallel": false
}
},
Expand All @@ -174,7 +174,7 @@
"commands": [
"../../scripts/supabase-start-locked.sh .",
"psql 'postgresql://postgres:postgres@localhost:50522/postgres' -c 'SELECT pgflow_tests.reset_db()'",
"vitest run __tests__/ --poolOptions.threads.singleThread"
"vitest run __tests__/ --config vitest.e2e.config.ts --poolOptions.threads.singleThread"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command runs ALL tests under __tests__/ (including both unit and e2e tests) but forces them to use the e2e configuration. This will cause unit tests to run with the e2e global setup, which is inefficient and potentially incorrect.

The command should be changed to either:

"vitest run __tests__/e2e/ --config vitest.e2e.config.ts --poolOptions.threads.singleThread"

to only run e2e tests, or use separate commands for unit and e2e tests if running all tests is intended.

Suggested change
"vitest run __tests__/ --config vitest.e2e.config.ts --poolOptions.threads.singleThread"
"vitest run __tests__/e2e/ --config vitest.e2e.config.ts --poolOptions.threads.singleThread"

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

],
"parallel": false
}
Expand Down
1 change: 0 additions & 1 deletion pkgs/client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export default defineConfig({
'__tests__/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'
],
setupFiles: ['__tests__/setup.ts'],
globalSetup: './vitest.global-setup.ts',
reporters: ['default'],
coverage: {
reportsDirectory: '../../coverage/pkgs/client',
Expand Down
12 changes: 12 additions & 0 deletions pkgs/client/vitest.e2e.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference types='vitest' />
import { defineConfig, mergeConfig } from 'vitest/config';
import baseConfig from './vite.config';

export default mergeConfig(
baseConfig,
defineConfig({
test: {
globalSetup: './vitest.e2e.global-setup.ts',
},
})
);
Loading