Skip to content

Commit

Permalink
Improve comments and get rid of unused features
Browse files Browse the repository at this point in the history
  • Loading branch information
stocaaro committed Dec 20, 2023
1 parent 0cf49ce commit 1f7415f
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 116 deletions.
94 changes: 47 additions & 47 deletions packages/datastore/__tests__/conflictResolutionBehavior.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('DataStore sync engine', () => {
describe('observed rapid single-field mutations with variable connection latencies', () => {
describe('single client updates', () => {
test('rapid mutations on poor connection when initial create is not pending', async () => {
harness.connectionSpeed = 'slow';
harness.userInputLatency = 'fasterThanOutbox';
harness.latency = 'high';
const postHarness = await harness.createPostHarness({
title: 'original title',
Expand All @@ -89,13 +89,13 @@ describe('DataStore sync engine', () => {
['post title 0', 3],
]);

postHarness.expectCurrentToMatch({
version: 3,
expect(await postHarness.currentContents).toMatchObject({
_version: 3,
title: 'post title 0',
});
});
test('rapid mutations on fast connection when initial create is not pending', async () => {
harness.connectionSpeed = 'fast';
harness.userInputLatency = 'slowerThanOutbox';
harness.latency = 'low';
const postHarness = await harness.createPostHarness({
title: 'original title',
Expand All @@ -120,13 +120,13 @@ describe('DataStore sync engine', () => {
['post title 0', 4],
]);

postHarness.expectCurrentToMatch({
version: 4,
expect(await postHarness.currentContents).toMatchObject({
_version: 4,
title: 'post title 0',
});
});
test('rapid mutations on poor connection when initial create is pending', async () => {
harness.connectionSpeed = 'slow';
harness.userInputLatency = 'fasterThanOutbox';
harness.latency = 'high';
const postHarness = await harness.createPostHarness({
title: 'original title',
Expand All @@ -149,13 +149,13 @@ describe('DataStore sync engine', () => {
['post title 2', 1],
]);

postHarness.expectCurrentToMatch({
version: 1,
expect(await postHarness.currentContents).toMatchObject({
_version: 1,
title: 'post title 2',
});
});
test('rapid mutations on fast connection when initial create is pending', async () => {
harness.connectionSpeed = 'fast';
harness.userInputLatency = 'slowerThanOutbox';
harness.latency = 'low';
const postHarness = await harness.createPostHarness({
title: 'original title',
Expand All @@ -178,13 +178,13 @@ describe('DataStore sync engine', () => {
['post title 2', 1],
]);

postHarness.expectCurrentToMatch({
version: 1,
expect(await postHarness.currentContents).toMatchObject({
_version: 1,
title: 'post title 2',
});
});
test('observe on poor connection with awaited outbox', async () => {
harness.connectionSpeed = 'slow';
harness.userInputLatency = 'fasterThanOutbox';
harness.latency = 'high';
const postHarness = await harness.createPostHarness({
title: 'original title',
Expand Down Expand Up @@ -217,8 +217,8 @@ describe('DataStore sync engine', () => {
['post title 2', 4],
]);

postHarness.expectCurrentToMatch({
version: 4,
expect(await postHarness.currentContents).toMatchObject({
_version: 4,
title: 'post title 2',
});
});
Expand Down Expand Up @@ -249,8 +249,8 @@ describe('DataStore sync engine', () => {
['post title 2', 4],
]);

postHarness.expectCurrentToMatch({
version: 4,
expect(await postHarness.currentContents).toMatchObject({
_version: 4,
title: 'post title 2',
});
});
Expand All @@ -266,7 +266,7 @@ describe('DataStore sync engine', () => {
describe('Multi-client updates', () => {
describe('Updates to the same field', () => {
test('rapid mutations on poor connection when initial create is not pending', async () => {
harness.connectionSpeed = 'slow';
harness.userInputLatency = 'fasterThanOutbox';
harness.latency = 'high';
const postHarness = await harness.createPostHarness({
title: 'original title',
Expand All @@ -293,13 +293,13 @@ describe('DataStore sync engine', () => {
['update from second client', 4],
]);

postHarness.expectCurrentToMatch({
version: 4,
expect(await postHarness.currentContents).toMatchObject({
_version: 4,
title: 'update from second client',
});
});
test('rapid mutations on fast connection when initial create is not pending', async () => {
harness.connectionSpeed = 'fast';
harness.userInputLatency = 'slowerThanOutbox';
harness.latency = 'low';
const postHarness = await harness.createPostHarness({
title: 'original title',
Expand Down Expand Up @@ -327,13 +327,13 @@ describe('DataStore sync engine', () => {
['post title 0', 5],
]);

postHarness.expectCurrentToMatch({
version: 5,
expect(await postHarness.currentContents).toMatchObject({
_version: 5,
title: 'post title 0',
});
});
test('observe on poor connection with awaited outbox', async () => {
harness.connectionSpeed = 'fast';
harness.userInputLatency = 'slowerThanOutbox';
harness.latency = 'high';
const postHarness = await harness.createPostHarness({
title: 'original title',
Expand Down Expand Up @@ -369,13 +369,13 @@ describe('DataStore sync engine', () => {
['post title 2', 5],
]);

postHarness.expectCurrentToMatch({
version: 5,
expect(await postHarness.currentContents).toMatchObject({
_version: 5,
title: 'post title 2',
});
});
test('observe on fast connection with awaited outbox', async () => {
harness.connectionSpeed = 'fast';
harness.userInputLatency = 'slowerThanOutbox';
harness.latency = 'low';

const postHarness = await harness.createPostHarness({
Expand Down Expand Up @@ -412,8 +412,8 @@ describe('DataStore sync engine', () => {
['post title 2', 5],
]);

postHarness.expectCurrentToMatch({
version: 5,
expect(await postHarness.currentContents).toMatchObject({
_version: 5,
title: 'post title 2',
});
});
Expand All @@ -432,7 +432,7 @@ describe('DataStore sync engine', () => {
* ultimately resulting in different final states.
*/
test('poor connection, initial create is not pending, external request is first received update', async () => {
harness.connectionSpeed = 'fast';
harness.userInputLatency = 'slowerThanOutbox';
harness.latency = 'high';
const postHarness = await harness.createPostHarness({
title: 'original title',
Expand Down Expand Up @@ -464,14 +464,14 @@ describe('DataStore sync engine', () => {
['original title', 'update from second client', 4],
]);

postHarness.expectCurrentToMatch({
version: 4,
expect(await postHarness.currentContents).toMatchObject({
_version: 4,
title: 'original title',
blogId: 'update from second client',
});
});
test('poor connection, initial create is not pending, external request is second received update', async () => {
harness.connectionSpeed = 'slow';
harness.userInputLatency = 'fasterThanOutbox';
harness.latency = 'high';
const postHarness = await harness.createPostHarness({
title: 'original title',
Expand Down Expand Up @@ -509,14 +509,14 @@ describe('DataStore sync engine', () => {
['post title 0', 'update from second client', 5],
]);

postHarness.expectCurrentToMatch({
version: 5,
expect(await postHarness.currentContents).toMatchObject({
_version: 5,
title: 'post title 0',
blogId: 'update from second client',
});
});
test('rapid mutations on fast connection when initial create is not pending (second field is `null`)', async () => {
harness.connectionSpeed = 'fast';
harness.userInputLatency = 'slowerThanOutbox';
harness.latency = 'low';

const postHarness = await harness.createPostHarness({
Expand Down Expand Up @@ -549,8 +549,8 @@ describe('DataStore sync engine', () => {
['post title 0', 'update from second client', 5],
]);

postHarness.expectCurrentToMatch({
version: 5,
expect(await postHarness.currentContents).toMatchObject({
_version: 5,
title: 'post title 0',
blogId: 'update from second client',
});
Expand All @@ -562,7 +562,7 @@ describe('DataStore sync engine', () => {
* in different behavior.
*/
test('rapid mutations on fast connection when initial create is not pending (second field has initial value)', async () => {
harness.connectionSpeed = 'fast';
harness.userInputLatency = 'slowerThanOutbox';
harness.latency = 'low';

const postHarness = await harness.createPostHarness({
Expand Down Expand Up @@ -596,14 +596,14 @@ describe('DataStore sync engine', () => {
['post title 0', 'original blogId', 5],
]);

postHarness.expectCurrentToMatch({
version: 5,
expect(await postHarness.currentContents).toMatchObject({
_version: 5,
title: 'post title 0',
blogId: 'original blogId',
});
});
test('observe on poor connection with awaited outbox', async () => {
harness.connectionSpeed = 'slow';
harness.userInputLatency = 'fasterThanOutbox';
harness.latency = 'high';
const postHarness = await harness.createPostHarness({
title: 'original title',
Expand Down Expand Up @@ -641,14 +641,14 @@ describe('DataStore sync engine', () => {
['post title 2', 'update from second client', 5],
]);

postHarness.expectCurrentToMatch({
version: 5,
expect(await postHarness.currentContents).toMatchObject({
_version: 5,
title: 'post title 2',
blogId: 'update from second client',
});
});
test('observe on fast connection with awaited outbox', async () => {
harness.connectionSpeed = 'slow';
harness.userInputLatency = 'fasterThanOutbox';
harness.latency = 'low';
const postHarness = await harness.createPostHarness({
title: 'original title',
Expand Down Expand Up @@ -686,8 +686,8 @@ describe('DataStore sync engine', () => {
['post title 2', 'update from second client', 5],
]);

postHarness.expectCurrentToMatch({
version: 5,
expect(await postHarness.currentContents).toMatchObject({
_version: 5,
title: 'post title 2',
blogId: 'update from second client',
});
Expand Down
Loading

0 comments on commit 1f7415f

Please sign in to comment.