Skip to content

Commit

Permalink
Add logging to the test, to understand progress
Browse files Browse the repository at this point in the history
  • Loading branch information
iainsproat committed Sep 6, 2024
1 parent a21f42e commit aa2e3f9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/preview-service/tests/acceptance/acceptance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import { afterEach, beforeEach, describe, expect } from 'vitest'
import { promises as fs } from 'fs'
import { OBJECTS_TABLE_NAME } from '#/migrations/migrations.js'
import type { Angle } from '@/domain/domain.js'
import { testLogger as logger } from '@/observability/logging.js'

describe.sequential('Acceptance', () => {
describe.sequential('Run the preview-service image in docker', () => {
beforeEach(() => {
// const dbName = inject('dbName')
logger.info('🤜 running acceptance test before-each')
})
afterEach(() => {
logger.info('🤛 running acceptance test after-each')
})
afterEach(async () => {})

// we use integration test and not e2e test because we don't need the server
acceptanceTest(
Expand Down Expand Up @@ -57,6 +61,10 @@ describe.sequential('Acceptance', () => {
.where('streamId', streamId)
.andWhere('objectId', objectId)

logger.info(
{ result: objectPreviewResult, streamId, objectId },
'🔍 Polled object preview for a result for {streamId} and {objectId}'
)
// wait a second before polling again
await new Promise((resolve) => setTimeout(resolve, 1000))
}
Expand All @@ -65,6 +73,7 @@ describe.sequential('Acceptance', () => {
.select(['data'])
.where('id', objectPreviewResult[0].preview['all' as Angle])
.first()
logger.info({ previewData }, '🔍 Retrieved preview data')

if (!previewData) {
expect(previewData).toBeDefined()
Expand All @@ -76,6 +85,7 @@ describe.sequential('Acceptance', () => {
const outputFilePath =
process.env.OUTPUT_FILE_PATH || '/tmp/preview-service-output.png'
await fs.writeFile(outputFilePath, previewData.data)
logger.info({ outputFilePath }, '📝 Saved preview image to {outputFilePath}')
}
)
})
Expand Down

0 comments on commit aa2e3f9

Please sign in to comment.