Skip to content

Commit

Permalink
cli compare. test setup for A/B
Browse files Browse the repository at this point in the history
  • Loading branch information
lynchbomb committed Apr 1, 2019
1 parent c83fa7a commit ce09eb8
Show file tree
Hide file tree
Showing 5 changed files with 49,125 additions and 6 deletions.
36 changes: 30 additions & 6 deletions packages/cli/test/commands/compare.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,48 @@ import { tmpDir } from '../setup';

chai.use(require('chai-fs'));

const indexFile = path.join(
process.cwd() + '/test/fixtures/release/index.html'
const control = path.join(process.cwd() + '/test/fixtures/release/index.html');
const experiment = path.join(
process.cwd() + '/test/fixtures/experiment/index.html'
);
const fixture = `file://${indexFile}?tracing`;
const experimentFixture = `file://${experiment}?tracing`;
const controlFixture = `file://${control}?tracing`;
const fidelity = 'test';
const output = path.join(`${process.cwd()}/${tmpDir}`);

describe('compare: fixture: A/A', () => {
test
.stdout()
.it(
`runs compare --controlURL ${fixture} --experimentURL ${fixture} --fidelity ${fidelity} --output ${output}`,
`runs compare --controlURL ${controlFixture} --experimentURL ${controlFixture} --fidelity ${fidelity} --output ${output}`,
async ctx => {
await Compare.run([
'--controlURL',
fixture,
controlFixture,
'--experimentURL',
fixture,
controlFixture,
'--fidelity',
fidelity,
'--output',
output
]);

chai.expect(ctx.stdout).to.contain(`Success`);
}
);
});

describe('compare: fixture: A/B', () => {
test
.stdout()
.it(
`runs compare --controlURL ${controlFixture} --experimentURL ${experimentFixture} --fidelity ${fidelity} --output ${output}`,
async ctx => {
await Compare.run([
'--controlURL',
controlFixture,
'--experimentURL',
experimentFixture,
'--fidelity',
fidelity,
'--output',
Expand Down
56 changes: 56 additions & 0 deletions packages/cli/test/fixtures/experiment/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Ember.TEMPLATES["application"] = Ember.HTMLBars.template({
"id": null,
"block": "{\"symbols\":[],\"statements\":[[7,\"h1\"],[9],[0,\"Welcome To Ember\"],[10],[0,\"\\n\"],[7,\"div\"],[18,\"style\",[21,\"color\"]],[9],[0,\"\\n\"],[1,[21,\"outlet\"],false],[0,\"\\n\"],[10]],\"hasEval\":false}",
"meta": {}
});
var MyApp;
(function () {
"use strict";

function renderEnd() {
performance.mark("renderEnd");
requestAnimationFrame(function () {
performance.mark("beforePaint");
requestAnimationFrame(function () {
performance.mark("afterPaint");
performance.measure("document", "navigationStart", "domLoading");
performance.measure("jquery", "domLoading", "jqueryLoaded");
performance.measure("ember", "jqueryLoaded", "emberLoaded");
performance.measure("application", "emberLoaded", "startRouting");
performance.measure("routing", "startRouting", "willTransition");
performance.measure("transition", "willTransition", "didTransition");
performance.measure("render", "didTransition", "renderEnd");
performance.measure("afterRender", "renderEnd", "beforePaint");
performance.measure("paint", "beforePaint", "afterPaint");
if (location.search === "?tracing") {
requestAnimationFrame(function () {
setTimeout(function () {
document.location.href = "about:blank";
}, 0);
});
}
});
});
}

MyApp = Ember.Application.extend({
autoboot: false
}).create();

MyApp.Router = Ember.Router.extend({
location: "none",
setupRouter: function () {
performance.mark("startRouting");
this.on("willTransition", function () {
performance.mark("willTransition");
});
this.on("didTransition", function () {
performance.mark("didTransition");
Ember.run.schedule("afterRender", renderEnd);
});
this._super.apply(this, arguments);
}
});

Ember.run(MyApp, "visit", "/");
})();
Loading

0 comments on commit ce09eb8

Please sign in to comment.