Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-423: Offer Media management testing as part of TestBasicOrchardFeaturesAsync() too in Lombiq.UITestingToolbox #226

Merged
merged 20 commits into from
Dec 14, 2022
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Lombiq.Tests.UI.Models;
using Lombiq.Tests.UI.Pages;
using Lombiq.Tests.UI.Services;
using OpenQA.Selenium;
using Shouldly;
using System;
using System.Threading.Tasks;
Expand Down Expand Up @@ -107,6 +108,7 @@ public static async Task TestBasicOrchardFeaturesExceptSetupAsync(this UITestCon
await context.TestLoginAsync();
await context.TestContentOperationsAsync();
await context.TestTurningFeatureOnAndOffAsync();
await context.TestMediaOperationsAsync();
await context.TestLogoutAsync();
}

Expand Down Expand Up @@ -506,6 +508,59 @@ public static Task TestTurningFeatureOnAndOffAsync(
.SearchForFeature(featureName).IsEnabled.Should.Equal(originalEnabledState));
});

public static Task TestMediaOperationsAsync(this UITestContext context) =>
context.ExecuteTestAsync(
"Test media operations",
async () =>
{
await context.GoToRelativeUrlAsync("Admin/Media");
Piedone marked this conversation as resolved.
Show resolved Hide resolved

context.UploadSamplePngByIdOfAnyVisibility("fileupload");
context.UploadSamplePdfByIdOfAnyVisibility("fileupload");

// Workaround for pending uploads.
Piedone marked this conversation as resolved.
Show resolved Hide resolved
context.WaitForPageLoad();
await context.ClickReliablyOnAsync(By.CssSelector("body"));

context
.Get(By.CssSelector("#mediaContainerMain tbody tr:nth-child(4) .break-word"))
.Text
.ShouldBeAsString("Image.png");
Piedone marked this conversation as resolved.
Show resolved Hide resolved
context
.Get(By.CssSelector("#mediaContainerMain tbody tr:nth-child(2) .break-word"))
.Text
.ShouldBeAsString("Document.pdf");
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Piedone marked this conversation as resolved.
Show resolved Hide resolved

await context.Get(By.CssSelector("#folder-tree .treeroot .folder-actions")).ClickReliablyAsync(context);

var folderNameInput = context.Get(By.Id("create-folder-name"));
folderNameInput.SendKeys("Example Folder");
Piedone marked this conversation as resolved.
Show resolved Hide resolved

await context.Get(By.Id("modalFooterOk")).ClickReliablyAsync(context);

context.UploadSamplePngByIdOfAnyVisibility("fileupload");
context.UploadSamplePdfByIdOfAnyVisibility("fileupload");
context.WaitForPageLoad();
var image = context
.Get(By.CssSelector("#mediaContainerMain tbody tr:nth-child(2) .break-word"));
image.Text.ShouldBeAsString("Image.png");
var pdf = context
.Get(By.CssSelector("#mediaContainerMain tbody tr:nth-child(1) .break-word"));
pdf.Text.ShouldBeAsString("Document.pdf");

await image.ClickReliablyAsync(context);
await context
.Get(By.CssSelector(
"#mediaContainerMain div.media-container-middle.p-3 tr:nth-child(2) a.btn.btn-link.btn-sm.delete-button"))
.ClickReliablyAsync(context);
await context.ClickModalOkAsync();
Piedone marked this conversation as resolved.
Show resolved Hide resolved

var deleteFolderButton =
context.Get(By.CssSelector("#folder-tree > li > ol > li.selected > div > a > div.btn-group.folder-actions > a:nth-child(2)"));
await deleteFolderButton.ClickReliablyAsync(context);
await context.ClickModalOkAsync();
Piedone marked this conversation as resolved.
Show resolved Hide resolved
});

/// <summary>
/// Executes the <paramref name="testFunctionAsync"/> with the specified <paramref name="testName"/>.
/// </summary>
Expand Down