diff --git a/test/modules/amp-caching/amp-caching-test.js b/test/modules/amp-caching/amp-caching-test.js index b5f1088..681c9f4 100644 --- a/test/modules/amp-caching/amp-caching-test.js +++ b/test/modules/amp-caching/amp-caching-test.js @@ -18,8 +18,10 @@ import { buildSW } from '../../../lib/builder/index'; import { promisify } from 'util'; import * as fs from 'fs'; import { join } from 'path'; +const fetch = require('node-fetch'); import { testStaleWhileRevalidate } from '../../strategy-tests/strategy-tests'; +const METADATA_URL = 'https://cdn.ampproject.org/rtv/metadata'; const writeFile = promisify(fs.writeFile); describe('AMP caching module', function() { @@ -135,11 +137,14 @@ describe('AMP caching module', function() { }); it('should cache AMP scripts given by postMessage', async () => { + const ampRuntimeVersion = (await (await fetch(METADATA_URL)).json())[ + 'ampRuntimeVersion' + ]; await driver.get('http://localhost:6881/test/index.html'); const cacheName = 'AMP-VERSIONED-CACHE'; const payload = [ - 'https://cdn.ampproject.org/rtv/001525381599226/v0.js', - 'https://cdn.ampproject.org/rtv/001810022028350/v0/amp-mustache-0.1.js', + `https://cdn.ampproject.org/rtv/${ampRuntimeVersion}/v0.js`, + `https://cdn.ampproject.org/rtv/${ampRuntimeVersion}/v0/amp-mustache-0.1.js`, 'https://code.jquery.com/jquery-3.3.1.min.js', ]; let hasVersionJSInCache = await driver.executeAsyncScript( diff --git a/test/modules/offline-page/offline-page-test.js b/test/modules/offline-page/offline-page-test.js index 49fbfeb..8a0a859 100644 --- a/test/modules/offline-page/offline-page-test.js +++ b/test/modules/offline-page/offline-page-test.js @@ -90,12 +90,19 @@ describe('Offline page module', function() { }); it('should use offline page when navigating to an uncached page', async () => { - global.__AMPSW.server.stop(); - await sleep(5000); + await driver.setNetworkConditions({ + offline: true, + latency: 5, + throughput: 500 * 1024, + }); await driver.navigate().refresh(); const title = await driver.getTitle(); expect(title).to.be.equal('Offline page'); - global.__AMPSW.server.start(); + await driver.setNetworkConditions({ + offline: false, + latency: 0, + throughput: 500 * 1024, + }); await driver.navigate().refresh(); }); });