Skip to content

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

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

Merged
merged 1 commit into from
May 2, 2019
Merged
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
112 changes: 49 additions & 63 deletions spec/ParseInstallation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 installId2 = '22222222-abcd-abcd-abcd-123456789abc';
const t =
'0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';

let input = {
installationId: installId1,
deviceToken: t,
deviceType: 'android',
};
let firstObject;
let secondObject;
rest
.create(config, auth.nobody(config), '_Installation', input)
.then(() => {
input = {
installationId: installId2,
deviceType: 'android',
};
return rest.create(config, auth.nobody(config), '_Installation', input);
})
.then(() =>
database.adapter.find(
'_Installation',
installationSchema,
{ installationId: installId1 },
{}
)
)
.then(results => {
firstObject = results[0];
expect(results.length).toEqual(1);
return database.adapter.find(
'_Installation',
installationSchema,
{ installationId: installId2 },
{}
);
})
.then(results => {
expect(results.length).toEqual(1);
secondObject = results[0];
// Update second installation to conflict with first installation
input = {
objectId: secondObject.objectId,
deviceToken: t,
};
return rest.update(
config,
auth.nobody(config),
'_Installation',
{ objectId: secondObject.objectId },
input
);
})
.then(() =>
database.adapter.find(
'_Installation',
installationSchema,
{ objectId: firstObject.objectId },
{}
)
)
.then(results => {
// The first object should have been deleted
expect(results.length).toEqual(0);
done();
})
.catch(error => {
jfail(error);
done();
});
await rest.create(config, auth.nobody(config), '_Installation', input);

input = {
installationId: installId2,
deviceType: 'android',
};
await rest.create(config, auth.nobody(config), '_Installation', input);
await delay(100);

let results = await database.adapter.find(
'_Installation',
installationSchema,
{ installationId: installId1 },
{}
);
expect(results.length).toEqual(1);
const firstObject = results[0];

results = await database.adapter.find(
'_Installation',
installationSchema,
{ installationId: installId2 },
{}
);
expect(results.length).toEqual(1);
const secondObject = results[0];

// Update second installation to conflict with first installation
input = {
objectId: secondObject.objectId,
deviceToken: t,
};
await rest.update(
config,
auth.nobody(config),
'_Installation',
{ objectId: secondObject.objectId },
input
);
await delay(100);
results = await database.adapter.find(
'_Installation',
installationSchema,
{ objectId: firstObject.objectId },
{}
);
expect(results.length).toEqual(0);
});

it('update ios device token with duplicate device token', done => {
Expand Down