test: drop now-empty remote runner (#35343)
* test: drop the now-empty remote runner from CI * move fixtures to spec-main * remove remote runner * fix stuff * remove global-paths hack * move ts-smoke to spec/ * fix test after merge * rename spec-main to spec * no need to ignore spec/node_modules twice * simplify spec-runner a little * no need to hash pj/yl twice * undo lint change to verify-mksnapshot.py * excessive .. * update electron_woa_testing.yml * don't search for test-results-remote.xml it is never produced now
This commit is contained in:
parent
e87c4015fe
commit
db7c92fd57
327 changed files with 950 additions and 1707 deletions
211
spec/api-dialog-spec.ts
Normal file
211
spec/api-dialog-spec.ts
Normal file
|
@ -0,0 +1,211 @@
|
|||
import { expect } from 'chai';
|
||||
import { dialog, BrowserWindow } from 'electron/main';
|
||||
import { closeAllWindows } from './window-helpers';
|
||||
import { ifit, delay } from './spec-helpers';
|
||||
|
||||
describe('dialog module', () => {
|
||||
describe('showOpenDialog', () => {
|
||||
afterEach(closeAllWindows);
|
||||
ifit(process.platform !== 'win32')('should not throw for valid cases', () => {
|
||||
expect(() => {
|
||||
dialog.showOpenDialog({ title: 'i am title' });
|
||||
}).to.not.throw();
|
||||
|
||||
expect(() => {
|
||||
const w = new BrowserWindow();
|
||||
dialog.showOpenDialog(w, { title: 'i am title' });
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
||||
it('throws errors when the options are invalid', () => {
|
||||
expect(() => {
|
||||
dialog.showOpenDialog({ properties: false as any });
|
||||
}).to.throw(/Properties must be an array/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showOpenDialog({ title: 300 as any });
|
||||
}).to.throw(/Title must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showOpenDialog({ buttonLabel: [] as any });
|
||||
}).to.throw(/Button label must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showOpenDialog({ defaultPath: {} as any });
|
||||
}).to.throw(/Default path must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showOpenDialog({ message: {} as any });
|
||||
}).to.throw(/Message must be a string/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showSaveDialog', () => {
|
||||
afterEach(closeAllWindows);
|
||||
ifit(process.platform !== 'win32')('should not throw for valid cases', () => {
|
||||
expect(() => {
|
||||
dialog.showSaveDialog({ title: 'i am title' });
|
||||
}).to.not.throw();
|
||||
|
||||
expect(() => {
|
||||
const w = new BrowserWindow();
|
||||
dialog.showSaveDialog(w, { title: 'i am title' });
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
||||
it('throws errors when the options are invalid', () => {
|
||||
expect(() => {
|
||||
dialog.showSaveDialog({ title: 300 as any });
|
||||
}).to.throw(/Title must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showSaveDialog({ buttonLabel: [] as any });
|
||||
}).to.throw(/Button label must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showSaveDialog({ defaultPath: {} as any });
|
||||
}).to.throw(/Default path must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showSaveDialog({ message: {} as any });
|
||||
}).to.throw(/Message must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showSaveDialog({ nameFieldLabel: {} as any });
|
||||
}).to.throw(/Name field label must be a string/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showMessageBox', () => {
|
||||
afterEach(closeAllWindows);
|
||||
|
||||
// parentless message boxes are synchronous on macOS
|
||||
// dangling message boxes on windows cause a DCHECK: https://cs.chromium.org/chromium/src/base/win/message_window.cc?l=68&rcl=7faa4bf236a866d007dc5672c9ce42660e67a6a6
|
||||
ifit(process.platform !== 'darwin' && process.platform !== 'win32')('should not throw for a parentless message box', () => {
|
||||
expect(() => {
|
||||
dialog.showMessageBox({ message: 'i am message' });
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
||||
ifit(process.platform !== 'win32')('should not throw for valid cases', () => {
|
||||
expect(() => {
|
||||
const w = new BrowserWindow();
|
||||
dialog.showMessageBox(w, { message: 'i am message' });
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
||||
it('throws errors when the options are invalid', () => {
|
||||
expect(() => {
|
||||
dialog.showMessageBox(undefined as any, { type: 'not-a-valid-type', message: '' });
|
||||
}).to.throw(/Invalid message box type/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showMessageBox(null as any, { buttons: false as any, message: '' });
|
||||
}).to.throw(/Buttons must be an array/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showMessageBox({ title: 300 as any, message: '' });
|
||||
}).to.throw(/Title must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showMessageBox({ message: [] as any });
|
||||
}).to.throw(/Message must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showMessageBox({ detail: 3.14 as any, message: '' });
|
||||
}).to.throw(/Detail must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showMessageBox({ checkboxLabel: false as any, message: '' });
|
||||
}).to.throw(/checkboxLabel must be a string/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showMessageBox with signal', () => {
|
||||
afterEach(closeAllWindows);
|
||||
|
||||
it('closes message box immediately', async () => {
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
const w = new BrowserWindow();
|
||||
const p = dialog.showMessageBox(w, { signal, message: 'i am message' });
|
||||
controller.abort();
|
||||
const result = await p;
|
||||
expect(result.response).to.equal(0);
|
||||
});
|
||||
|
||||
it('closes message box after a while', async () => {
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
const w = new BrowserWindow();
|
||||
const p = dialog.showMessageBox(w, { signal, message: 'i am message' });
|
||||
await delay(500);
|
||||
controller.abort();
|
||||
const result = await p;
|
||||
expect(result.response).to.equal(0);
|
||||
});
|
||||
|
||||
it('cancels message box', async () => {
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
const w = new BrowserWindow();
|
||||
const p = dialog.showMessageBox(w, {
|
||||
signal,
|
||||
message: 'i am message',
|
||||
buttons: ['OK', 'Cancel'],
|
||||
cancelId: 1
|
||||
});
|
||||
controller.abort();
|
||||
const result = await p;
|
||||
expect(result.response).to.equal(1);
|
||||
});
|
||||
|
||||
it('cancels message box after a while', async () => {
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
const w = new BrowserWindow();
|
||||
const p = dialog.showMessageBox(w, {
|
||||
signal,
|
||||
message: 'i am message',
|
||||
buttons: ['OK', 'Cancel'],
|
||||
cancelId: 1
|
||||
});
|
||||
await delay(500);
|
||||
controller.abort();
|
||||
const result = await p;
|
||||
expect(result.response).to.equal(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showErrorBox', () => {
|
||||
it('throws errors when the options are invalid', () => {
|
||||
expect(() => {
|
||||
(dialog.showErrorBox as any)();
|
||||
}).to.throw(/Insufficient number of arguments/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showErrorBox(3 as any, 'four');
|
||||
}).to.throw(/Error processing argument at index 0/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showErrorBox('three', 4 as any);
|
||||
}).to.throw(/Error processing argument at index 1/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showCertificateTrustDialog', () => {
|
||||
it('throws errors when the options are invalid', () => {
|
||||
expect(() => {
|
||||
(dialog.showCertificateTrustDialog as any)();
|
||||
}).to.throw(/options must be an object/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showCertificateTrustDialog({} as any);
|
||||
}).to.throw(/certificate must be an object/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showCertificateTrustDialog({ certificate: {} as any, message: false as any });
|
||||
}).to.throw(/message must be a string/);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue