-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
69 lines (67 loc) · 2.33 KB
/
test.ts
File metadata and controls
69 lines (67 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { expect, it } from 'vitest';
import {
SEMANTIC_ATTRIBUTE_SENTRY_OP,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
} from '@sentry/core';
import { createRunner } from '../../../runner';
it('Workflow steps create transactions with correct attributes', async ({ signal }) => {
const runner = createRunner(__dirname)
.expect(envelope => {
const transactionEvent = envelope[1]?.[0]?.[1];
expect(transactionEvent).toEqual(
expect.objectContaining({
type: 'transaction',
transaction: 'step-one',
transaction_info: { source: 'task' },
spans: [],
contexts: expect.objectContaining({
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
op: 'function.step.do',
origin: 'auto.faas.cloudflare.workflow',
status: 'ok',
data: {
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.step.do',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.workflow',
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 1,
},
},
}),
}),
);
})
.expect(envelope => {
const transactionEvent = envelope[1]?.[0]?.[1];
expect(transactionEvent).toEqual(
expect.objectContaining({
type: 'transaction',
transaction: 'step-two',
transaction_info: { source: 'task' },
spans: [],
contexts: expect.objectContaining({
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
op: 'function.step.do',
origin: 'auto.faas.cloudflare.workflow',
status: 'ok',
data: {
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.step.do',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.workflow',
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 1,
},
},
}),
}),
);
})
.unordered()
.start(signal);
await runner.makeRequest('get', '/workflow/trigger');
await runner.completed();
});