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
35 changes: 19 additions & 16 deletions apps/sim/lib/logs/execution/snapshot/service.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { beforeEach, describe, expect, test } from 'vitest'
import { describe, expect, it } from 'vitest'
import { SnapshotService } from '@/lib/logs/execution/snapshot/service'
import type { WorkflowState } from '@/lib/logs/types'

describe('SnapshotService', () => {
let service: SnapshotService

beforeEach(() => {
service = new SnapshotService()
})

describe('computeStateHash', () => {
test('should generate consistent hashes for identical states', () => {
it.concurrent('should generate consistent hashes for identical states', () => {
const service = new SnapshotService()
const state: WorkflowState = {
blocks: {
block1: {
Expand Down Expand Up @@ -39,7 +34,8 @@ describe('SnapshotService', () => {
expect(hash1).toHaveLength(64) // SHA-256 hex string
})

test('should ignore position changes', () => {
it.concurrent('should ignore position changes', () => {
const service = new SnapshotService()
const baseState: WorkflowState = {
blocks: {
block1: {
Expand Down Expand Up @@ -77,7 +73,8 @@ describe('SnapshotService', () => {
expect(hash1).toBe(hash2)
})

test('should detect meaningful changes', () => {
it.concurrent('should detect meaningful changes', () => {
const service = new SnapshotService()
const baseState: WorkflowState = {
blocks: {
block1: {
Expand Down Expand Up @@ -128,7 +125,8 @@ describe('SnapshotService', () => {
expect(hash1).not.toBe(hash2)
})

test('should handle edge order consistently', () => {
it.concurrent('should handle edge order consistently', () => {
const service = new SnapshotService()
const state1: WorkflowState = {
blocks: {},
edges: [
Expand All @@ -155,7 +153,8 @@ describe('SnapshotService', () => {
expect(hash1).toBe(hash2) // Should be same despite different order
})

test('should handle empty states', () => {
it.concurrent('should handle empty states', () => {
const service = new SnapshotService()
const emptyState: WorkflowState = {
blocks: {},
edges: [],
Expand All @@ -167,7 +166,8 @@ describe('SnapshotService', () => {
expect(hash).toHaveLength(64)
})

test('should handle complex nested structures', () => {
it.concurrent('should handle complex nested structures', () => {
const service = new SnapshotService()
const complexState: WorkflowState = {
blocks: {
block1: {
Expand Down Expand Up @@ -224,7 +224,8 @@ describe('SnapshotService', () => {
expect(hash).toBe(hash2)
})

test('should include variables in hash computation', () => {
it.concurrent('should include variables in hash computation', () => {
const service = new SnapshotService()
const stateWithVariables: WorkflowState = {
blocks: {},
edges: [],
Expand Down Expand Up @@ -253,7 +254,8 @@ describe('SnapshotService', () => {
expect(hashWith).not.toBe(hashWithout)
})

test('should detect changes in variable values', () => {
it.concurrent('should detect changes in variable values', () => {
const service = new SnapshotService()
const state1: WorkflowState = {
blocks: {},
edges: [],
Expand Down Expand Up @@ -290,7 +292,8 @@ describe('SnapshotService', () => {
expect(hash1).not.toBe(hash2)
})

test('should generate consistent hashes for states with variables', () => {
it.concurrent('should generate consistent hashes for states with variables', () => {
const service = new SnapshotService()
const stateWithVariables: WorkflowState = {
blocks: {
block1: {
Expand Down
Loading