diff --git a/backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/PartOfSpeechTests.cs b/backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/PartOfSpeechTests.cs index 3943623a0..5533cbb2b 100644 --- a/backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/PartOfSpeechTests.cs +++ b/backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/PartOfSpeechTests.cs @@ -1,6 +1,7 @@ using FwDataMiniLcmBridge.Api; using FwDataMiniLcmBridge.Tests.Fixtures; using MiniLcm.Models; +using SIL.LCModel; using SIL.LCModel.Infrastructure; namespace FwDataMiniLcmBridge.Tests.MiniLcmTests; @@ -81,4 +82,31 @@ public async Task SetPartOfSpeech_WithNullMorphoSyntaxAnalysisRA_ToNull() retrievedEntry.Should().NotBeNull(); retrievedEntry!.PartOfSpeechId.Should().BeNull(); } + + [Fact] + public async Task GetPartsOfSpeech_DoesNotReturnReversalIndexPos() + { + // Arrange + var fwApi = (FwDataMiniLcmApi)BaseApi; + var reversalIndexRepository = fwApi.Cache.ServiceLocator.GetInstance(); + var analysisWs = fwApi.Cache.DefaultAnalWs; + + var reversalPosGuid = Guid.NewGuid(); + UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW("Create Reversal Index POS", + "Remove Reversal Index POS", + fwApi.Cache.ServiceLocator.ActionHandler, + () => + { + var reversalIndex = reversalIndexRepository.FindOrCreateIndexForWs(analysisWs); + var posFactory = fwApi.Cache.ServiceLocator.GetInstance(); + var reversalPos = posFactory.Create(reversalPosGuid, reversalIndex.PartsOfSpeechOA); + reversalPos.Name.set_String(analysisWs, "Reversal Test POS"); + }); + + // Act + var partsOfSpeech = await Api.GetPartsOfSpeech().ToArrayAsync(); + + // Assert + partsOfSpeech.Should().NotContain(pos => pos.Id == reversalPosGuid); + } } diff --git a/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs b/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs index bcaeb438f..c52fba6a0 100644 --- a/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs +++ b/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs @@ -271,8 +271,7 @@ void MoveWs(CoreWritingSystemDefinition ws, public IAsyncEnumerable GetPartsOfSpeech() { - return PartOfSpeechRepository - .AllInstances() + return Cache.LangProject.AllPartsOfSpeech .OrderBy(p => p.Name.BestAnalysisAlternative.Text) .ToAsyncEnumerable() .Select(FromLcmPartOfSpeech); diff --git a/backend/FwLite/FwLiteProjectSync.Tests/SyncTests.cs b/backend/FwLite/FwLiteProjectSync.Tests/SyncTests.cs index b7e5cc734..ed027c1d3 100644 --- a/backend/FwLite/FwLiteProjectSync.Tests/SyncTests.cs +++ b/backend/FwLite/FwLiteProjectSync.Tests/SyncTests.cs @@ -64,6 +64,14 @@ public async Task DisposeAsync() { await _fixture.CrdtApi.DeleteEntry(entry.Id); } + await foreach (var pos in _fixture.FwDataApi.GetPartsOfSpeech()) + { + await _fixture.FwDataApi.DeletePartOfSpeech(pos.Id); + } + foreach (var pos in await _fixture.CrdtApi.GetPartsOfSpeech().ToArrayAsync()) + { + await _fixture.CrdtApi.DeletePartOfSpeech(pos.Id); + } } public SyncTests(SyncFixture fixture)