Skip to content
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

Complex forms in miniLcm #1061

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
19ef8fe
add LcmDebugger CLI to be able open projects and inspect LCM stuff in…
hahn-kev Sep 23, 2024
dfcf5bb
first pass at what complex forms might look like in miniLcm
hahn-kev Sep 23, 2024
abad0cf
rename EntryType to ComplexEntryType and expose it via a method on th…
hahn-kev Sep 24, 2024
41bd955
add support for variants
hahn-kev Sep 24, 2024
b18c2ee
Merge branch 'develop' into feat/complex-forms
hahn-kev Sep 25, 2024
4b301f0
add crdt support for Complex Forms
hahn-kev Sep 30, 2024
66f99f7
undo ugly hack of putting Sense list on Crdt Entry
hahn-kev Sep 30, 2024
af357b4
add a note when populating the complex forms of an entry
hahn-kev Sep 30, 2024
f1555a2
write tests and support creating entries with complex forms or compon…
hahn-kev Sep 30, 2024
3d9f45c
add complex form type to miniLcm API, ensure complex forms get imported
hahn-kev Sep 30, 2024
786e20b
support updating LCM entry components via the components property
hahn-kev Oct 1, 2024
0fc946e
add support for changing ComplexForms collection directly
hahn-kev Oct 1, 2024
6793913
add support for changing complex form types
hahn-kev Oct 2, 2024
95762f9
add support for changing Components of a complex form
hahn-kev Oct 2, 2024
1c4951d
add support for changing ComplexForms of a component
hahn-kev Oct 2, 2024
5f3b81f
implement complex form type changes via json patch
hahn-kev Oct 2, 2024
37124bf
Merge branch 'develop' into feat/complex-forms
hahn-kev Oct 4, 2024
73dca2f
define custom mapping for MiniLcm.Models.Entry.Senses so that linq2db…
hahn-kev Oct 4, 2024
0b25746
update code to better handle filtering on senses
hahn-kev Oct 4, 2024
58cbdca
revert changes to Entry.Senses
hahn-kev Oct 7, 2024
1b05889
remove variants field from Entry as it's not ready and is out of scope
hahn-kev Oct 7, 2024
1f32678
Merge branch 'develop' into feat/complex-forms
hahn-kev Oct 7, 2024
2652efc
correct some failing tests
hahn-kev Oct 7, 2024
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
7 changes: 7 additions & 0 deletions LexBox.sln
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FwLiteProjectSync", "backen
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FwLiteProjectSync.Tests", "backend\FwLite\FwLiteProjectSync.Tests\FwLiteProjectSync.Tests.csproj", "{5352D1CC-14C5-4589-9389-731F55E4FFDF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LcmDebugger", "backend\LfNext\LcmDebugger\LcmDebugger.csproj", "{5A9011D8-6EC1-4550-BDD7-AFF00DB2B921}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -127,6 +129,10 @@ Global
{5352D1CC-14C5-4589-9389-731F55E4FFDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5352D1CC-14C5-4589-9389-731F55E4FFDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5352D1CC-14C5-4589-9389-731F55E4FFDF}.Release|Any CPU.Build.0 = Release|Any CPU
{5A9011D8-6EC1-4550-BDD7-AFF00DB2B921}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A9011D8-6EC1-4550-BDD7-AFF00DB2B921}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A9011D8-6EC1-4550-BDD7-AFF00DB2B921}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A9011D8-6EC1-4550-BDD7-AFF00DB2B921}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -144,6 +150,7 @@ Global
{9001FE0F-DBBF-4A78-9EB9-9B5042CF8A78} = {7B6E21C4-5AF4-4505-B7D9-59A3886C5090}
{2245BAB6-753A-48AE-B929-6D8C35CB9804} = {7B6E21C4-5AF4-4505-B7D9-59A3886C5090}
{5352D1CC-14C5-4589-9389-731F55E4FFDF} = {7B6E21C4-5AF4-4505-B7D9-59A3886C5090}
{5A9011D8-6EC1-4550-BDD7-AFF00DB2B921} = {7B6E21C4-5AF4-4505-B7D9-59A3886C5090}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {440AE83C-6DB0-4F18-B2C1-BCD33F0645B6}
Expand Down
138 changes: 138 additions & 0 deletions backend/FwLite/FwDataMiniLcmBridge.Tests/CreateEntryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
using FwDataMiniLcmBridge.Api;
using FwDataMiniLcmBridge.Tests.Fixtures;
using MiniLcm.Models;

