From ef132a382e040605cee25b47375b68d1e88e7cfe Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 9 Dec 2019 14:57:35 +0100 Subject: [PATCH] Another full text test. --- .../Text/TextIndexerGrainTestsBase.cs | 53 ++++++++++++++----- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/TextIndexerGrainTestsBase.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/TextIndexerGrainTestsBase.cs index 349ca2ff8..bdd584242 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/TextIndexerGrainTestsBase.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/TextIndexerGrainTestsBase.cs @@ -95,6 +95,26 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text g => TestSearchAsync(g, expected: ids1, text: "Hallo", target: Scope.Published)); } + [Fact] + public async Task Should_also_update_published_after_copy_for_specific_step() + { + await SearchWithGrains(3, + g => AddInvariantContent(g, text1: "Hello", text2: "World", onlyDraft: false), + + g => CopyAsync(g, fromDraft: true), + + g => TestSearchAsync(g, expected: ids1, text: "Hello", target: Scope.Draft), + g => TestSearchAsync(g, expected: ids1, text: "Hello", target: Scope.Draft), + + g => AddInvariantContent(g, text1: "Hallo", text2: "Welt", onlyDraft: false), + + g => TestSearchAsync(g, expected: null, text: "Hello", target: Scope.Draft), + g => TestSearchAsync(g, expected: null, text: "Hello", target: Scope.Published), + + g => TestSearchAsync(g, expected: ids1, text: "Hallo", target: Scope.Draft), + g => TestSearchAsync(g, expected: ids1, text: "Hallo", target: Scope.Published)); + } + [Fact] public async Task Should_simulate_content_reversion() { @@ -246,24 +266,29 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text { for (var i = 0; i < actions.Length; i++) { - var schemaId = Guid.NewGuid(); + await SearchWithGrains(i, actions); + } + } - await ExecuteAsync(schemaId, async sut => + private async Task SearchWithGrains(int i, params Func[] actions) + { + var schemaId = Guid.NewGuid(); + + await ExecuteAsync(schemaId, async sut => + { + foreach (var action in actions.Take(i)) { - foreach (var action in actions.Take(i)) - { - await action(sut); - } - }); + await action(sut); + } + }); - await ExecuteAsync(schemaId, async sut => + await ExecuteAsync(schemaId, async sut => + { + foreach (var action in actions.Skip(i)) { - foreach (var action in actions.Skip(i)) - { - await action(sut); - } - }); - } + await action(sut); + } + }); } private async Task ExecuteAsync(Guid id, Func action)