-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
hahn-kev
wants to merge
23
commits into
develop
Choose a base branch
from
feat/complex-forms
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Complex forms in miniLcm #1061
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 dfcf5bb
first pass at what complex forms might look like in miniLcm
hahn-kev abad0cf
rename EntryType to ComplexEntryType and expose it via a method on th…
hahn-kev 41bd955
add support for variants
hahn-kev b18c2ee
Merge branch 'develop' into feat/complex-forms
hahn-kev 4b301f0
add crdt support for Complex Forms
hahn-kev 66f99f7
undo ugly hack of putting Sense list on Crdt Entry
hahn-kev af357b4
add a note when populating the complex forms of an entry
hahn-kev f1555a2
write tests and support creating entries with complex forms or compon…
hahn-kev 3d9f45c
add complex form type to miniLcm API, ensure complex forms get imported
hahn-kev 786e20b
support updating LCM entry components via the components property
hahn-kev 0fc946e
add support for changing ComplexForms collection directly
hahn-kev 6793913
add support for changing complex form types
hahn-kev 95762f9
add support for changing Components of a complex form
hahn-kev 1c4951d
add support for changing ComplexForms of a component
hahn-kev 5f3b81f
implement complex form type changes via json patch
hahn-kev 37124bf
Merge branch 'develop' into feat/complex-forms
hahn-kev 73dca2f
define custom mapping for MiniLcm.Models.Entry.Senses so that linq2db…
hahn-kev 0b25746
update code to better handle filtering on senses
hahn-kev 58cbdca
revert changes to Entry.Senses
hahn-kev 1b05889
remove variants field from Entry as it's not ready and is out of scope
hahn-kev 1f32678
Merge branch 'develop' into feat/complex-forms
hahn-kev 2652efc
correct some failing tests
hahn-kev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
backend/FwLite/FwDataMiniLcmBridge.Tests/CreateEntryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.