mirror of https://github.com/Squidex/squidex.git
2 changed files with 91 additions and 0 deletions
@ -0,0 +1,61 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using TestSuite.Fixtures; |
|||
using TestSuite.Model; |
|||
using Xunit; |
|||
|
|||
#pragma warning disable SA1300 // Element should begin with upper-case letter
|
|||
#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row
|
|||
|
|||
namespace TestSuite.ApiTests |
|||
{ |
|||
public class ContentReferencesTests : IClassFixture<ContentReferencesFixture> |
|||
{ |
|||
public ContentReferencesFixture _ { get; } |
|||
|
|||
public ContentReferencesTests(ContentReferencesFixture fixture) |
|||
{ |
|||
_ = fixture; |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_not_deliver_unpublished_references() |
|||
{ |
|||
// STEP 1: Create a referenced content.
|
|||
var dataA = new TestEntityWithReferencesData(); |
|||
|
|||
var contentA_1 = await _.Contents.CreateAsync(dataA); |
|||
|
|||
|
|||
// STEP 2: Create a content with a reference.
|
|||
var dataB = new TestEntityWithReferencesData { References = new[] { contentA_1.Id } }; |
|||
|
|||
var contentB_1 = await _.Contents.CreateAsync(dataB); |
|||
|
|||
await _.Contents.ChangeStatusAsync(contentB_1.Id, "Published"); |
|||
|
|||
|
|||
// STEP 3: Query new item
|
|||
var contentB_2 = await _.Contents.GetAsync(contentB_1.Id); |
|||
|
|||
Assert.Empty(contentB_2.Data.References); |
|||
|
|||
|
|||
// STEP 4: Publish reference
|
|||
await _.Contents.ChangeStatusAsync(contentA_1.Id, "Published"); |
|||
|
|||
|
|||
// STEP 5: Query new item again
|
|||
var contentB_3 = await _.Contents.GetAsync(contentB_1.Id); |
|||
|
|||
Assert.Equal(new Guid[] { contentA_1.Id }, contentB_3.Data.References); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Threading.Tasks; |
|||
using Squidex.ClientLibrary; |
|||
using TestSuite.Model; |
|||
|
|||
namespace TestSuite.Fixtures |
|||
{ |
|||
public sealed class ContentReferencesFixture : CreatedAppFixture |
|||
{ |
|||
public string SchemaName { get; } = "references"; |
|||
|
|||
public IContentsClient<TestEntityWithReferences, TestEntityWithReferencesData> Contents { get; } |
|||
|
|||
public ContentReferencesFixture() |
|||
{ |
|||
Task.Run(async () => |
|||
{ |
|||
await TestEntityWithReferences.CreateSchemaAsync(Schemas, AppName, SchemaName); |
|||
}).Wait(); |
|||
|
|||
Contents = ClientManager.CreateContentsClient<TestEntityWithReferences, TestEntityWithReferencesData>(SchemaName); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue