2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-12-22 01:58:54 +00:00

Fix broken tests (#1523)

This commit is contained in:
Adam Weeden 2023-03-24 14:16:49 -04:00 committed by GitHub
parent 79009e87cd
commit 69625f1a01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 9 deletions

1
.gitignore vendored
View File

@ -65,3 +65,4 @@ nativefier*.tgz
.actrc
tsconfig.tsbuildinfo
scripts

View File

@ -66,6 +66,9 @@ async function getDisplayMedia(
sourceId: number | string,
): Promise<MediaStream> {
type OriginalVideoPropertyType = boolean | MediaTrackConstraints | undefined;
if (!window?.navigator?.mediaDevices) {
throw Error('window.navigator.mediaDevices is not present');
}
// Electron supports an outdated specification for mediaDevices,
// see https://www.electronjs.org/docs/latest/api/desktop-capturer/
const stream = await window.navigator.mediaDevices.getUserMedia({
@ -262,6 +265,9 @@ function setupScreenSharePicker(
function setDisplayMediaPromise(): void {
// Since no implementation for `getDisplayMedia` exists in Electron we write our own.
if (!window?.navigator?.mediaDevices) {
return;
}
window.navigator.mediaDevices.getDisplayMedia = (): Promise<MediaStream> => {
return new Promise((resolve, reject) => {
const sources = ipcRenderer.invoke(

View File

@ -18,7 +18,7 @@ type ElectronRelease = {
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(
electronVersion: string,

View File

@ -26,7 +26,7 @@ async function checkApp(
expect(
path.join(
inputOptions.out,
`Google-${inputOptions.platform as string}-${arch}`,
`npm-${inputOptions.platform as string}-${arch}`,
),
).toBe(appRoot);
}
@ -34,7 +34,7 @@ async function checkApp(
let relativeResourcesDir = 'resources';
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');
@ -47,7 +47,7 @@ async function checkApp(
expect(inputOptions.targetUrl).toBe(nativefierConfig?.targetUrl);
// Test name inferring
expect(nativefierConfig?.name).toBe('Google');
expect(nativefierConfig?.name).toBe('npm');
// Test icon writing
const iconFile =
@ -118,7 +118,7 @@ describe('Nativefier', () => {
out: tempDirectory,
overwrite: true,
platform,
targetUrl: 'https://google.com/',
targetUrl: 'https://npmjs.com/',
};
const appPath = await buildNativefierApp(options);
expect(appPath).not.toBeUndefined();
@ -177,7 +177,7 @@ describe('Nativefier upgrade', () => {
globalShortcuts: shortcuts,
out: tempDirectory,
overwrite: true,
targetUrl: 'https://google.com/',
targetUrl: 'https://npmjs.com/',
...baseAppOptions,
};
const appPath = await buildNativefierApp(options);

View File

@ -164,7 +164,7 @@ describe('Application launch', () => {
);
expect(headerStyle.backgroundColor).toBe(fuschia);
await mainWindow.click('#nav-products-link');
await mainWindow.click('#nav-pricing-link');
await mainWindow.waitForLoadState('domcontentloaded');
const headerStylePostNavigate = await mainWindow.$eval('header', (el) =>
window.getComputedStyle(el),
@ -196,7 +196,7 @@ describe('Application launch', () => {
test('can open internal links', async () => {
const mainWindow = (await spawnApp()) as Page;
await mainWindow.waitForLoadState('domcontentloaded');
await mainWindow.click('#nav-products-link');
await mainWindow.click('#nav-pricing-link');
await mainWindow.waitForLoadState('domcontentloaded');
expect(app.windows()).toHaveLength(1);
});
@ -277,7 +277,7 @@ describe('Application launch', () => {
await mainWindow.waitForLoadState('domcontentloaded');
await Promise.all([
mainWindow.click('#nav-products-link'),
mainWindow.click('#nav-pricing-link'),
mainWindow.waitForNavigation({ waitUntil: 'domcontentloaded' }),
]);