namespace FwDataMiniLcmBridge.Tests;

[Collection(ProjectLoaderFixture.Name)]
public class CreateEntryTests(ProjectLoaderFixture fixture) : IAsyncLifetime
{
private FwDataMiniLcmApi _api = null!;

public Task InitializeAsync()
{
var projectName = "create-entry-test_" + Guid.NewGuid();
fixture.MockFwProjectLoader.NewProject(projectName, "en", "en");
_api = fixture.CreateApi(projectName);
return Task.CompletedTask;
}

public Task DisposeAsync()
{
_api.Dispose();
return Task.CompletedTask;
}

[Fact]
public async Task CanCreateEntry()
{
var entry = await _api.CreateEntry(new() { LexemeForm = { { "en", "test" } } });
entry.Should().NotBeNull();
entry!.LexemeForm.Values.Should().ContainKey("en");
entry.LexemeForm.Values["en"].Should().Be("test");
}

[Fact]
public async Task CanCreate_WithComponentsProperty()
{
var component = await _api.CreateEntry(new() { LexemeForm = { { "en", "test component" } } });
var entryId = Guid.NewGuid();
var entry = await _api.CreateEntry(new()
{
Id = entryId,
LexemeForm = { { "en", "test" } },
Components =
[
new ComplexFormComponent()
{
ComponentEntryId = component.Id,
ComponentHeadword = component.Headword(),
ComplexFormEntryId = entryId,
ComplexFormHeadword = "test"
}
]
});
entry = await _api.GetEntry(entry.Id);
entry.Should().NotBeNull();
entry!.Components.Should().ContainSingle(c => c.ComponentEntryId == component.Id);
}

[Fact]
public async Task CanCreate_WithComplexFormsProperty()
{
var complexForm = await _api.CreateEntry(new() { LexemeForm = { { "en", "test complex form" } } });
var entryId = Guid.NewGuid();
var entry = await _api.CreateEntry(new()
{
Id = entryId,
LexemeForm = { { "en", "test" } },
ComplexForms =
[
new ComplexFormComponent()
{
ComponentEntryId = entryId,
ComponentHeadword = "test",
ComplexFormEntryId = complexForm.Id,
ComplexFormHeadword = "test complex form"
}
]
});
entry = await _api.GetEntry(entry.Id);
entry.Should().NotBeNull();
entry!.ComplexForms.Should().ContainSingle(c => c.ComplexFormEntryId == complexForm.Id);
}

[Fact]
public async Task CreateEntry_WithComponentSenseDoesNotShowOnComplexFormsList()
{
var componentSenseId = Guid.NewGuid();
var component = await _api.CreateEntry(new()
{
LexemeForm = { { "en", "test component" } },
Senses = [new Sense() { Id = componentSenseId, Gloss = { { "en", "test component sense" } } }]
});
var complexFormEntryId = Guid.NewGuid();
await _api.CreateEntry(new()
{
Id = complexFormEntryId,
LexemeForm = { { "en", "test" } },
Components =
[
new ComplexFormComponent()
{
ComponentEntryId = component.Id,
ComponentHeadword = component.Headword(),
ComponentSenseId = componentSenseId,
ComplexFormEntryId = complexFormEntryId,
ComplexFormHeadword = "test"
}
]
});

var entry = await _api.GetEntry(component.Id);
entry.Should().NotBeNull();
entry!.ComplexForms.Should().BeEmpty();

entry = await _api.GetEntry(complexFormEntryId);
entry.Should().NotBeNull();
entry!.Components.Should().ContainSingle(c => c.ComplexFormEntryId == complexFormEntryId && c.ComponentEntryId == component.Id && c.ComponentSenseId == componentSenseId);
}

[Fact]
public async Task CanCreate_WithComplexFormTypesProperty()
{
var complexFormType = await _api.CreateComplexFormType(new()
{
Name = new MultiString() { { "en", "test complex form type" } }
});

var entry = await _api.CreateEntry(new()
{
LexemeForm = { { "en", "test" } },
ComplexFormTypes = [complexFormType]
});
entry = await _api.GetEntry(entry.Id);
entry.Should().NotBeNull();
entry!.ComplexFormTypes.Should().ContainSingle(c => c.Id == complexFormType.Id);
}
}
Loading
Loading