Skip to content

Commit

Permalink
Merge branch 'nathan/create-load-during-upgrades-and-downgrades' into…
Browse files Browse the repository at this point in the history
… 'master'

test(service-worker): create load on the service worker during upgrade and downgrade e2e tests

re #TT-233 

See merge request dfinity-lab/public/ic!14314
  • Loading branch information
nathanosdev committed Sep 14, 2023
2 parents 330df35 + a350637 commit 0ebf3ed
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
21 changes: 17 additions & 4 deletions typescript/service-worker/e2e/specs/asset-loading.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
runInBrowser,
waitForServiceWorkerUpgrade,
env,
loadSampleAssetUnderLoad,
} from '../utils';

const { baseUrl, swPath, currentSwPath, latestSwPath, previousSwPath } = env;
Expand All @@ -23,31 +24,43 @@ it('should load sample asset', async () => {

console.log('\n\nDeploying latest service worker...');
await deployServiceWorker(latestSwPath, swPath);
await waitForServiceWorkerUpgrade(browser);
await Promise.all([
await waitForServiceWorkerUpgrade(browser),
await loadSampleAssetUnderLoad(browser),
]);

console.log('Running tests...');
contentElem = await loadSampleAsset(browser);
await expectSampleAssetLoaded(contentElem);

console.log('\n\nDeploying current service worker...');
await deployServiceWorker(currentSwPath, swPath);
await waitForServiceWorkerUpgrade(browser);
await Promise.all([
await waitForServiceWorkerUpgrade(browser),
await loadSampleAssetUnderLoad(browser),
]);

console.log('Running tests...');
contentElem = await loadSampleAsset(browser);
await expectSampleAssetLoaded(contentElem);

console.log('\n\nDeploying previous service worker...');
await deployServiceWorker(previousSwPath, swPath);
await waitForServiceWorkerUpgrade(browser);
await Promise.all([
await waitForServiceWorkerUpgrade(browser),
await loadSampleAssetUnderLoad(browser),
]);

console.log('Running tests...');
contentElem = await loadSampleAsset(browser);
await expectSampleAssetLoaded(contentElem);

console.log('\n\nDeploying current service worker...');
await deployServiceWorker(currentSwPath, swPath);
await waitForServiceWorkerUpgrade(browser);
await Promise.all([
await waitForServiceWorkerUpgrade(browser),
await loadSampleAssetUnderLoad(browser),
]);

console.log('Running tests...');
contentElem = await loadSampleAsset(browser);
Expand Down
12 changes: 12 additions & 0 deletions typescript/service-worker/e2e/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ export async function waitForServiceWorkerUpgrade(
await setTimeout(3000);
}

export async function loadSampleAssetUnderLoad(
browser: WebdriverIO.Browser
): Promise<void> {
await Promise.all(
new Array(100).fill(async () => {
const contentElem = await loadSampleAsset(browser);

await expectSampleAssetLoaded(contentElem);
})
);
}

export async function loadSampleAsset(
browser: WebdriverIO.Browser
): Promise<WebdriverIO.Element> {
Expand Down

0 comments on commit 0ebf3ed

Please sign in to comment.