diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetEnricher.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetEnricher.cs index baf877d309..e7f2b728fb 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetEnricher.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetEnricher.cs @@ -64,23 +64,20 @@ public async Task> EnrichAsync(IEnumerable assets) + private void EnrichWithEditTokens(IEnumerable assets) { var url = urlGenerator.Root(); foreach (var asset in assets) { + // We have to use these short names here because they are later read like this. var token = new { a = asset.AppId.Name, diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/CalculateTokens.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/CalculateTokens.cs index edcd9a3e01..7f7535717b 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/CalculateTokens.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/CalculateTokens.cs @@ -25,15 +25,11 @@ public CalculateTokens(IUrlGenerator urlGenerator, IJsonSerializer serializer) public Task EnrichAsync(Context context, IEnumerable contents, ProvideSchema schemas, CancellationToken ct) { - if (context.IsFrontendClient) - { - return Task.CompletedTask; - } - var url = urlGenerator.Root(); foreach (var content in contents) { + // We have to use these short names here because they are later read like this. var token = new { a = content.AppId.Name, diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetEnricherTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetEnricherTests.cs index 54824a2b71..fe3844c549 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetEnricherTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetEnricherTests.cs @@ -173,7 +173,7 @@ public async Task Should_enrich_multiple_assets_with_tag_names() } [Fact] - public async Task Should_not_compute_ui_tokens_for_frontend() + public async Task Should_also_compute_ui_tokens_for_frontend() { var source = new AssetEntity { @@ -182,10 +182,10 @@ public async Task Should_not_compute_ui_tokens_for_frontend() var result = await sut.EnrichAsync(new[] { source }, new Context(Mocks.FrontendUser(), Mocks.App(appId)), ct); - Assert.Null(result[0].EditToken); + Assert.NotNull(result[0].EditToken); A.CallTo(() => urlGenerator.Root()) - .MustNotHaveHappened(); + .MustHaveHappened(); } [Fact] diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/CalculateTokensTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/CalculateTokensTests.cs index 6335563991..d30243db9a 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/CalculateTokensTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Queries/CalculateTokensTests.cs @@ -39,24 +39,24 @@ public CalculateTokensTests() } [Fact] - public async Task Should_not_compute_ui_tokens_for_frontend() + public async Task Should_compute_ui_tokens() { var source = CreateContent(); - await sut.EnrichAsync(new Context(Mocks.FrontendUser(), Mocks.App(appId)), new[] { source }, schemaProvider, default); + await sut.EnrichAsync(requestContext, new[] { source }, schemaProvider, default); - Assert.Null(source.EditToken); + Assert.NotNull(source.EditToken); A.CallTo(() => urlGenerator.Root()) - .MustNotHaveHappened(); + .MustHaveHappened(); } [Fact] - public async Task Should_compute_ui_tokens() + public async Task Should_also_compute_ui_tokens_for_frontend() { var source = CreateContent(); - await sut.EnrichAsync(requestContext, new[] { source }, schemaProvider, default); + await sut.EnrichAsync(new Context(Mocks.FrontendUser(), Mocks.App(appId)), new[] { source }, schemaProvider, default); Assert.NotNull(source.EditToken);