fix readability's substack test page failure by mocking the tweet redirect link

This commit is contained in:
Hongbo Wu 2023-05-10 18:09:07 +08:00
parent 56d64df9d5
commit d1c69303b3
3 changed files with 27 additions and 0 deletions

View file

@ -31,6 +31,7 @@
"js-beautify": "^1.13.0",
"linkedom": "^0.14.9",
"mocha": "^8.2.0",
"nock": "^13.3.1",
"puppeteer": "^10.1.0",
"sinon": "^7.3.2"
},

View file

@ -2,6 +2,7 @@ var chai = require("chai");
var sinon = require("sinon");
var chaiAsPromised = require("chai-as-promised");
const { parseHTML } = require("linkedom");
const nock = require("nock");
chai.use(chaiAsPromised);
chai.config.includeStack = true;
@ -323,6 +324,21 @@ describe("Readability API", function() {
});
describe("Test pages", function() {
before(function() {
// mock the substack redirect to twitter
nock('https://email.mg2.substack.com')
.get('/c/eJxNkcuO3SAMhp8m7E5EzC1ZsDjT0fQidVG1qtRVRIKToCYQAZmZ9OlLejaVEBhk-__5PJqMc4in3kPK5Nr6fO6oPb6lFXPGSI6EsXdWK8ZAcQXEam6bVrTEpX6KiJtxq87xQLIfw-pGk13wVwWojlNKFo1UMpgYWCrbtoNJmIYh60AMYKxopoewOaxDP6LGV4xn8EjGsG3o89WLrHrJeU8Vu1fwUlZ-c5e9uuSU2_cF1xX9gHHG-PW5vKRs8pFK0AjoWq6KdMNapVoJvGIvpdEz0ApkLsEdPrLz6dP5Pv76LNOfnx_gxxd6J04DBaACZDkphZrVVqnR0nZCaVs6GVFxus1Qp2MoeuPvyw2Jegl-HsJNheC-JX7DkuX8EN5vFrdQh8271xCxNvt-Ieuvbx7e5bNHb4YV7YNmfgzlH99-Ro-xDMv2JutGCiY6yRsGgj_gFURCyk6wRpHixoZS5fXmxsXgmv6n8xdPFKS3')
.reply(302, '', [
'location',
'https://twitter.com/ShellenbergerMD/status/1529847068138778624?s=20&t=A2G3yBHyxcYI6szVC2TJ0A'
]);
nock('https://twitter.com')
.get('/ShellenbergerMD/status/1529847068138778624')
.query({"s":"20","t":"A2G3yBHyxcYI6szVC2TJ0A"})
.reply(200);
});
testPages.forEach(function(testPage) {
describe(testPage.dir, function() {
var uri = "http://fakehost/test/page.html";

View file

@ -20857,6 +20857,16 @@ nock@^13.2.9:
lodash "^4.17.21"
propagate "^2.0.0"
nock@^13.3.1:
version "13.3.1"
resolved "https://registry.yarnpkg.com/nock/-/nock-13.3.1.tgz#f22d4d661f7a05ebd9368edae1b5dc0a62d758fc"
integrity sha512-vHnopocZuI93p2ccivFyGuUfzjq2fxNyNurp7816mlT5V5HF4SzXu8lvLrVzBbNqzs+ODooZ6OksuSUNM7Njkw==
dependencies:
debug "^4.1.0"
json-stringify-safe "^5.0.1"
lodash "^4.17.21"
propagate "^2.0.0"
node-abort-controller@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/node-abort-controller/-/node-abort-controller-3.0.1.tgz#f91fa50b1dee3f909afabb7e261b1e1d6b0cb74e"