Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unskip test that fail with lolex v2 #12858

Merged
merged 1 commit into from Jan 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions extensions/amp-access/0.1/test/test-amp-access-client.js
Expand Up @@ -31,7 +31,7 @@ describes.realWin('AccessClientAdapter', {

beforeEach(() => {
ampdoc = env.ampdoc;
clock = lolex.install();
clock = lolex.install({target: ampdoc.win});

validConfig = {
'authorization': 'https://acme.com/a?rid=READER_ID',
Expand Down Expand Up @@ -190,8 +190,7 @@ describes.realWin('AccessClientAdapter', {
});
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('should time out XHR fetch', () => {
it('should time out XHR fetch', () => {
contextMock.expects('buildUrl')
.withExactArgs(
'https://acme.com/a?rid=READER_ID',
Expand Down
8 changes: 3 additions & 5 deletions extensions/amp-access/0.1/test/test-amp-access-server-jwt.js
Expand Up @@ -34,7 +34,7 @@ describes.realWin('AccessServerJwtAdapter', {amp: true}, env => {
beforeEach(() => {
win = env.win;
ampdoc = env.ampdoc;
clock = lolex.install();
clock = lolex.install({target: win});

validConfig = {
'authorization': 'https://acme.com/a?rid=READER_ID',
Expand Down Expand Up @@ -277,8 +277,7 @@ describes.realWin('AccessServerJwtAdapter', {amp: true}, env => {
});
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('should fail when authorize-and-fill times out', () => {
it('should fail when authorize-and-fill times out', () => {
adapter.serviceUrl_ = 'http://localhost:8000/af';
const authdata = {};
const jwt = {'amp_authdata': authdata};
Expand Down Expand Up @@ -408,8 +407,7 @@ describes.realWin('AccessServerJwtAdapter', {amp: true}, env => {
});
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('should fail when JWT fetch times out', () => {
it('should fail when JWT fetch times out', () => {
contextMock.expects('buildUrl')
.withExactArgs(
'https://acme.com/a?rid=READER_ID',
Expand Down
5 changes: 2 additions & 3 deletions extensions/amp-access/0.1/test/test-amp-access-server.js
Expand Up @@ -33,7 +33,7 @@ describes.realWin('AccessServerAdapter', {amp: true}, env => {
win = env.win;
document = win.document;
ampdoc = env.ampdoc;
clock = lolex.install();
clock = lolex.install({target: win});

validConfig = {
'authorization': 'https://acme.com/a?rid=READER_ID',
Expand Down Expand Up @@ -232,8 +232,7 @@ describes.realWin('AccessServerAdapter', {amp: true}, env => {
});
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('should time out XHR fetch', () => {
it('should time out XHR fetch', () => {
adapter.serviceUrl_ = 'http://localhost:8000/af';
contextMock.expects('collectUrlVars')
.withExactArgs(
Expand Down
5 changes: 2 additions & 3 deletions extensions/amp-ad/0.1/test/test-amp-ad-3p-impl.js
Expand Up @@ -291,9 +291,8 @@ describes.realWin('amp-ad-3p-impl', {
expect(ad3p.renderOutsideViewport()).to.equal(1.25);
});

// TODO(lannka, #12486): Make this test work with lolex v2.
it.skip('should only allow rendering one ad per second', function* () {
const clock = lolex.install();
it('should only allow rendering one ad per second', function* () {
const clock = lolex.install({target: win});
const ad3p2 = createAmpAd(win);
expect(ad3p.renderOutsideViewport()).to.equal(3);
expect(ad3p2.renderOutsideViewport()).to.equal(3);
Expand Down
6 changes: 3 additions & 3 deletions extensions/amp-ad/0.1/test/test-concurrent-load.js
Expand Up @@ -65,15 +65,15 @@ describes.realWin('concurrent-load', {}, env => {
}
});

// TODO(lannka, #12486): Make this test work with lolex v2.
describe.skip('incrementLoadingAds', () => {
describe('incrementLoadingAds', () => {

let win;
let clock;

beforeEach(() => {
win = env.win;
clock = lolex.install({toFake: ['Date', 'setTimeout', 'clearTimeout']});
clock = lolex.install({
target: win, toFake: ['Date', 'setTimeout', 'clearTimeout']});
installTimerService(win);
});

Expand Down
20 changes: 7 additions & 13 deletions extensions/amp-analytics/0.1/test/test-events.js
Expand Up @@ -542,7 +542,7 @@ describes.realWin('Events', {amp: 1}, env => {
let tracker;

beforeEach(() => {
clock = lolex.install(root.ampdoc.win);
clock = lolex.install({target: root.ampdoc.win});
tracker = root.getTracker('timer', TimerEventTracker);
});

Expand Down Expand Up @@ -685,8 +685,7 @@ describes.realWin('Events', {amp: 1}, env => {
});
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('timers started and stopped by the same event on the same target'
it('timers started and stopped by the same event on the same target'
+ ' do not have race condition problems', () => {
const fn1 = sandbox.stub();
tracker.add(analyticsElement, 'timer', {timerSpec: {
Expand Down Expand Up @@ -740,8 +739,7 @@ describes.realWin('Events', {amp: 1}, env => {
expect(fn2.args[0][0].type).to.equal('timer');
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('fires on the appropriate interval', () => {
it('fires on the appropriate interval', () => {
const fn1 = sandbox.stub();
tracker.add(analyticsElement, 'timer', {timerSpec: {
interval: 10,
Expand Down Expand Up @@ -791,8 +789,7 @@ describes.realWin('Events', {amp: 1}, env => {
expect(fn1.args[0][0].type).to.equal('timer');
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('stops firing after the maxTimerLength is exceeded', () => {
it('stops firing after the maxTimerLength is exceeded', () => {
const fn1 = sandbox.stub();
tracker.add(analyticsElement, 'timer', {timerSpec: {
interval: 10,
Expand Down Expand Up @@ -861,8 +858,7 @@ describes.realWin('Events', {amp: 1}, env => {
expect(tracker.getTrackedTimerKeys()).to.have.length(1);
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('should unlisten tracker', () => {
it('should unlisten tracker', () => {
const fn1 = sandbox.stub();
const u1 = tracker.add(analyticsElement, 'timer', {timerSpec: {
interval: 10,
Expand All @@ -889,8 +885,7 @@ describes.realWin('Events', {amp: 1}, env => {
expect(countIntervals()).to.equal(0);
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('should dispose all trackers', () => {
it('should dispose all trackers', () => {
const fn1 = sandbox.stub();
tracker.add(analyticsElement, 'timer', {timerSpec: {
interval: 10,
Expand All @@ -911,8 +906,7 @@ describes.realWin('Events', {amp: 1}, env => {
expect(countIntervals()).to.equal(0);
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('should create events with timer vars', () => {
it('should create events with timer vars', () => {
const handler = sandbox.stub();
tracker.add(analyticsElement, 'timer', {timerSpec: {
interval: 3,
Expand Down
5 changes: 2 additions & 3 deletions extensions/amp-analytics/0.1/test/test-requests.js
Expand Up @@ -29,7 +29,7 @@ describes.realWin('Requests', {amp: 1}, env => {
beforeEach(() => {
installVariableService(env.win);
ampdoc = env.ampdoc;
clock = lolex.install();
clock = lolex.install({target: ampdoc.win});
preconnectSpy = sandbox.spy();
preconnect = {
url: preconnectSpy,
Expand All @@ -40,8 +40,7 @@ describes.realWin('Requests', {amp: 1}, env => {
clock.uninstall();
});

// TODO(lannka, #12486): Make this test work with lolex v2.
describe.skip('RequestHandler', () => {
describe('RequestHandler', () => {
describe('batch Delay', () => {
it('maxDelay should be a number', () => {
const r1 = {'baseUrl': 'r1', 'maxDelay': 1};
Expand Down
6 changes: 3 additions & 3 deletions test/functional/test-ad-cid.js
Expand Up @@ -36,7 +36,8 @@ describes.realWin('ad-cid', {amp: true}, env => {
beforeEach(() => {
win = env.win;
sandbox = env.sandbox;
clock = lolex.install({toFake: ['Date', 'setTimeout', 'clearTimeout']});
clock = lolex.install({
target: win, toFake: ['Date', 'setTimeout', 'clearTimeout']});
element = env.win.document.createElement('amp-ad');
element.setAttribute('type', '_ping_');
const ampdoc = env.ampdoc;
Expand Down Expand Up @@ -89,8 +90,7 @@ describes.realWin('ad-cid', {amp: true}, env => {
});
});

// TODO(lannka, #12486): Make this test work with lolex v2.
it.skip('should return on timeout', () => {
it('should return on timeout', () => {
config.clientIdScope = cidScope;
sandbox.stub(cidService, 'get').callsFake(() => {
return Services.timerFor(win).promise(2000);
Expand Down
12 changes: 5 additions & 7 deletions test/functional/test-cid.js
Expand Up @@ -723,7 +723,8 @@ describes.realWin('cid', {amp: true}, env => {
win = env.win;
ampdoc = env.ampdoc;
sandbox = env.sandbox;
clock = lolex.install({toFake: ['Date', 'setTimeout', 'clearTimeout']});
clock = lolex.install({
target: win, toFake: ['Date', 'setTimeout', 'clearTimeout']});
cid = cidServiceForDocForTesting(ampdoc);
});

Expand Down Expand Up @@ -758,8 +759,7 @@ describes.realWin('cid', {amp: true}, env => {
.to.eventually.equal('cid-from-viewer');
});

// TODO(lannka, #12486): Make this test work with lolex v2.
it.skip('get method should time out when in Viewer', function *() {
it('get method should time out when in Viewer', function *() {
win.parent = {};
stubServiceForDoc(sandbox, ampdoc, 'viewer', 'sendMessageAwaitResponse')
.returns(new Promise(() => {}));
Expand Down Expand Up @@ -795,8 +795,7 @@ describes.realWin('cid', {amp: true}, env => {
setCookie(win, '_ga', '', 0);
});

// TODO(lannka, #12486): Make this test work with lolex v2.
it.skip('should use cid api on pub origin if opted in', () => {
it('should use cid api on pub origin if opted in', () => {
const getScopedCidStub = sandbox.stub(cid.cidApi_, 'getScopedCid');
getScopedCidStub.returns(Promise.resolve('cid-from-api'));
return cid.get({
Expand All @@ -811,8 +810,7 @@ describes.realWin('cid', {amp: true}, env => {
});
});

// TODO(lannka, #12486): Make this test work with lolex v2.
it.skip('should fallback to cookie if cid api returns nothing', () => {
it('should fallback to cookie if cid api returns nothing', () => {
sandbox.stub(cid.cidApi_, 'getScopedCid').returns(Promise.resolve());
return cid.get({
scope: 'AMP_ECID_GOOGLE',
Expand Down
22 changes: 8 additions & 14 deletions test/functional/test-custom-element.js
Expand Up @@ -106,7 +106,7 @@ describes.realWin('CustomElement', {amp: true}, env => {
win = env.win;
doc = win.document;
ampdoc = env.ampdoc;
clock = lolex.install();
clock = lolex.install({target: win});
resources = Services.resourcesForDoc(doc);
resources.isBuildOn_ = true;
resourcesMock = sandbox.mock(resources);
Expand Down Expand Up @@ -362,8 +362,7 @@ describes.realWin('CustomElement', {amp: true}, env => {
expect(element.isBuilt()).to.equal(false);
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('Element - re-upgrade to new direct instance', () => {
it('Element - re-upgrade to new direct instance', () => {
const element = new ElementClass();
expect(element.isUpgraded()).to.equal(false);
const newImpl = new TestElement(element);
Expand All @@ -375,8 +374,7 @@ describes.realWin('CustomElement', {amp: true}, env => {
expect(element.upgradeDelayMs_).to.equal(0);
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('Element - re-upgrade to new promised instance', () => {
it('Element - re-upgrade to new promised instance', () => {
const element = new ElementClass();
expect(element.isUpgraded()).to.equal(false);
const oldImpl = element.implementation_;
Expand Down Expand Up @@ -544,8 +542,7 @@ describes.realWin('CustomElement', {amp: true}, env => {
});
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('Element - buildCallback cannot be called twice', () => {
it('Element - buildCallback cannot be called twice', () => {
const element = new ElementClass();
expect(element.isBuilt()).to.equal(false);
expect(testElementBuildCallback).to.have.not.been.called;
Expand Down Expand Up @@ -717,8 +714,7 @@ describes.realWin('CustomElement', {amp: true}, env => {
expect(testElementLayoutCallback).to.have.not.been.called;
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('Element - layoutCallback', () => {
it('Element - layoutCallback', () => {
const element = new ElementClass();
element.setAttribute('layout', 'fill');
container.appendChild(element);
Expand Down Expand Up @@ -839,8 +835,7 @@ describes.realWin('CustomElement', {amp: true}, env => {
});
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('should dequeue all actions after build', () => {
it('should dequeue all actions after build', () => {
const element = new ElementClass();
const handler = sandbox.spy();
element.implementation_.executeAction = handler;
Expand Down Expand Up @@ -1513,7 +1508,7 @@ describes.realWin('CustomElement', {amp: true}, env => {
beforeEach(() => {
win = env.win;
doc = win.document;
clock = lolex.install();
clock = lolex.install({target: win});
ElementClass = doc.registerElement('amp-test-loader', {
prototype: createAmpElementProtoForTesting(
win, 'amp-test-loader', TestElement),
Expand Down Expand Up @@ -1715,8 +1710,7 @@ describes.realWin('CustomElement', {amp: true}, env => {
expect(toggle).to.have.not.been.called;
});

// TODO(dvoytenko, #12486): Make this test work with lolex v2.
it.skip('should turn on when enters viewport', () => {
it('should turn on when enters viewport', () => {
stubInA4A(false);
const toggle = sandbox.spy(element, 'toggleLoading_');
element.viewportCallback(true);
Expand Down
9 changes: 4 additions & 5 deletions test/functional/test-jank-meter.js
Expand Up @@ -26,7 +26,8 @@ describes.realWin('jank-meter', {}, env => {

beforeEach(() => {
win = env.win;
clock = lolex.install({toFake: ['Date', 'setTimeout', 'clearTimeout']});
clock = lolex.install({
target: win, toFake: ['Date', 'setTimeout', 'clearTimeout']});

meter = new JankMeter(win);
meter.perf_ = {
Expand All @@ -40,8 +41,7 @@ describes.realWin('jank-meter', {}, env => {
clock.uninstall();
});

// TODO(lannka, #12486): Make this test work with lolex v2.
it.skip('should use first schedule time when scheduled ' +
it('should use first schedule time when scheduled ' +
'multiple times ', () => {
meter.onScheduled();
clock.tick(5);
Expand All @@ -52,8 +52,7 @@ describes.realWin('jank-meter', {}, env => {
expect(meter.badFrameCnt_).to.equal(1);
});

// TODO(lannka, #12486): Make this test work with lolex v2.
it.skip('should count bad frames correctly', () => {
it('should count bad frames correctly', () => {
runTask(16);
expect(meter.totalFrameCnt_).to.equal(1);
expect(meter.badFrameCnt_).to.equal(0);
Expand Down
6 changes: 3 additions & 3 deletions test/functional/test-layout-delay-meter.js
Expand Up @@ -37,7 +37,8 @@ describes.realWin('layout-delay-meter', {
installPerformanceService(win);
const perf = Services.performanceFor(win);
sandbox.stub(perf, 'isPerformanceTrackingOn').callsFake(() => true);
clock = lolex.install({toFake: ['Date', 'setTimeout', 'clearTimeout']});
clock = lolex.install({
target: win, toFake: ['Date', 'setTimeout', 'clearTimeout']});
tickSpy = sandbox.spy(perf, 'tickDelta');

meter = new LayoutDelayMeter(win, 2);
Expand All @@ -47,8 +48,7 @@ describes.realWin('layout-delay-meter', {
clock.uninstall();
});

// TODO(lannka, #12486): Make this test work with lolex v2.
it.skip('should tick when there is a delay', () => {
it('should tick when there is a delay', () => {
clock.tick(100);
meter.enterViewport(); // first time in viewport
clock.tick(100);
Expand Down