-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathlogs.test.ts
More file actions
116 lines (96 loc) · 4.16 KB
/
logs.test.ts
File metadata and controls
116 lines (96 loc) · 4.16 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { expect, test } from '@playwright/test';
import { waitForEnvelopeItem } from '@sentry-internal/test-utils';
import type { SerializedLogContainer } from '@sentry/core';
test('should send Effect debug logs', async ({ page }) => {
const logEnvelopePromise = waitForEnvelopeItem('effect-3-browser', envelope => {
return (
envelope[0].type === 'log' &&
(envelope[1] as SerializedLogContainer).items.some(
item => item.level === 'debug' && item.body === 'Debug log from Effect',
)
);
});
await page.goto('/');
const logButton = page.locator('id=log-button');
await logButton.click();
await expect(page.locator('id=log-result')).toHaveText('Logs sent!');
const logEnvelope = await logEnvelopePromise;
const logs = (logEnvelope[1] as SerializedLogContainer).items;
const debugLog = logs.find(log => log.level === 'debug' && log.body === 'Debug log from Effect');
expect(debugLog).toBeDefined();
expect(debugLog?.level).toBe('debug');
});
test('should send Effect info logs', async ({ page }) => {
const logEnvelopePromise = waitForEnvelopeItem('effect-3-browser', envelope => {
return (
envelope[0].type === 'log' &&
(envelope[1] as SerializedLogContainer).items.some(
item => item.level === 'info' && item.body === 'Info log from Effect',
)
);
});
await page.goto('/');
const logButton = page.locator('id=log-button');
await logButton.click();
await expect(page.locator('id=log-result')).toHaveText('Logs sent!');
const logEnvelope = await logEnvelopePromise;
const logs = (logEnvelope[1] as SerializedLogContainer).items;
const infoLog = logs.find(log => log.level === 'info' && log.body === 'Info log from Effect');
expect(infoLog).toBeDefined();
expect(infoLog?.level).toBe('info');
});
test('should send Effect warning logs', async ({ page }) => {
const logEnvelopePromise = waitForEnvelopeItem('effect-3-browser', envelope => {
return (
envelope[0].type === 'log' &&
(envelope[1] as SerializedLogContainer).items.some(
item => item.level === 'warn' && item.body === 'Warning log from Effect',
)
);
});
await page.goto('/');
const logButton = page.locator('id=log-button');
await logButton.click();
await expect(page.locator('id=log-result')).toHaveText('Logs sent!');
const logEnvelope = await logEnvelopePromise;
const logs = (logEnvelope[1] as SerializedLogContainer).items;
const warnLog = logs.find(log => log.level === 'warn' && log.body === 'Warning log from Effect');
expect(warnLog).toBeDefined();
expect(warnLog?.level).toBe('warn');
});
test('should send Effect error logs', async ({ page }) => {
const logEnvelopePromise = waitForEnvelopeItem('effect-3-browser', envelope => {
return (
envelope[0].type === 'log' &&
(envelope[1] as SerializedLogContainer).items.some(
item => item.level === 'error' && item.body === 'Error log from Effect',
)
);
});
await page.goto('/');
const logButton = page.locator('id=log-button');
await logButton.click();
await expect(page.locator('id=log-result')).toHaveText('Logs sent!');
const logEnvelope = await logEnvelopePromise;
const logs = (logEnvelope[1] as SerializedLogContainer).items;
const errorLog = logs.find(log => log.level === 'error' && log.body === 'Error log from Effect');
expect(errorLog).toBeDefined();
expect(errorLog?.level).toBe('error');
});
test('should send Effect logs with context attributes', async ({ page }) => {
const logEnvelopePromise = waitForEnvelopeItem('effect-3-browser', envelope => {
return (
envelope[0].type === 'log' &&
(envelope[1] as SerializedLogContainer).items.some(item => item.body === 'Log with context')
);
});
await page.goto('/');
const logContextButton = page.locator('id=log-context-button');
await logContextButton.click();
await expect(page.locator('id=log-context-result')).toHaveText('Log with context sent!');
const logEnvelope = await logEnvelopePromise;
const logs = (logEnvelope[1] as SerializedLogContainer).items;
const contextLog = logs.find(log => log.body === 'Log with context');
expect(contextLog).toBeDefined();
expect(contextLog?.level).toBe('info');
});