Skip to content

Commit

Permalink
Merge 011cee5 into f40461f
Browse files Browse the repository at this point in the history
  • Loading branch information
bitdisaster committed Apr 27, 2020
2 parents f40461f + 011cee5 commit c18f0b2
Show file tree
Hide file tree
Showing 10 changed files with 335 additions and 153 deletions.
14 changes: 14 additions & 0 deletions __tests__/creator-spec.ts
Expand Up @@ -421,6 +421,8 @@ test('MSICreator create() shortcut name override', async () => {
});
testIncludes('Custom shortcut name', '<Shortcut Id="ApplicationStartMenuShortcut" Name="BeepBeep"');

testIncludes('Single Package Authoring setting', '<Property Id="ALLUSERS" Secure="yes" Value="2" />');
testIncludes('correct default perUser setting', '<Property Id="MSIINSTALLPERUSER" Secure="yes" Value="0" />');
testIncludes('Install path property', '<Property Id="INSTALLPATH">');
testIncludes('Install RegistrySearch', '<RegistrySearch Key="SOFTWARE\\Acme Technologies\\Acme"');
testIncludes('RegistryInstallPath component', '<Component Id="RegistryInstallPath"');
Expand Down Expand Up @@ -484,3 +486,15 @@ describe('auto-launch', () => {
testIncludes('RegistryRunKey component-ref', '<ComponentRef Id="RegistryRunKey" />');
regexTestIncludes('AutoLaunch feature', /<Feature Id="AutoLaunch" Title="Launch On Login" Level="2" .*>/);
});

