Skip to content

Commit

Permalink
move onerror-per-visit test to scenario-tester
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Oct 27, 2023
1 parent c6962b3 commit 1e5d8cb
Show file tree
Hide file tree
Showing 14 changed files with 209 additions and 66,535 deletions.
119 changes: 0 additions & 119 deletions packages/fastboot/test/fastboot-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,125 +337,6 @@ describe('FastBoot', function() {
});
});

it('errors can be properly attributed with buildSandboxPerVisit=true', async function() {
this.timeout(3000);

var fastboot = new FastBoot({
distPath: fixture('onerror-per-visit'),
});

let first = fastboot.visit('/slow/100/reject', {
buildSandboxPerVisit: true,
request: { url: '/slow/100/reject', headers: {} },
});

let second = fastboot.visit('/slow/50/resolve', {
buildSandboxPerVisit: true,
request: { url: '/slow/50/resolve', headers: {} },
});

let third = fastboot.visit('/slow/25/resolve', {
buildSandboxPerVisit: true,
request: { url: '/slow/25/resolve', headers: {} },
});

await Promise.all([second, third]);

await first.then(
() => {
throw new Error('Visit should not resolve!');
},
error => {
expect(error.code).to.equal('from-slow');
expect(error.fastbootRequestPath).to.equal('/slow/100/reject');
}
);
});

it('it eagerly builds sandbox when queue is empty', async function() {
this.timeout(3000);

var fastboot = new FastBoot({
distPath: fixture('onerror-per-visit'),
maxSandboxQueueSize: 2,
});

let first = fastboot.visit('/slow/50/resolve', {
buildSandboxPerVisit: true,
request: { url: '/slow/50/resolve', headers: {} },
});

let second = fastboot.visit('/slow/50/resolve', {
buildSandboxPerVisit: true,
request: { url: '/slow/50/resolve', headers: {} },
});

let third = fastboot.visit('/slow/25/resolve', {
buildSandboxPerVisit: true,
request: { url: '/slow/25/resolve', headers: {} },
});

let result = await first;
let analytics = result.analytics;
expect(analytics).to.be.deep.equals({
usedPrebuiltSandbox: true,
});

result = await second;
analytics = result.analytics;
expect(analytics).to.be.deep.equals({
usedPrebuiltSandbox: true,
});

result = await third;
analytics = result.analytics;
expect(analytics).to.be.deep.equals({
usedPrebuiltSandbox: false,
});
});

it('it leverages sandbox from queue when present', async function() {
this.timeout(3000);

var fastboot = new FastBoot({
distPath: fixture('onerror-per-visit'),
maxSandboxQueueSize: 3,
});

let first = fastboot.visit('/slow/50/resolve', {
buildSandboxPerVisit: true,
request: { url: '/slow/50/resolve', headers: {} },
});

let second = fastboot.visit('/slow/50/resolve', {
buildSandboxPerVisit: true,
request: { url: '/slow/50/resolve', headers: {} },
});

let third = fastboot.visit('/slow/25/resolve', {
buildSandboxPerVisit: true,
request: { url: '/slow/25/resolve', headers: {} },
});

let result = await first;
let analytics = result.analytics;
expect(analytics).to.be.deep.equals({
usedPrebuiltSandbox: true,
});

result = await second;
analytics = result.analytics;
expect(analytics).to.be.deep.equals({
usedPrebuiltSandbox: true,
});

result = await third;
analytics = result.analytics;
expect(analytics).to.be.deep.equals({
usedPrebuiltSandbox: true,
});
});

it('htmlEntrypoint works', function() {
var fastboot = new FastBoot({
distPath: fixture('html-entrypoint'),
Expand Down

This file was deleted.

This file was deleted.

Empty file.
Loading

0 comments on commit 1e5d8cb

Please sign in to comment.