Fix flaky test and add screenshots

This commit is contained in:
Fedor Indutny 2022-09-01 09:35:44 -07:00 committed by GitHub
parent 0ba23d4b62
commit 0715cc6be3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 41 additions and 31 deletions

View File

@ -42,7 +42,7 @@ jobs:
macos:
needs: lint
runs-on: macos-11
runs-on: macos-latest
if: github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
timeout-minutes: 30

View File

@ -550,8 +550,8 @@ function handleCommonWindowEvents(
}
}
const DEFAULT_WIDTH = 800;
const DEFAULT_HEIGHT = 610;
const DEFAULT_WIDTH = enableCI ? 1024 : 800;
const DEFAULT_HEIGHT = enableCI ? 1024 : 610;
// LARGEST_LEFT_PANE_WIDTH = 380
// TIMELINE_WIDTH = 300
// TIMELINE_MARGIN = 16 + 16

View File

@ -36,7 +36,7 @@
"test": "yarn test-node && yarn test-electron",
"test-electron": "node ts/scripts/test-electron.js",
"test-release": "node ts/scripts/test-release.js",
"test-node": "electron-mocha --file test/setup-test-node.js --recursive test/modules ts/test-node ts/test-both",
"test-node": "electron-mocha --timeout 10000 --file test/setup-test-node.js --recursive test/modules ts/test-node ts/test-both",
"test-mock": "mocha ts/test-mock/**/*_test.js",
"test-node-coverage": "nyc --reporter=lcov --reporter=text mocha --recursive test/modules ts/test-node ts/test-both",
"eslint": "eslint --cache .",

View File

@ -68,6 +68,8 @@
<script type="text/javascript">
window.Signal.conversationControllerStart();
mocha.setup({ timeout: 10000 });
window.testUtilities.prepareTests();
delete window.testUtilities.prepareTests;

View File

@ -99,7 +99,7 @@ const DELAY = 50; // milliseconds
await Promise.all([sendQueue(), measure()]);
} catch (error) {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
throw error;
} finally {
await app?.close();

View File

@ -182,7 +182,7 @@ const LAST_MESSAGE = 'start sending messages now';
console.log('stats info=%j', { delta: stats(deltaList, [99, 99.8]) });
} catch (error) {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
throw error;
} finally {
await app?.close();

View File

@ -132,7 +132,7 @@ const LAST_MESSAGE = 'start sending messages now';
console.log('stats info=%j', { delta: stats(deltaList, [99, 99.8]) });
} catch (error) {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
throw error;
} finally {
await app?.close();

View File

@ -60,7 +60,7 @@ const CONTACT_COUNT = 1000;
const duration = Date.now() - start;
console.log(`Took: ${(duration / 1000).toFixed(2)} seconds`);
} catch (error) {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
throw error;
} finally {
await app?.close();

View File

@ -256,7 +256,7 @@ export class Bootstrap {
return result;
}
public async saveLogs(): Promise<void> {
public async saveLogs(app?: App): Promise<void> {
const { ARTIFACTS_DIR } = process.env;
if (!ARTIFACTS_DIR) {
// eslint-disable-next-line no-console
@ -272,7 +272,13 @@ export class Bootstrap {
console.error(`Saving logs to ${outDir}`);
const { logsDir } = this;
await fs.rename(logsDir, path.join(outDir));
await fs.rename(logsDir, outDir);
if (app) {
const window = await app.getWindow();
const screenshot = await window.screenshot();
await fs.writeFile(path.join(outDir, 'screenshot.png'), screenshot);
}
}
//

View File

@ -62,7 +62,7 @@ describe('gv2', function needsName() {
afterEach(async function after() {
if (this.currentTest?.state !== 'passed') {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
}
await app.close();
@ -172,28 +172,33 @@ describe('gv2', function needsName() {
const window = await app.getWindow();
debug('Sending another invite');
debug('Waiting for the PNI invite');
await window
.locator(`text=${first.profileName} invited you to the group.`)
.waitFor();
// Invite ACI from another contact
debug('Inviting ACI from another contact');
group = await second.inviteToGroup(group, desktop, {
uuidKind: UUIDKind.ACI,
});
const conversationStack = window.locator('.conversation-stack');
debug('Waiting for the ACI invite');
await window
.locator(`text=${second.profileName} invited you to the group.`)
.waitFor();
debug('Accepting');
await conversationStack
.locator('.module-message-request-actions button >> "Accept"')
.click();
debug('Verifying notifications');
await window
.locator(`"${first.profileName} invited you to the group."`)
.waitFor();
await window.locator('"You were invited to the group."').waitFor();
debug('Checking final notification');
await window
.locator(
`"You accepted an invitation to the group from ${second.profileName}."`
'text=You accepted an invitation to the group from ' +
`${second.profileName}.`
)
.waitFor();

View File

@ -24,7 +24,7 @@ describe('PNP change number', function needsName() {
afterEach(async function after() {
if (this.currentTest?.state !== 'passed') {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
}
await app.close();

View File

@ -92,7 +92,7 @@ describe('PNI Signature', function needsName() {
afterEach(async function after() {
if (this.currentTest?.state !== 'passed') {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
}
await app.close();

View File

@ -84,7 +84,7 @@ describe('gv2', function needsName() {
afterEach(async function after() {
if (this.currentTest?.state !== 'passed') {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
}
await app.close();

View File

@ -23,7 +23,7 @@ describe('storage service', function needsName() {
}
if (this.currentTest?.state !== 'passed') {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
}
await app.close();

View File

@ -26,7 +26,7 @@ describe('storage service', function needsName() {
}
if (this.currentTest?.state !== 'passed') {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
}
await app.close();

View File

@ -28,7 +28,7 @@ describe('storage service', function needsName() {
}
if (this.currentTest?.state !== 'passed') {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
}
await app.close();

View File

@ -23,7 +23,7 @@ describe('storage service', function needsName() {
}
if (this.currentTest?.state !== 'passed') {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
}
await app.close();

View File

@ -27,7 +27,7 @@ describe('storage service', function needsName() {
}
if (this.currentTest?.state !== 'passed') {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
}
await app.close();

View File

@ -100,7 +100,7 @@ describe('storage service', function needsName() {
}
if (this.currentTest?.state !== 'passed') {
await bootstrap.saveLogs();
await bootstrap.saveLogs(app);
}
await app.close();

View File

@ -14,9 +14,6 @@ import {
describe('license comments', () => {
it('includes a license comment at the top of every relevant file', async function test() {
// This usually executes quickly but can be slow in some cases, such as Windows CI.
this.timeout(10000);
await forEachRelevantFile(async file => {
let firstLine: string;
let secondLine: string;