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
Show file tree
Hide file tree
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
@@ -1,5 +1,6 @@
using Atata;
using Lombiq.Tests.UI.Constants;
using Lombiq.Tests.UI.Helpers;
using Lombiq.Tests.UI.Models;
using Lombiq.Tests.UI.Pages;
using Lombiq.Tests.UI.Services;
Expand Down Expand Up @@ -513,28 +514,51 @@ public static Task TestMediaOperationsAsync(this UITestContext context) =>
"Test media operations",
async () =>
{
await context.GoToRelativeUrlAsync("Admin/Media");
await context.GoToAdminRelativeUrlAsync("/Media");

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

// Workaround for pending uploads.
// Workaround for pending uploads, until you make an action the page is stuck on "Uploads Pending".
context.WaitForPageLoad();
await context.ClickReliablyOnAsync(By.CssSelector("body"));

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

await context
.Get(By.CssSelector($"a[href=\"/media/{FileUploadHelper.SamplePngFileName}\"]"))
.ClickReliablyAsync(context);

context.WaitForPageLoad();
await context.GoToAdminRelativeUrlAsync("/Media");

context.UploadSamplePdfByIdOfAnyVisibility("fileupload");

// Workaround for pending uploads, until you make an action the page is stuck on "Uploads Pending".
context.WaitForPageLoad();
await context.ClickReliablyOnAsync(By.CssSelector("body"));

context
.Get(By.CssSelector("#mediaContainerMain tbody tr:nth-child(2) .break-word"))
.Text
.ShouldBeAsString("Document.pdf");
.ShouldBeAsString(FileUploadHelper.SamplePdfFileName);

await context
.Get(By.CssSelector("#mediaContainerMain tbody tr:nth-child(2)"))
.ClickReliablyAsync(context);

await context
.Get(By.CssSelector($"a[href=\"/media/{FileUploadHelper.SamplePdfFileName}\"]"))
.ClickReliablyAsync(context);

context.WaitForPageLoad();
await context.GoToAdminRelativeUrlAsync("/Media");

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");
context.Get(By.Id("create-folder-name")).SendKeys("Example Folder");

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

Expand All @@ -543,10 +567,10 @@ public static Task TestMediaOperationsAsync(this UITestContext context) =>
context.WaitForPageLoad();
var image = context
.Get(By.CssSelector("#mediaContainerMain tbody tr:nth-child(2) .break-word"));
image.Text.ShouldBeAsString("Image.png");
image.Text.ShouldBe(FileUploadHelper.SamplePngFileName);
var pdf = context
.Get(By.CssSelector("#mediaContainerMain tbody tr:nth-child(1) .break-word"));
pdf.Text.ShouldBeAsString("Document.pdf");
pdf.Text.ShouldBe(FileUploadHelper.SamplePdfFileName);

await image.ClickReliablyAsync(context);
await context
Expand All @@ -555,10 +579,22 @@ await context
.ClickReliablyAsync(context);
await context.ClickModalOkAsync();
Piedone marked this conversation as resolved.
Show resolved Hide resolved

var fileNames = context.GetAll(By.CssSelector("#mediaContainerMain tbody tr .break-word"));
foreach (var fileName in fileNames)
{
fileName.Text.ShouldNotBe(FileUploadHelper.SamplePngFileName);
}

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

var folders = context.GetAll(By.CssSelector("#folder-tree ol li .folder-name"));
foreach (var folder in folders)
{
folder.Text.ShouldNotBe("Example Folder");
}
});

/// <summary>
Expand Down
13 changes: 9 additions & 4 deletions Lombiq.Tests.UI/Helpers/FileUploadHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ public static class FileUploadHelper
{
private static readonly string BasePath = Path.Combine(Environment.CurrentDirectory, "SampleUploadFiles");

public static readonly string SamplePdfPath = Path.Combine(BasePath, "Document.pdf");
public static readonly string SamplePngPath = Path.Combine(BasePath, "Image.png");
public static readonly string SampleDocxPath = Path.Combine(BasePath, "UploadingTestFileDOCX.docx");
public static readonly string SampleXlsxPath = Path.Combine(BasePath, "UploadingTestFileXLSX.xlsx");
public static readonly string SamplePdfFileName = "Document.pdf";
public static readonly string SamplePngFileName = "Image.png";
public static readonly string SampleDocxFileName = "UploadingTestFileDOCX.docx";
public static readonly string SampleXlsxFileName = "UploadingTestFileXLSX.xlsx";

public static readonly string SamplePdfPath = Path.Combine(BasePath, SamplePdfFileName);
public static readonly string SamplePngPath = Path.Combine(BasePath, SamplePngFileName);
public static readonly string SampleDocxPath = Path.Combine(BasePath, SampleDocxFileName);
public static readonly string SampleXlsxPath = Path.Combine(BasePath, SampleXlsxFileName);
}