mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-12-22 10:08:55 +00:00
Fix broken tests (#1523)
This commit is contained in:
parent
79009e87cd
commit
69625f1a01
1
.gitignore
vendored
1
.gitignore
vendored
@ -65,3 +65,4 @@ nativefier*.tgz
|
|||||||
.actrc
|
.actrc
|
||||||
|
|
||||||
tsconfig.tsbuildinfo
|
tsconfig.tsbuildinfo
|
||||||
|
scripts
|
||||||
|
@ -66,6 +66,9 @@ async function getDisplayMedia(
|
|||||||
sourceId: number | string,
|
sourceId: number | string,
|
||||||
): Promise<MediaStream> {
|
): Promise<MediaStream> {
|
||||||
type OriginalVideoPropertyType = boolean | MediaTrackConstraints | undefined;
|
type OriginalVideoPropertyType = boolean | MediaTrackConstraints | undefined;
|
||||||
|
if (!window?.navigator?.mediaDevices) {
|
||||||
|
throw Error('window.navigator.mediaDevices is not present');
|
||||||
|
}
|
||||||
// Electron supports an outdated specification for mediaDevices,
|
// Electron supports an outdated specification for mediaDevices,
|
||||||
// see https://www.electronjs.org/docs/latest/api/desktop-capturer/
|
// see https://www.electronjs.org/docs/latest/api/desktop-capturer/
|
||||||
const stream = await window.navigator.mediaDevices.getUserMedia({
|
const stream = await window.navigator.mediaDevices.getUserMedia({
|
||||||
@ -262,6 +265,9 @@ function setupScreenSharePicker(
|
|||||||
|
|
||||||
function setDisplayMediaPromise(): void {
|
function setDisplayMediaPromise(): void {
|
||||||
// Since no implementation for `getDisplayMedia` exists in Electron we write our own.
|
// Since no implementation for `getDisplayMedia` exists in Electron we write our own.
|
||||||
|
if (!window?.navigator?.mediaDevices) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
window.navigator.mediaDevices.getDisplayMedia = (): Promise<MediaStream> => {
|
window.navigator.mediaDevices.getDisplayMedia = (): Promise<MediaStream> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const sources = ipcRenderer.invoke(
|
const sources = ipcRenderer.invoke(
|
||||||
|
@ -18,7 +18,7 @@ type ElectronRelease = {
|
|||||||
files: string[];
|
files: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const ELECTRON_VERSIONS_URL = 'https://atom.io/download/atom-shell/index.json';
|
const ELECTRON_VERSIONS_URL = 'https://releases.electronjs.org/releases.json';
|
||||||
|
|
||||||
export async function getChromeVersionForElectronVersion(
|
export async function getChromeVersionForElectronVersion(
|
||||||
electronVersion: string,
|
electronVersion: string,
|
||||||
|
@ -26,7 +26,7 @@ async function checkApp(
|
|||||||
expect(
|
expect(
|
||||||
path.join(
|
path.join(
|
||||||
inputOptions.out,
|
inputOptions.out,
|
||||||
`Google-${inputOptions.platform as string}-${arch}`,
|
`npm-${inputOptions.platform as string}-${arch}`,
|
||||||
),
|
),
|
||||||
).toBe(appRoot);
|
).toBe(appRoot);
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ async function checkApp(
|
|||||||
let relativeResourcesDir = 'resources';
|
let relativeResourcesDir = 'resources';
|
||||||
|
|
||||||
if (inputOptions.platform === 'darwin') {
|
if (inputOptions.platform === 'darwin') {
|
||||||
relativeResourcesDir = path.join('Google.app', 'Contents', 'Resources');
|
relativeResourcesDir = path.join('npm.app', 'Contents', 'Resources');
|
||||||
}
|
}
|
||||||
|
|
||||||
const appPath = path.join(appRoot, relativeResourcesDir, 'app');
|
const appPath = path.join(appRoot, relativeResourcesDir, 'app');
|
||||||
@ -47,7 +47,7 @@ async function checkApp(
|
|||||||
expect(inputOptions.targetUrl).toBe(nativefierConfig?.targetUrl);
|
expect(inputOptions.targetUrl).toBe(nativefierConfig?.targetUrl);
|
||||||
|
|
||||||
// Test name inferring
|
// Test name inferring
|
||||||
expect(nativefierConfig?.name).toBe('Google');
|
expect(nativefierConfig?.name).toBe('npm');
|
||||||
|
|
||||||
// Test icon writing
|
// Test icon writing
|
||||||
const iconFile =
|
const iconFile =
|
||||||
@ -118,7 +118,7 @@ describe('Nativefier', () => {
|
|||||||
out: tempDirectory,
|
out: tempDirectory,
|
||||||
overwrite: true,
|
overwrite: true,
|
||||||
platform,
|
platform,
|
||||||
targetUrl: 'https://google.com/',
|
targetUrl: 'https://npmjs.com/',
|
||||||
};
|
};
|
||||||
const appPath = await buildNativefierApp(options);
|
const appPath = await buildNativefierApp(options);
|
||||||
expect(appPath).not.toBeUndefined();
|
expect(appPath).not.toBeUndefined();
|
||||||
@ -177,7 +177,7 @@ describe('Nativefier upgrade', () => {
|
|||||||
globalShortcuts: shortcuts,
|
globalShortcuts: shortcuts,
|
||||||
out: tempDirectory,
|
out: tempDirectory,
|
||||||
overwrite: true,
|
overwrite: true,
|
||||||
targetUrl: 'https://google.com/',
|
targetUrl: 'https://npmjs.com/',
|
||||||
...baseAppOptions,
|
...baseAppOptions,
|
||||||
};
|
};
|
||||||
const appPath = await buildNativefierApp(options);
|
const appPath = await buildNativefierApp(options);
|
||||||
|
@ -164,7 +164,7 @@ describe('Application launch', () => {
|
|||||||
);
|
);
|
||||||
expect(headerStyle.backgroundColor).toBe(fuschia);
|
expect(headerStyle.backgroundColor).toBe(fuschia);
|
||||||
|
|
||||||
await mainWindow.click('#nav-products-link');
|
await mainWindow.click('#nav-pricing-link');
|
||||||
await mainWindow.waitForLoadState('domcontentloaded');
|
await mainWindow.waitForLoadState('domcontentloaded');
|
||||||
const headerStylePostNavigate = await mainWindow.$eval('header', (el) =>
|
const headerStylePostNavigate = await mainWindow.$eval('header', (el) =>
|
||||||
window.getComputedStyle(el),
|
window.getComputedStyle(el),
|
||||||
@ -196,7 +196,7 @@ describe('Application launch', () => {
|
|||||||
test('can open internal links', async () => {
|
test('can open internal links', async () => {
|
||||||
const mainWindow = (await spawnApp()) as Page;
|
const mainWindow = (await spawnApp()) as Page;
|
||||||
await mainWindow.waitForLoadState('domcontentloaded');
|
await mainWindow.waitForLoadState('domcontentloaded');
|
||||||
await mainWindow.click('#nav-products-link');
|
await mainWindow.click('#nav-pricing-link');
|
||||||
await mainWindow.waitForLoadState('domcontentloaded');
|
await mainWindow.waitForLoadState('domcontentloaded');
|
||||||
expect(app.windows()).toHaveLength(1);
|
expect(app.windows()).toHaveLength(1);
|
||||||
});
|
});
|
||||||
@ -277,7 +277,7 @@ describe('Application launch', () => {
|
|||||||
await mainWindow.waitForLoadState('domcontentloaded');
|
await mainWindow.waitForLoadState('domcontentloaded');
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
mainWindow.click('#nav-products-link'),
|
mainWindow.click('#nav-pricing-link'),
|
||||||
mainWindow.waitForNavigation({ waitUntil: 'domcontentloaded' }),
|
mainWindow.waitForNavigation({ waitUntil: 'domcontentloaded' }),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user