Skip to content

Commit

Permalink
Merge pull request #753 from Picturepark/investigation/PP9-21251-shar…
Browse files Browse the repository at this point in the history
…e-test-on-new-content-and-restricted-formats

PP9-21251 create new content during test and also cover shares with s…
  • Loading branch information
pschwarzpp authored Aug 23, 2024
2 parents 9664c34 + d623c67 commit fb90778
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/Picturepark.SDK.V1.Tests/Clients/ShareTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,16 @@ public async Task ShouldContainDynamicOutputsBasic()
LanguageCode = "en"
});

await AssertSharesContainCorrectOutputs(fullId, previewId, formatIdOriginal, formatIdPreview);
shareContents.Single().OutputFormatIds = new[] { formatIdPreview };
var specificFormatShareId = await CreateShareAndReturnId(new ShareBasicCreateRequest()
{
Contents = shareContents,
OutputAccess = OutputAccess.None,
Name = formatIdPreview + "-share",
LanguageCode = "en"
});

await AssertSharesContainCorrectOutputs(fullId, previewId, specificFormatShareId, formatIdOriginal, formatIdPreview);
}

[Fact]
Expand All @@ -578,7 +587,16 @@ public async Task ShouldContainDynamicOutputsEmbed()
Name = formatIdPreview + "-share"
});

await AssertSharesContainCorrectOutputs(fullId, previewId, formatIdOriginal, formatIdPreview);
shareContents.Single().OutputFormatIds = new[] { formatIdPreview };
var specificFormatShareId = await CreateShareAndReturnId(new ShareBasicCreateRequest()
{
Contents = shareContents,
OutputAccess = OutputAccess.None,
Name = formatIdPreview + "-share",
LanguageCode = "en"
});

await AssertSharesContainCorrectOutputs(fullId, previewId, specificFormatShareId, formatIdOriginal, formatIdPreview);
}

[Fact]
Expand Down Expand Up @@ -623,17 +641,21 @@ public async Task ShouldPageOverContentsInShare()
private async Task AssertSharesContainCorrectOutputs(
string shareFullId,
string sharePreviewId,
string shareNoneId,
string formatIdOriginal,
string formatIdPreview)
{
var shareFull = await _client.Share.GetAsync(shareFullId);
var sharePreview = await _client.Share.GetAsync(sharePreviewId);
var shareNone = await _client.Share.GetAsync(shareNoneId);

shareFull.ContentSelections.Single().Outputs.Should().Contain(o => o.OutputFormatId == formatIdPreview);
shareFull.ContentSelections.Single().Outputs.Should().Contain(o => o.OutputFormatId == formatIdOriginal);

sharePreview.ContentSelections.Single().Outputs.Should().Contain(o => o.OutputFormatId == formatIdPreview);
sharePreview.ContentSelections.Single().Outputs.Should().NotContain(o => o.OutputFormatId == formatIdOriginal);

shareNone.ContentSelections.Single().Outputs.Should().NotBeEmpty().And.OnlyContain(o => o.OutputFormatId == formatIdPreview);
}

private async Task<(string outputFormatIdOriginal, string outputFormatIdPreview, ICollection<ShareContentBase> shareContent)> PrepareDynamicOutputFormatTest([CallerMemberName] string testName = null)
Expand Down Expand Up @@ -664,11 +686,14 @@ private async Task AssertSharesContainCorrectOutputs(

await _client.OutputFormat.CreateManyAsync(new OutputFormatCreateManyRequest { Items = formats });

var contentToShare = await _fixture.GetRandomContentIdAsync("fileMetadata.fileExtension:.jpg", 10);
var uploadResult = await _client.Ingest.UploadAndImportFilesAsync(new[] { Path.Combine(_fixture.ExampleFilesBasePath, "0559_BYu8ITUWMfc.jpg") });
var uploadResultDetail = await uploadResult.FetchDetail();
var contentIdToShare = uploadResultDetail.SucceededItems.Should().ContainSingle().Which.Item.Id;

return (
formats[0].Id,
formats[1].Id,
new[] { new ShareContent { ContentId = contentToShare } }
new[] { new ShareContent { ContentId = contentIdToShare } }
);
}

Expand Down

0 comments on commit fb90778

Please sign in to comment.