Skip to content

Commit

Permalink
test: add more electron framework tests for release builds (#4272)
Browse files Browse the repository at this point in the history
  • Loading branch information
karanbirsingh authored May 24, 2021
1 parent d0cfe34 commit b6766bd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pipeline/scripts/download-electron-mirror-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ const process = require('process');
const { downloadArtifact } = require('@electron/get');
const extract = require('extract-zip');
const pkg = require('../../package.json');
const { electronBuildId } = require('./electron-build-id');

/*
This script replaces existing electron & chromedriver modules
with mirror dependencies specified by `assetNumber` and pipeline
with mirror dependencies specified by `electronBuildId` and pipeline
build variables. We use this to avoid bundling non-freely-redistributable
media codecs in our release builds. The version of Electron published to
npm includes these as part of Chromium; our release builds use a
Expand All @@ -28,8 +29,6 @@ if (
process.exit(1);
}

const assetNumber = '7912306';

const clearAndExtract = async (zipFilePath, destinationPath) => {
destinationPath = path.resolve(destinationPath);

Expand All @@ -52,7 +51,7 @@ const resolveCustomAssetURL = details => {
details.artifactSuffix ? details.artifactSuffix : '',
].join('-')}.zip`.replace('-.', '.');
const strippedVer = details.version.replace(/^v/, '');
return `${opts.mirror}/${strippedVer}/${opts.customDir}/${assetNumber}/${file}`;
return `${opts.mirror}/${strippedVer}/${opts.customDir}/${electronBuildId}/${file}`;
};

const downloadElectronArtifact = async (artifactName, artifactSuffix) => {
Expand Down
9 changes: 9 additions & 0 deletions pipeline/scripts/electron-build-id.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

/*
This number identifies an internally-maintained Electron build
used in our releases. Each Electron update in package.json requires
a corresponding change here.
*/
exports.electronBuildId = '7912306';
23 changes: 23 additions & 0 deletions src/tests/electron/tests/framework-no-codecs.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { readFileSync } from 'fs';
import * as path from 'path';
import { createAppController } from 'tests/electron/common/create-application';
import { AppController } from 'tests/electron/common/view-controllers/app-controller';
import { CodecTestViewController } from 'tests/electron/common/view-controllers/codecs-test-view-controller';
import { electronBuildId } from '../../../../pipeline/scripts/electron-build-id.js';

/*
We bundle a mirrored version of electron with no
Expand Down Expand Up @@ -35,5 +37,26 @@ const releaseTests = process.env.RUN_RELEASE_TESTS === 'true';
it('has error when loading mp3 <audio> in renderer process', async () => {
expect(await viewContoller.client.getAttribute('#audio', 'data-err')).toEqual('4');
});

it('uses expected build during release', async () => {
const buildId = await viewContoller.client.execute(() => {
return (window as any).process.versions['microsoft-build'];
});
expect(buildId).toBe(electronBuildId);
});
},
);

it('electron versions in package.json and build id are updated together', async () => {
const mainPackage = JSON.parse(readFileSync('package.json', { encoding: 'utf-8' }));
const versions = {
electronVersion: mainPackage.dependencies.electron,
electronBuildId,
};
expect(versions).toMatchInlineSnapshot(`
Object {
"electronBuildId": "7912306",
"electronVersion": "11.4.5",
}
`);
});

0 comments on commit b6766bd

Please sign in to comment.