describe('perUser install by default', () => {
test('MSICreator includes Auto-Updater feature', async () => {
const msiCreator = new MSICreator({ ...defaultOptions, defaultInstallMode: 'perUser' });
const { wxsFile } = await msiCreator.create();
wxsContent = await fs.readFile(wxsFile, 'utf-8');
console.log(wxsContent);
expect(wxsFile).toBeTruthy();
});

testIncludes('correct defautlt perUser setting', '<Property Id="MSIINSTALLPERUSER" Secure="yes" Value="1" />');
});
2 changes: 1 addition & 1 deletion __tests__/utils/array-to-tree-spec.ts
Expand Up @@ -78,7 +78,7 @@ const mockFolderFileTree = defaultsDeep(cloneDeep(mockFolderTree), {
id: 'RegistryInstallPath',
key: 'SOFTWARE\\{{Manufacturer}}\\{{ApplicationName}}',
name: 'InstallPath',
root: 'HKLM',
root: 'HKMU',
type: 'string',
value: '[APPLICATIONROOTDIRECTORY]',
}],
Expand Down
103 changes: 55 additions & 48 deletions e2e/src/e2e-auto-launch.ts
Expand Up @@ -37,61 +37,68 @@ describe('MSI auto-launch', () => {
];

testConfigs.forEach((testConfig) => {
const msiOptions = {
...autoLaunchMsiOptions,
...testConfig
};
const msiPaths123beta = getInstallPaths(msiOptions);

it(`packages (${testConfig.arch})`, async () => {
await createMsiPackage(msiOptions);
});
describe((`arch:${testConfig.arch}`), () => {
after(() => {
// even if we failed, we still wanna leave behind a clean state for the next test
fs.rmdirSync(msiPaths123beta.appRootFolder, { recursive: true });
});

it(`installs (${testConfig.arch})`, async () => {
await install(msiPath, 3);
const version = getWindowsCompliantVersion(msiOptions.version);
expect(await checkInstall(msiOptions.name, version)).ok();
});
const msiOptions = {
...autoLaunchMsiOptions,
...testConfig
};
const msiPaths123beta = getInstallPaths(msiOptions);

it(`has all files in program files (${testConfig.arch})`, () => {
expect(fs.pathExistsSync(msiPaths123beta.stubExe)).ok();
expect(fs.pathExistsSync(msiPaths123beta.appFolder)).ok();
expectSameFolderContent(HARNESS_APP_DIR, msiPaths123beta.appFolder);
});
it(`packages (${testConfig.arch})`, async () => {
await createMsiPackage(msiOptions);
});

it(`has shortcuts (${testConfig.arch})`, () => {
expect(fs.pathExistsSync(msiPaths123beta.startMenuShortcut)).ok();
expect(fs.pathExistsSync(msiPaths123beta.desktopShortcut)).ok();
});
it(`installs (${testConfig.arch})`, async () => {
await install(msiPath, 2);
const version = getWindowsCompliantVersion(msiOptions.version);
expect(await checkInstall(msiOptions.name, version)).ok();
});

it(`has auto-launch registry key (${testConfig.arch})`, async () => {
autoLaunchRegistryKeyValue = await getRegistryKeyValue(msiPaths123beta.registryRunKey,
msiPaths123beta.appUserModelId);
expect(autoLaunchRegistryKeyValue).to.be(msiPaths123beta.stubExe);
});
it(`has all files in program files (${testConfig.arch})`, () => {
expect(fs.pathExistsSync(msiPaths123beta.stubExe)).ok();
expect(fs.pathExistsSync(msiPaths123beta.appFolder)).ok();
expectSameFolderContent(HARNESS_APP_DIR, msiPaths123beta.appFolder);
});

const entryPoints = [
{ name: 'stubExe', path: msiPaths123beta.stubExe },
{ name: 'start menu shortcut', path: msiPaths123beta.startMenuShortcut },
{ name: 'desktop shortcut', path: msiPaths123beta.desktopShortcut },
{ name: 'auto-launch key', path: autoLaunchRegistryKeyValue },
];

entryPoints.forEach(async (entryPoint) => {
it(`runs the correct binary via ${entryPoint.name}`, async () => {
await launch(msiPaths123beta.startMenuShortcut);
expect(await runs(msiOptions.exe)).ok();
expect(await getProcessPath(msiOptions.exe)).to.be(msiPaths123beta.appExe);
await kill(msiOptions.exe);
it(`has shortcuts (${testConfig.arch})`, () => {
expect(fs.pathExistsSync(msiPaths123beta.startMenuShortcut)).ok();
expect(fs.pathExistsSync(msiPaths123beta.desktopShortcut)).ok();
});

it(`has auto-launch registry key (${testConfig.arch})`, async () => {
autoLaunchRegistryKeyValue = await getRegistryKeyValue(msiPaths123beta.registryRunKey,
msiPaths123beta.appUserModelId);
expect(autoLaunchRegistryKeyValue).to.be(msiPaths123beta.stubExe);
});
});

it(`uninstalls (${testConfig.arch})`, async () => {
await uninstall(msiPath);
expect(await checkInstall(msiOptions.name)).not.ok();
expect(fs.pathExistsSync(msiPaths123beta.appRootFolder)).not.ok();
expect(fs.pathExistsSync(msiPaths123beta.startMenuShortcut)).not.ok();
expect(fs.pathExistsSync(msiPaths123beta.desktopShortcut)).not.ok();
const entryPoints = [
{ name: 'stubExe', path: msiPaths123beta.stubExe },
{ name: 'start menu shortcut', path: msiPaths123beta.startMenuShortcut },
{ name: 'desktop shortcut', path: msiPaths123beta.desktopShortcut },
{ name: 'auto-launch key', path: autoLaunchRegistryKeyValue },
];

entryPoints.forEach(async (entryPoint) => {
it(`runs the correct binary via ${entryPoint.name}`, async () => {
await launch(entryPoint.path);
expect(await runs(msiOptions.exe)).ok();
expect(await getProcessPath(msiOptions.exe)).to.be(msiPaths123beta.appExe);
await kill(msiOptions.exe);
});
});

it(`uninstalls (${testConfig.arch})`, async () => {
await uninstall(msiPath);
expect(await checkInstall(msiOptions.name)).not.ok();
expect(fs.pathExistsSync(msiPaths123beta.appRootFolder)).not.ok();
expect(fs.pathExistsSync(msiPaths123beta.startMenuShortcut)).not.ok();
expect(fs.pathExistsSync(msiPaths123beta.desktopShortcut)).not.ok();
});
});
});
});
178 changes: 92 additions & 86 deletions e2e/src/e2e-auto-updater.ts
Expand Up @@ -42,98 +42,104 @@ describe('MSI auto-updating', () => {
];

testConfigs.forEach((testConfig) => {
const msiOptions = {
...autoUpdateMsiOptions,
...testConfig
};

const squirrelOptions130Config = {
...squirrelOptions130,
...testConfig
};

const msiPaths123beta = getInstallPaths(msiOptions);
const squirrelPaths130 = getInstallPaths(squirrelOptions130Config);

console.log(msiPaths123beta);
console.log(squirrelPaths130);

it(`packages (${testConfig.arch})`, async () => {
await createMsiPackage(msiOptions);
cleanSquirrelOutDir();
await createSquirrelPackage(defaultSquirrelOptions);
await createSquirrelPackage(squirrelOptions130Config);
expect(fs.pathExistsSync(msiPath)).ok();
expect(fs.pathExistsSync(path.join(OUT_SQRL_DIR, 'RELEASES'))).ok();
expect(fs.pathExistsSync(path.join(OUT_SQRL_DIR, 'HelloWix-1.2.3-beta-full.nupkg'))).ok();
expect(fs.pathExistsSync(path.join(OUT_SQRL_DIR, 'HelloWix-1.3.0-full.nupkg'))).ok();
expect(fs.pathExistsSync(path.join(OUT_SQRL_DIR, 'HelloWix-1.3.0-delta.nupkg'))).ok();
expect(fs.pathExistsSync(path.join(OUT_SQRL_DIR, 'Setup.exe'))).ok();
});

const installConfigs = [
{ userGroup: undefined, effectiveUserGroup: 'Users' },
{ userGroup: 'Guests', effectiveUserGroup: 'Guests' },
];

installConfigs.forEach((config) => {
it(`installs (userGroup: ${config.effectiveUserGroup})`, async () => {
await install(msiPath, 3, config.userGroup);
const version = getWindowsCompliantVersion(msiOptions.version);
expect(await checkInstall(msiOptions.name, version)).ok();
});

it(`auto-updates (userGroup: ${config.effectiveUserGroup})`, async () => {
const server = serveSquirrel(OUT_SQRL_DIR);
await autoUpdate(msiPaths123beta.updateExe, server);
stopServingSquirrel();
});

it(`has all files in program files (userGroup: ${config.effectiveUserGroup})`, () => {
expect(fs.pathExistsSync(msiPaths123beta.stubExe)).ok();
expect(fs.pathExistsSync(squirrelPaths130.appFolder)).ok();
expectSameFolderContent(HARNESS_APP_DIR, squirrelPaths130.appFolder);
describe((`arch:${testConfig.arch}`), () => {
const msiOptions = {
...autoUpdateMsiOptions,
...testConfig
};

const squirrelOptions130Config = {
...squirrelOptions130,
...testConfig
};

const msiPaths123beta = getInstallPaths(msiOptions);
const squirrelPaths130 = getInstallPaths(squirrelOptions130Config);

it(`packages (${testConfig.arch})`, async () => {
await createMsiPackage(msiOptions);
cleanSquirrelOutDir();
await createSquirrelPackage(defaultSquirrelOptions);
await createSquirrelPackage(squirrelOptions130Config);
expect(fs.pathExistsSync(msiPath)).ok();
expect(fs.pathExistsSync(path.join(OUT_SQRL_DIR, 'RELEASES'))).ok();
expect(fs.pathExistsSync(path.join(OUT_SQRL_DIR, 'HelloWix-1.2.3-beta-full.nupkg'))).ok();
expect(fs.pathExistsSync(path.join(OUT_SQRL_DIR, 'HelloWix-1.3.0-full.nupkg'))).ok();
expect(fs.pathExistsSync(path.join(OUT_SQRL_DIR, 'HelloWix-1.3.0-delta.nupkg'))).ok();
expect(fs.pathExistsSync(path.join(OUT_SQRL_DIR, 'Setup.exe'))).ok();
});

it(`has access rights (userGroup: ${config.effectiveUserGroup})`, async () => {
const x = await hasAccessRights(squirrelPaths130.appRootFolder, config.effectiveUserGroup);
expect(x).ok();
});

it(`has called MsiSquirrel self-update (userGroup: ${config.effectiveUserGroup})`, () => {
const selfUpdateLog = path.join(squirrelPaths130.appFolder, 'SquirrelSetup.log');
expect(fs.pathExistsSync(selfUpdateLog)).ok();
const logContent = fs.readFileSync(selfUpdateLog, 'utf-8');
expect(logContent.includes('--updateSelf')).ok();
});

it(`has shortcuts (userGroup: ${config.effectiveUserGroup})`, () => {
expect(fs.pathExistsSync(msiPaths123beta.startMenuShortcut)).ok();
expect(fs.pathExistsSync(msiPaths123beta.desktopShortcut)).ok();
});

const entryPoints = [
{ name: 'stubExe', path: msiPaths123beta.stubExe },
{ name: 'start menu shortcut', path: msiPaths123beta.startMenuShortcut },
{ name: 'desktop shortcut', path: msiPaths123beta.desktopShortcut },
const installConfigs = [
{ userGroup: undefined, effectiveUserGroup: 'Users' },
{ userGroup: 'Guests', effectiveUserGroup: 'Guests' },
];

entryPoints.forEach(async (entryPoint) => {
it(`runs the correct binary via ${entryPoint.name}`, async () => {
await launch(entryPoint.path);
expect(await runs(msiOptions.exe)).ok();
expect(await getProcessPath(msiOptions.exe)).to.be(squirrelPaths130.appExe);
await kill(msiOptions.exe);
installConfigs.forEach((config) => {
describe((`userGroup:${config.effectiveUserGroup}`), () => {
after(() => {
// even if we failed, we still wanna leave behind a clean state for the next test
fs.rmdirSync(msiPaths123beta.appRootFolder, { recursive: true });
});

it(`installs (userGroup: ${config.effectiveUserGroup})`, async () => {
await install(msiPath, 3, config.userGroup);
const version = getWindowsCompliantVersion(msiOptions.version);
expect(await checkInstall(msiOptions.name, version)).ok();
});

it(`auto-updates (userGroup: ${config.effectiveUserGroup})`, async () => {
const server = serveSquirrel(OUT_SQRL_DIR);
await autoUpdate(msiPaths123beta.updateExe, server);
stopServingSquirrel();
});

it(`has all files in program files (userGroup: ${config.effectiveUserGroup})`, () => {
expect(fs.pathExistsSync(msiPaths123beta.stubExe)).ok();
expect(fs.pathExistsSync(squirrelPaths130.appFolder)).ok();
expectSameFolderContent(HARNESS_APP_DIR, squirrelPaths130.appFolder);
});

it(`has access rights (userGroup: ${config.effectiveUserGroup})`, async () => {
const x = await hasAccessRights(squirrelPaths130.appRootFolder, config.effectiveUserGroup);
expect(x).ok();
});

it(`has called MsiSquirrel self-update (userGroup: ${config.effectiveUserGroup})`, () => {
const selfUpdateLog = path.join(squirrelPaths130.appFolder, 'SquirrelSetup.log');
expect(fs.pathExistsSync(selfUpdateLog)).ok();
const logContent = fs.readFileSync(selfUpdateLog, 'utf-8');
expect(logContent.includes('--updateSelf')).ok();
});

it(`has shortcuts (userGroup: ${config.effectiveUserGroup})`, () => {
expect(fs.pathExistsSync(msiPaths123beta.startMenuShortcut)).ok();
expect(fs.pathExistsSync(msiPaths123beta.desktopShortcut)).ok();
});

const entryPoints = [
{ name: 'stubExe', path: msiPaths123beta.stubExe },
{ name: 'start menu shortcut', path: msiPaths123beta.startMenuShortcut },
{ name: 'desktop shortcut', path: msiPaths123beta.desktopShortcut },
];

entryPoints.forEach(async (entryPoint) => {
it(`runs the correct binary via ${entryPoint.name}`, async () => {
await launch(entryPoint.path);
expect(await runs(msiOptions.exe)).ok();
expect(await getProcessPath(msiOptions.exe)).to.be(squirrelPaths130.appExe);
await kill(msiOptions.exe);
});
});

it(`uninstalls (userGroup: ${config.effectiveUserGroup})`, async () => {
await uninstall(msiPath);
expect(await checkInstall(msiOptions.name)).not.ok();
expect(fs.pathExistsSync(msiPaths123beta.appRootFolder)).not.ok();
expect(fs.pathExistsSync(msiPaths123beta.startMenuShortcut)).not.ok();
expect(fs.pathExistsSync(msiPaths123beta.desktopShortcut)).not.ok();
});
});
});

it(`uninstalls (userGroup: ${config.effectiveUserGroup})`, async () => {
await uninstall(msiPath);
expect(await checkInstall(msiOptions.name)).not.ok();
expect(fs.pathExistsSync(msiPaths123beta.appRootFolder)).not.ok();
expect(fs.pathExistsSync(msiPaths123beta.startMenuShortcut)).not.ok();
expect(fs.pathExistsSync(msiPaths123beta.desktopShortcut)).not.ok();
});
});
});
});
6 changes: 5 additions & 1 deletion e2e/src/e2e-msi.ts
Expand Up @@ -143,7 +143,7 @@ describe('Electron WIX MSI', () => {

entryPoints.forEach((entryPoint) => {
it(`runs the correct binary via ${entryPoint.name}`, async () => {
await launch(paths124.startMenuShortcut);
await launch(entryPoint.name);
expect(await runs(options.exe)).ok();
expect(await getProcessPath(options.exe)).to.be(paths124.appExe);
await kill(options.exe);
Expand All @@ -152,6 +152,10 @@ describe('Electron WIX MSI', () => {
});

describe(`Uninstalling ${getTestConfigString()}`, () => {
after(() => {
// even if we failed, we still wanna leave behind a clean state for the next test
fs.rmdirSync(paths124.appRootFolder, { recursive: true });
});
it('uninstalls', async () => {
await uninstall(msiPath);
expect(await checkInstall(options.name)).not.ok();
Expand Down

0 comments on commit c18f0b2

Please sign in to comment.