Skip to content

Commit

Permalink
fix: new tests failing
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Nov 16, 2022
1 parent 9d6cf90 commit a93550e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions end-to-end/test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,35 @@ describe('basic Full Client tests', () => {
});

it('allows you to block urls: strings', async () => {
koaServer.get('/block', ctx => {
koaServer.get('/block-strings', ctx => {
ctx.body = `<html>
<head>
<link rel="stylesheet" href="/test.css" />
<link rel="stylesheet" href="/foo/bar/42.css?x=foo&y=%20baz" />
</head>
<body>
<img src="/img.png" alt="Image"/>
<img src="/baz/bar.png" alt="Image"/>
</body>
</html>`;
});

koaServer.get('/foo/bar/42?x=foo&y=%20baz', ctx => {
koaServer.get('/foo/bar/42.css?x=foo&y=%20baz', ctx => {
ctx.statusCode = 500;
});
koaServer.get('/baz/bar', ctx => {
koaServer.get('/baz/bar.png', ctx => {
ctx.statusCode = 500;
});

const hero = new Hero({
blockedResourceUrls: [
'42?x=foo',
'42.css?x=foo',
'/baz/',
],
});
Helpers.needsClosing.push(hero);

const resources: Resource[] = [];
await hero.activeTab.on('resource', event => resources.push(event as any));
await hero.goto(`${koaServer.baseUrl}/block`);
await hero.goto(`${koaServer.baseUrl}/block-strings`);
await hero.waitForPaintingStable();
await new Promise(setImmediate);
expect(resources).toHaveLength(1);
Expand All @@ -97,35 +97,35 @@ describe('basic Full Client tests', () => {
});

it('allows you to block urls: RegExp', async () => {
koaServer.get('/block', ctx => {
koaServer.get('/block-regexes', ctx => {
ctx.body = `<html>
<head>
<link rel="stylesheet" href="/test.css" />
<link rel="stylesheet" href="/foo/bar/42.css?x=foo&y=%20baz" />
</head>
<body>
<img src="/img.png" alt="Image"/>
<img src="/baz/bar.png" alt="Image"/>
</body>
</html>`;
});

koaServer.get('/foo/bar/42?x=foo&y=%20baz', ctx => {
koaServer.get('/foo/bar/42.css?x=foo&y=%20baz', ctx => {
ctx.statusCode = 500;
});
koaServer.get('/baz/bar', ctx => {
koaServer.get('/baz/bar.png', ctx => {
ctx.statusCode = 500;
});

const hero = new Hero({
blockedResourceUrls: [
/42\?x=oo/,
/.*\?x=foo/,
/\/baz\//,
],
});
Helpers.needsClosing.push(hero);

const resources: Resource[] = [];
await hero.activeTab.on('resource', event => resources.push(event as any));
await hero.goto(`${koaServer.baseUrl}/block`);
await hero.goto(`${koaServer.baseUrl}/block-regexes`);
await hero.waitForPaintingStable();
await new Promise(setImmediate);
expect(resources).toHaveLength(1);
Expand Down

0 comments on commit a93550e

Please sign in to comment.