-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
89 lines (79 loc) · 3.86 KB
/
test.js
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
const puppeteer = require("puppeteer");
const URL = "https://github.com/KatsuteDev/GitHub-Red-Issues";
const variables = [
`--bgColor-closed-emphasis`,
`--fgColor-closed`,
`--bgColor-closed-muted`,
`--boxShadow-thin`
];
const tests = {
"https://github.com/KatsuteDev/GitHub-Red-Issues/issues/5": [
`svg.octicon-issue-closed`,
`svg.octicon-discussion-closed`,
`.octicon-checklist.color-fg-done`,
`span.State--merged:has(svg.octicon-issue-closed)`,
`.TimelineItem-badge:has(svg.octicon-issue-closed)`,
// removed?
// `.TimelineItem-badge:has(svg.octicon-discussion-closed)`,
`tasklist-block-title > div.color-bg-done`,
`tracked-issues-progress svg > circle[stroke^="var(--fgColor-done"]:last-child`,
`span > svg[data-target="tracked-issues-progress.progress"] > path`,
],
"https://github.com/KatsuteDev/GitHub-Red-Issues/issues?q=is%3Aissue+is%3Aclosed": [
`svg.octicon-issue-closed`,
],
"https://github.com/KatsuteDev/GitHub-Red-Issues/discussions/90": [
`span.State--merged:has(svg.octicon-discussion-closed)`,
],
"https://github.com/search?q=repo%3AKatsuteDev%2FGitHub-Red-Issues+issue&type=issues": [
`svg:has(path[d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm1.5 0a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm10.28-1.72-4.5 4.5a.75.75 0 0 1-1.06 0l-2-2a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018l1.47 1.47 3.97-3.97a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"])`
],
"https://github.com/search?q=repo%3AKatsuteDev%2FGitHub-Red-Issues&type=pullrequests": [
`svg:has(path[d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm1.5 0a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm10.28-1.72-4.5 4.5a.75.75 0 0 1-1.06 0l-2-2a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018l1.47 1.47 3.97-3.97a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"])`
],
"https://github.com/orgs/github/projects/4247/views/2?pane=issue&itemId=35503395": [
`svg:has(path[d="M11.28 6.78a.75.75 0 0 0-1.06-1.06L7.25 8.69 5.78 7.22a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l3.5-3.5Z"] + path[d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z"])`,
`projects-v2 span[class^="StateLabel__StateLabelBase"]:has(path[d="M11.28 6.78a.75.75 0 0 0-1.06-1.06L7.25 8.69 5.78 7.22a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l3.5-3.5Z"] + path[d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z"])`,
// not visible when signed out
// `projects-v2 .TimelineItem-Badge:has(path[d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm1.5 0a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm10.28-1.72-4.5 4.5a.75.75 0 0 1-1.06 0l-2-2a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018l1.47 1.47 3.97-3.97a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"])`,
]
};
(async () => {
const browser = await puppeteer.launch({
args: ["--headless=old"]
});
const page = await browser.newPage();
await page.setViewport({
width: 3000,
height: 2000
});
await page.goto(URL);
let failed = false;
for(const v of variables){
if(
await page.evaluate((v2) => {
const style = getComputedStyle(document.documentElement);
return style.getPropertyValue(v2) !== '';
}, v)
){
console.info('✅', v);
}else{
console.error('❌', v);
failed = true;
}
}
for(const [url, selectors] of Object.entries(tests)){
await page.goto(url);
for(const s of selectors){
try{
await page.waitForSelector(s, { timeout: 5000 });
console.info('✅', s);
}catch(e){
console.error('❌', s);
failed = true;
}
}
}
await browser.close();
failed && process.exit(1);
})();