Skip to content

Commit

Permalink
Merge pull request #594 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Nov 24, 2022
2 parents 2d8e61a + b924cba commit 3044b13
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 47 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ jobs:
run: yarn
- name: Install Chromium
if: ${{ matrix.chromium.dependency != '' }}
# Chromium from Ubuntu is too old (85), but can still pass the tests
# That's not really a problem since Chromium-bundled Docker image is based on Debian bullseye,
# which updates Chromium frequently, and only on arm/arm64 the image needs Chromium from Debian.
# 'chromium-browser' from Ubuntu APT repo is a dummy package. Its version (85.0.4183.83) means
# nothing since it calls Snap (disgusting!) to install Chromium, which should be up-to-date.
# That's not really a problem since the Chromium-bundled Docker image is based on Debian bullseye,
# which provides up-to-date native packages.
run: |
set -ex
curl -s "https://dl.google.com/linux/linux_signing_key.pub" | gpg --dearmor |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"dependencies": {
"@koa/router": "12.0.0",
"@postlight/parser": "2.2.3",
"@sentry/node": "7.21.0",
"@sentry/node": "7.21.1",
"aes-js": "3.1.2",
"art-template": "4.13.2",
"bbcodejs": "0.0.4",
Expand Down
29 changes: 8 additions & 21 deletions test/utils/puppeteer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
let puppeteer;
const wait = require('../../lib/utils/wait');
const cheerio = require('cheerio');

let browser = null;

Expand Down Expand Up @@ -47,38 +46,26 @@ describe('puppeteer', () => {
puppeteer = require('../../lib/utils/puppeteer');
browser = await puppeteer({ stealth: false });
const page = await browser.newPage();
await page.goto('https://bot.sannysoft.com');

const html = await page.evaluate(() => document.body.innerHTML);
const $ = cheerio.load(html);
browser.close();
browser = null;

const webDriverTest = $('tbody tr').eq(2).find('td').eq(1).text().trim();
const chromeTest = $('tbody tr').eq(4).find('td').eq(1).text().trim();
await page.goto('https://bot.sannysoft.com', { waitUntil: 'networkidle0' });
// page rendering is not instant, wait for expected elements to appear
const [webDriverTest, chromeTest] = await Promise.all(['webdriver', 'chrome'].map((t) => page.waitForSelector(`td#${t}-result.result.failed`).then((hd) => hd.evaluate((e) => e.textContent))));
// the website return empty string from time to time for no reason
// since we don't really care whether puppeteer without stealth passes the bot test, just let it go
expect(['present (failed)', '']).toContain(webDriverTest);
expect(['missing (failed)', '']).toContain(chromeTest);
}, 10000);
}, 15000);

it('puppeteer with stealth', async () => {
puppeteer = require('../../lib/utils/puppeteer');
browser = await puppeteer({ stealth: true });
const page = await browser.newPage();
await page.goto('https://bot.sannysoft.com');

const html = await page.evaluate(() => document.body.innerHTML);
const $ = cheerio.load(html);
browser.close();
browser = null;

const webDriverTest = $('tbody tr').eq(2).find('td').eq(1).text().trim();
const chromeTest = $('tbody tr').eq(4).find('td').eq(1).text().trim();
await page.goto('https://bot.sannysoft.com', { waitUntil: 'networkidle0' });
// page rendering is not instant, wait for expected elements to appear
const [webDriverTest, chromeTest] = await Promise.all(['webdriver', 'chrome'].map((t) => page.waitForSelector(`td#${t}-result.result.passed`).then((hd) => hd.evaluate((e) => e.textContent))));
// these are something we really care about
expect(webDriverTest).toBe('missing (passed)');
expect(chromeTest).toBe('present (passed)');
}, 10000);
}, 15000);

