Skip to content

Commit

Permalink
Merge pull request #371 from Lombiq/issue/NEST-538
Browse files Browse the repository at this point in the history
NEST-538: Adjusting workflow testing in case there are already one page of workflows
  • Loading branch information
sarahelsaig authored May 22, 2024
2 parents aa08c68 + 8b097da commit 038f62d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ public static Task TestWorkflowsAsync(this UITestContext context) =>
"Test Workflows",
async () =>
{
var workflowsPath = "/Workflows/Types";
var contentItemPublishTestSuccessMessage = "The content item was published.";
const string testWorkflowName = "Test workflow";
const string workflowsPath = "/Workflows/Types";
const string contentItemPublishTestSuccessMessage = "The content item was published.";
await context.EnableFeatureDirectlyAsync("OrchardCore.Workflows");
await context.GoToAdminRelativeUrlAsync(workflowsPath + "/EditProperties");
await context.ClickAndFillInWithRetriesAsync(By.Id("Name"), "Test workflow");
await context.ClickAndFillInWithRetriesAsync(By.Id("Name"), testWorkflowName);
await context.ClickReliablyOnSubmitAsync();
await context.ClickReliablyOnAsync(By.XPath("//button[@data-activity-type='Event']"));
Expand Down Expand Up @@ -69,6 +70,11 @@ public static Task TestWorkflowsAsync(this UITestContext context) =>
// Checking if the workflow run was logged.
await context.GoToAdminRelativeUrlAsync(workflowsPath);
// If we are testing an app with already existing workflows, our "Test workflow" can end up on a
// different page, rather than on the first.
await context.FilterOnAdminAsync(testWorkflowName);
await context.ClickReliablyOnAsync(By.XPath("//a[text()='Test workflow']/following-sibling::a[contains(@href, 'Instances')]"));
context.Exists(By.XPath("//span[@class = 'badge text-bg-success']"));
});
Expand Down
14 changes: 14 additions & 0 deletions Lombiq.Tests.UI/Extensions/NavigationUITestContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,18 @@ public static void DragAndDropToOffset(this UITestContext context, By sourceElem
new Actions(context.Driver).DragAndDropToOffset(context.Get(sourceElementBy), offsetX, offsetY)
.Build()
.Perform();

/// <summary>
/// A method to filter for an item on one of the admin pages.
/// </summary>
/// <param name="itemName">The element we should search or filter for. It could be for example a workflow too,
/// that's why it's not called "contentItem".</param>
public static async Task FilterOnAdminAsync(this UITestContext context, string itemName)
{
await context.ClickAndFillInWithRetriesAsync(By.Id("Options_Search"), itemName);

// Normally we would trigger filtering by pressing the "Enter" key. The filter submit button is hidden,
// so we have to use JS to click on it.
context.ExecuteScript("document.getElementById('submitFilter').click();");
}
}

0 comments on commit 038f62d

Please sign in to comment.