Fix flaky test. Give em a little more time. (#5557)

Similar to https://github.com/parse-community/parse-server/pull/3453
This commit is contained in:
Diamond Lewis
2019-05-02 13:59:01 -05:00
committed by GitHub
parent 005fd78275
commit e0a25d9030

View File

@@ -674,78 +674,64 @@ describe('Installations', () => {
}); });
}); });
it('update android device token with duplicate device token', done => { it('update android device token with duplicate device token', async () => {
const installId1 = '11111111-abcd-abcd-abcd-123456789abc'; const installId1 = '11111111-abcd-abcd-abcd-123456789abc';
const installId2 = '22222222-abcd-abcd-abcd-123456789abc'; const installId2 = '22222222-abcd-abcd-abcd-123456789abc';
const t = const t =
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'; '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
let input = { let input = {
installationId: installId1, installationId: installId1,
deviceToken: t, deviceToken: t,
deviceType: 'android', deviceType: 'android',
}; };
let firstObject; await rest.create(config, auth.nobody(config), '_Installation', input);
let secondObject;
rest
.create(config, auth.nobody(config), '_Installation', input)
.then(() => {
input = { input = {
installationId: installId2, installationId: installId2,
deviceType: 'android', deviceType: 'android',
}; };
return rest.create(config, auth.nobody(config), '_Installation', input); await rest.create(config, auth.nobody(config), '_Installation', input);
}) await delay(100);
.then(() =>
database.adapter.find( let results = await database.adapter.find(
'_Installation', '_Installation',
installationSchema, installationSchema,
{ installationId: installId1 }, { installationId: installId1 },
{} {}
) );
)
.then(results => {
firstObject = results[0];
expect(results.length).toEqual(1); expect(results.length).toEqual(1);
return database.adapter.find( const firstObject = results[0];
results = await database.adapter.find(
'_Installation', '_Installation',
installationSchema, installationSchema,
{ installationId: installId2 }, { installationId: installId2 },
{} {}
); );
})
.then(results => {
expect(results.length).toEqual(1); expect(results.length).toEqual(1);
secondObject = results[0]; const secondObject = results[0];
// Update second installation to conflict with first installation // Update second installation to conflict with first installation
input = { input = {
objectId: secondObject.objectId, objectId: secondObject.objectId,
deviceToken: t, deviceToken: t,
}; };
return rest.update( await rest.update(
config, config,
auth.nobody(config), auth.nobody(config),
'_Installation', '_Installation',
{ objectId: secondObject.objectId }, { objectId: secondObject.objectId },
input input
); );
}) await delay(100);
.then(() => results = await database.adapter.find(
database.adapter.find(
'_Installation', '_Installation',
installationSchema, installationSchema,
{ objectId: firstObject.objectId }, { objectId: firstObject.objectId },
{} {}
) );
)
.then(results => {
// The first object should have been deleted
expect(results.length).toEqual(0); expect(results.length).toEqual(0);
done();
})
.catch(error => {
jfail(error);
done();
});
}); });
it('update ios device token with duplicate device token', done => { it('update ios device token with duplicate device token', done => {