1
0
mirror of https://github.com/jiahaog/Nativefier synced 2024-06-25 07:37:41 +02:00
Nativefier/src/integration-test.ts
Ronan Jouchet 74a7d3375d App: revert addition of extra flag --internal-login-pages
See discussion at https://github.com/nativefier/nativefier/pull/1124#issuecomment-794751514 :

> @TheCleric I was about to merge this, then reconsidered one little thing (yes I wrote "little", I'm not reconsidering this whole thing 😅).
>
> I'm re-considering having the extra flag. I'm not so sure this will harm a lot of use cases. I'd like to 1. merge this PR, 2. immediately follow up with a small commit removing the flag & adjusting api.md, 3. release with the change well-documented / asking for feedback if this is problematic to anyone. (I'm not asking you any extra work, and like leaving an in-tree commit trace of considering the flag). If people complain with a valid reason, we'll restore the flag with a quick revert, else we're happy with one less flag and a reasonably-handled breaking change.
>
> Thoughts / objections?

Answered by:

> That seems reasonable to me.
>
> [discussion on an extra structured way to pass flags]
2021-03-10 19:36:20 -05:00

59 lines
1.6 KiB
TypeScript

import * as fs from 'fs';
import * as path from 'path';
import { getTempDir } from './helpers/helpers';
import { buildNativefierApp } from './main';
function checkApp(appRoot: string, inputOptions: any): void {
let relativeAppFolder: string;
switch (inputOptions.platform) {
case 'darwin':
relativeAppFolder = path.join('Google.app', 'Contents/Resources/app');
break;
case 'linux':
relativeAppFolder = 'resources/app';
break;
case 'win32':
relativeAppFolder = 'resources/app';
break;
default:
throw new Error('Unknown app platform');
}
const appPath = path.join(appRoot, relativeAppFolder);
const configPath = path.join(appPath, 'nativefier.json');
const nativefierConfig = JSON.parse(fs.readFileSync(configPath).toString());
expect(inputOptions.targetUrl).toBe(nativefierConfig.targetUrl);
// Test name inferring
expect(nativefierConfig.name).toBe('Google');
// Test icon writing
const iconFile =
inputOptions.platform === 'darwin' ? '../electron.icns' : 'icon.png';
const iconPath = path.join(appPath, iconFile);
expect(fs.existsSync(iconPath)).toBe(true);
expect(fs.statSync(iconPath).size).toBeGreaterThan(1000);
}
describe('Nativefier', () => {
jest.setTimeout(300000);
test.each(['darwin', 'linux'])(
'builds a Nativefier app for platform %s',
async (platform) => {
const tempDirectory = getTempDir('integtest');
const options = {
targetUrl: 'https://google.com/',
out: tempDirectory,
overwrite: true,
platform,
};
const appPath = await buildNativefierApp(options);
checkApp(appPath, options);
},
);
});