it('puppeteer accept proxy uri', async () => {
process.env.PROXY_URI = 'http://user:[email protected]:2333';
Expand Down
44 changes: 22 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1538,39 +1538,39 @@
domhandler "^4.2.0"
selderee "^0.6.0"

"@sentry/[email protected].0":
version "7.21.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.21.0.tgz#e0a7d7e772120ca0dbabd19049f340a2de74bb8a"
integrity sha512-5ZHwfHPm4svny7iXsNmlnRg0q1jw/N5/ugzAku+g98R769RCv2aSBaK9BIYlJmJ1SWwR7nQuR/GOCOdv5mA8jw==
"@sentry/[email protected].1":
version "7.21.1"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.21.1.tgz#d0423282d90875625802dfe380f9657e9242b72b"
integrity sha512-Og5wEEsy24fNvT/T7IKjcV4EvVK5ryY2kxbJzKY6GU2eX+i+aBl+n/vp7U0Es351C/AlTkS+0NOUsp2TQQFxZA==
dependencies:
"@sentry/types" "7.21.0"
"@sentry/utils" "7.21.0"
"@sentry/types" "7.21.1"
"@sentry/utils" "7.21.1"
tslib "^1.9.3"

"@sentry/[email protected].0":
version "7.21.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.21.0.tgz#0c91f13a298d65108f46e1576e3ffafcbfb20300"
integrity sha512-jRwsX1tqA9R1VFcnHs3vkbNKCWCBb/eakqLQa1keEc+QxTDLAOqB/Z+z8kwEe8LC/Sj3RZIVw3VbvjrOENLEvg==
"@sentry/[email protected].1":
version "7.21.1"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.21.1.tgz#929a2ad84c25f5374ec7323267f1171f6b0e261e"
integrity sha512-B+p1nQHaFWdCCRVmvqlr/+vdQCI3mGLObucNfK2YC22IQZg7+3u6tEbxJ7umITIjeSSKgf7ZoZwCxL9VfkrNXg==
dependencies:
"@sentry/core" "7.21.0"
"@sentry/types" "7.21.0"
"@sentry/utils" "7.21.0"
"@sentry/core" "7.21.1"
"@sentry/types" "7.21.1"
"@sentry/utils" "7.21.1"
cookie "^0.4.1"
https-proxy-agent "^5.0.0"
lru_map "^0.3.3"
tslib "^1.9.3"

"@sentry/[email protected].0":
version "7.21.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.21.0.tgz#b5611a60d4ce5c88e76429c3ad79af8f08de48fc"
integrity sha512-DqQi0HLp17x0++zCjI9jVST0cuszsQtrVIMQRQXpy8J/ay3IGxwFoX1qMrwFP2tmVQDsy8YKIz50J5e6caXwSw==
"@sentry/[email protected].1":
version "7.21.1"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.21.1.tgz#408a7b95a66ddc30c4359979594e03bee8f9fbdc"
integrity sha512-3/IKnd52Ol21amQvI+kz+WB76s8/LR5YvFJzMgIoI2S8d82smIr253zGijRXxHPEif8kMLX4Yt+36VzrLxg6+A==

"@sentry/[email protected].0":
version "7.21.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.21.0.tgz#50d841990953ea1ff006c2776e997620d091790f"
integrity sha512-Dn9zsPOfz1kbBua8KSYUPrka31Lh+am9BVJWnzqzGbALthf134oUTbp2vcwpMyEW7NxX+4Qd+36BvTzapfRINQ==
"@sentry/[email protected].1":
version "7.21.1"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.21.1.tgz#96582345178015fd32fe9159c25c44ccf2f99d2a"
integrity sha512-F0W0AAi8tgtTx6ApZRI2S9HbXEA9ENX1phTZgdNNWcMFm1BNbc21XEwLqwXBNjub5nlA6CE8xnjXRgdZKx4kzQ==
dependencies:
"@sentry/types" "7.21.0"
"@sentry/types" "7.21.1"
tslib "^1.9.3"

"@sinclair/typebox@^0.24.1":
Expand Down

1 comment on commit 3044b13

@vercel
Copy link

@vercel vercel bot commented on 3044b13 Nov 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.