Skip to content

Commit

Permalink
test: Fix EventuallyQueue flaky tests (#2108)
Browse files Browse the repository at this point in the history
  • Loading branch information
dplewis authored Apr 13, 2024
1 parent a7b2fa0 commit fe29e6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
33 changes: 5 additions & 28 deletions integration/test/ParseEventuallyQueueTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,15 @@ describe('Parse EventuallyQueue', () => {
const object = new TestObject({ hash: 'saveSecret' });
await new Promise((resolve) => parseServer.server.close(resolve));
await object.saveEventually();
let length = await Parse.EventuallyQueue.length();

const length = await Parse.EventuallyQueue.length();
assert(Parse.EventuallyQueue.isPolling());
assert.strictEqual(length, 1);

await reconfigureServer({});
while (Parse.EventuallyQueue.isPolling()) {
await sleep(100);
}
assert.strictEqual(Parse.EventuallyQueue.isPolling(), false);

while (await Parse.EventuallyQueue.length()) {
await sleep(100);
}
length = await Parse.EventuallyQueue.length();
assert.strictEqual(length, 0);

const query = new Parse.Query(TestObject);
query.equalTo('hash', 'saveSecret');
let results = await query.find();
Expand All @@ -233,10 +226,9 @@ describe('Parse EventuallyQueue', () => {
object.setACL(acl);

await new Promise((resolve) => parseServer.server.close(resolve));

await object.saveEventually();

let length = await Parse.EventuallyQueue.length();
const length = await Parse.EventuallyQueue.length();
assert(Parse.EventuallyQueue.isPolling());
assert.strictEqual(length, 1);

Expand All @@ -245,15 +237,6 @@ describe('Parse EventuallyQueue', () => {
while (Parse.EventuallyQueue.isPolling()) {
await sleep(100);
}
assert.strictEqual(Parse.EventuallyQueue.isPolling(), false);

length = await Parse.EventuallyQueue.length();
while (length) {
await sleep(100);
}
length = await Parse.EventuallyQueue.length();
assert.strictEqual(length, 0);

const query = new Parse.Query('TestObject');
query.equalTo('hash', 'saveSecret');
let results = await query.find();
Expand All @@ -269,21 +252,15 @@ describe('Parse EventuallyQueue', () => {
await object.save();
await new Promise((resolve) => parseServer.server.close(resolve));
await object.destroyEventually();
let length = await Parse.EventuallyQueue.length();
const length = await Parse.EventuallyQueue.length();

assert(Parse.EventuallyQueue.isPolling());
assert.strictEqual(length, 1);

await reconfigureServer({});
while (Parse.EventuallyQueue.isPolling()) {
await sleep(100);
}
assert.strictEqual(Parse.EventuallyQueue.isPolling(), false);
while (await Parse.EventuallyQueue.length()) {
await sleep(100);
}
length = await Parse.EventuallyQueue.length();
assert.strictEqual(length, 0);

const query = new Parse.Query(TestObject);
query.equalTo('hash', 'deleteSecret');
let results = await query.find();
Expand Down
1 change: 1 addition & 0 deletions integration/test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const defaultConfiguration = {
revokeSessionOnPasswordReset: false,
allowCustomObjectId: false,
allowClientClassCreation: true,
encodeParseObjectInCloudFunction: true,
emailAdapter: MockEmailAdapterWithOptions({
fromAddress: '[email protected]',
apiKey: 'k',
Expand Down

0 comments on commit fe29e6e

Please sign in to comment.