Skip to content

Commit

Permalink
Attempt to create unit test to repro sena-3 issue
Browse files Browse the repository at this point in the history
This was not successful at reproducing the issue we encounter syncing
sena-3, because this test is passing. I'll keep working at it.
  • Loading branch information
rmunn committed Nov 19, 2024
1 parent 452120a commit 622856d
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions backend/FwLite/FwLiteProjectSync.Tests/SyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,55 @@ await crdtApi.CreateEntry(new Entry()
.For(e => e.ComplexForms).Exclude(c => c.Id));
}

[Fact]
public async Task CreatingAComplexEntryInFwDataSyncsWithoutIssue()
{
var crdtApi = _fixture.CrdtApi;
var fwdataApi = _fixture.FwDataApi;
await _syncService.Sync(crdtApi, fwdataApi);

var hat = await fwdataApi.CreateEntry(new Entry()
{
LexemeForm = { { "en", "Hat" } },
Senses =
[
new Sense() { Gloss = { { "en", "Hat" } }, }
]
});
var stand = await fwdataApi.CreateEntry(new Entry()
{
LexemeForm = { { "en", "Stand" } },
Senses =
[
new Sense() { Gloss = { { "en", "Stand" } }, }
]
});
var hatstand = await fwdataApi.CreateEntry(new Entry()
{
LexemeForm = { { "en", "Hatstand" } },
Senses =
[
new Sense() { Gloss = { { "en", "Hatstand" } }, }
],
});
var component1 = ComplexFormComponent.FromEntries(hatstand, hat);
var component2 = ComplexFormComponent.FromEntries(hatstand, stand);
hatstand.Components = [component1, component2];
await _syncService.Sync(crdtApi, fwdataApi);

var crdtEntries = await crdtApi.GetEntries().ToArrayAsync();
var fwdataEntries = await fwdataApi.GetEntries().ToArrayAsync();
crdtEntries.Should().BeEquivalentTo(fwdataEntries,
options => options.For(e => e.Components).Exclude(c => c.Id)
.For(e => e.ComplexForms).Exclude(c => c.Id));

// Sync again, ensure no problems or changes
var secondSync = await _syncService.Sync(crdtApi, fwdataApi);
secondSync.CrdtChanges.Should().Be(0);
secondSync.FwdataChanges.Should().Be(0);
}


[Fact]
public async Task PartsOfSpeechSyncBothWays()
{
Expand Down

0 comments on commit 622856d

Please sign in to comment.