forked from darkreader/darkreader
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdevtools.tests.ts
More file actions
85 lines (76 loc) · 2.54 KB
/
Copy pathdevtools.tests.ts
File metadata and controls
85 lines (76 loc) · 2.54 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
import {multiline} from '../../support/test-utils';
import type {StyleExpectations} from '../globals';
async function loadBasicPage() {
await loadTestPage({
'/': multiline(
'<!DOCTYPE html>',
'<html>',
'<head>',
' <style>',
' h1 { color: red; }',
' </style>',
'</head>',
'<body>',
' <h1>E2E test page</h1>',
' <p>Text</p>',
' <a href="#">Link</a>',
'</body>',
'</html>',
),
});
}
async function expectStyles(styles: StyleExpectations) {
await expectPageStyles(expect, styles);
}
describe('Modifying config via Developer tools', () => {
// TODO: remove flakes and remove this line
jest.retryTimes(10, {logErrorsBeforeRetry: true});
it('Modifying config', async () => {
await loadBasicPage();
await expectStyles([
['document', 'background-color', 'rgb(24, 26, 27)'],
['document', 'color', 'rgb(232, 230, 227)'],
['body', 'background-color', 'rgb(24, 26, 27)'],
['body', 'color', 'rgb(232, 230, 227)'],
['h1', 'color', 'rgb(255, 26, 26)'],
['a', 'color', 'rgb(51, 145, 255)'],
]);
await devtoolsUtils.paste([
'*',
'',
'CSS',
'h1 {',
' background: black;',
' color: white;',
'}',
'',
'============================',
'',
'nonexistent.com',
'',
'CSS',
'h1 {',
' color: red;',
'}',
'',
].join('\n'));
await expectStyles([
['document', 'background-color', 'rgb(24, 26, 27)'],
['document', 'color', 'rgb(232, 230, 227)'],
['body', 'background-color', 'rgb(24, 26, 27)'],
['body', 'color', 'rgb(232, 230, 227)'],
['h1', 'background-color', 'rgb(0, 0, 0)'],
['h1', 'color', 'rgb(255, 255, 255)'],
['a', 'color', 'rgb(51, 145, 255)'],
]);
await devtoolsUtils.reset();
await expectStyles([
['document', 'background-color', 'rgb(24, 26, 27)'],
['document', 'color', 'rgb(232, 230, 227)'],
['body', 'background-color', 'rgb(24, 26, 27)'],
['body', 'color', 'rgb(232, 230, 227)'],
['h1', 'color', 'rgb(255, 26, 26)'],
['a', 'color', 'rgb(51, 145, 255)'],
]);
});
});