Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase timeout for fuzz testing #3818

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ on:
jobs:
unit:
uses: ./.github/workflows/_unit.yml
fuzz:
uses: ./.github/workflows/_fuzz.yml
e2e:
uses: ./.github/workflows/_e2e.yml
6 changes: 6 additions & 0 deletions _develop/karma.fuzz.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@ module.exports = config => {
frameworks: ['jasmine'],
reporters: ['progress'],
browsers: ['jsdom'],
singleRun: true,
browserNoActivityTimeout: 120000,
browserDisconnectTimeout: 120000,
browserDisconnectTolerance: 3,
browserSocketTimeout: 120000,
captureTimeout: 120000,
});
};
10 changes: 5 additions & 5 deletions test/fuzz/editor.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Delta, { AttributeMap, Op } from 'quill-delta';
import { choose, randomInt } from './utils';
import { choose, randomInt, runFuzz } from './utils';
import { AlignClass } from '../../formats/align';
import { FontClass } from '../../formats/font';
import { SizeClass } from '../../formats/size';
Expand Down Expand Up @@ -214,18 +214,18 @@ const generateChange = (doc: Delta, changeCount: number) => {

describe('editor', () => {
it('setContents()', () => {
for (let i = 0; i < 2000; i += 1) {
runFuzz(() => {
const quill = new Quill(document.createElement('div'));
const delta = generateDocument();

expect(delta.concat(new Delta().delete(1))).toEqual(
quill.setContents(delta),
);
}
});
});

it('updateContents()', () => {
for (let i = 0; i < 100; i += 1) {
runFuzz(() => {
const quill = new Quill(document.createElement('div'));
const delta = generateDocument();
quill.setContents(delta);
Expand All @@ -236,6 +236,6 @@ describe('editor', () => {
const diff = quill.updateContents(change);
expect(change).toEqual(diff);
}
}
});
});
});
7 changes: 7 additions & 0 deletions test/fuzz/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ export function randomInt(max: number) {
export function choose<T>(choices: T[]): T {
return choices[randomInt(choices.length)];
}

export function runFuzz(testCase: () => void) {
const start = performance.now();
do {
testCase();
} while (performance.now() - start > 30 * 1000);
}