-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #827 from Lombiq/issue/OFFI-56
OFFI-56: Fixing Elasticsearch setup workflow
- Loading branch information
Showing
5 changed files
with
148 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/Lombiq.OSOCE.Web/Recipes/Lombiq.OSOCE.Tests.Elasticsearch.recipe.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
{ | ||
"name": "Lombiq.OSOCE.Tests.Elasticsearch", | ||
"displayName": "TEST: Elasticsearch Configuration", | ||
"description": "Elasticsearch Configuration setup recipe for automated UI test execution.", | ||
"author": "Lombiq Technologies", | ||
"website": "https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions", | ||
"version": "1.0", | ||
"issetuprecipe": true, | ||
"categories": [ | ||
"test", | ||
"elasticsearch" | ||
], | ||
"tags": [ | ||
"test", | ||
"elasticsearch" | ||
], | ||
"steps": [ | ||
{ | ||
"name": "feature", | ||
"disable": [], | ||
"enable": [ | ||
"OrchardCore.Search.Elasticsearch", | ||
"OrchardCore.Search" | ||
] | ||
}, | ||
{ | ||
"name": "ElasticIndexSettings", | ||
"Indices": [ | ||
{ | ||
"blogposts": { | ||
"AnalyzerName": "standard", | ||
"IndexLatest": false, | ||
"IndexedContentTypes": [ | ||
"BlogPost" | ||
], | ||
"Culture": "any", | ||
"StoreSourceData": true | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Settings", | ||
"ElasticSettings": { | ||
"SearchIndex": "blogposts", | ||
"DefaultSearchFields": [ | ||
"Content.ContentItem.FullText" | ||
], | ||
"AllowElasticQueryStringQueryInSearch": false | ||
} | ||
}, | ||
{ | ||
"name": "Queries", | ||
"Queries": [ | ||
{ | ||
"Index": "blogposts", | ||
"Template": "{\r\n \"size\": 1000,\r\n \"query\":{\r\n \"term\":{\r\n \"Content.ContentItem.ContentType\":\"BlogPost\"\r\n }\r\n },\r\n \"fields\": [\r\n \"ContentItemId\", \"ContentItemVersionId\"\r\n ],\r\n \"sort\": [\r\n\t{\"Content.ContentItem.DisplayText.keyword\": {\"order\": \"asc\"}}\r\n ],\r\n \"_source\": true\r\n}", | ||
"ReturnContentItems": false, | ||
"Name": "Blog Posts", | ||
"Source": "Elasticsearch", | ||
"Schema": "{ \"type\": \"ContentItem/BlogPost\" }" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "recipes", | ||
"Values": [ | ||
{ | ||
"executionid": "Lombiq.OSOCE.Web", | ||
"name": "Lombiq.OSOCE.Tests" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
test/Lombiq.OSOCE.Tests.UI/Tests/ElasticsearchTests/BehaviorElasticsearchTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Atata; | ||
using Lombiq.Tests.UI.Extensions; | ||
using Lombiq.Tests.UI.Helpers; | ||
using Lombiq.Tests.UI.Pages; | ||
using OpenQA.Selenium; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Lombiq.OSOCE.Tests.UI.Tests.ModuleTests; | ||
|
||
public class BehaviorElasticsearchTests : UITestBase | ||
{ | ||
public BehaviorElasticsearchTests(ITestOutputHelper testOutputHelper) | ||
: base(testOutputHelper) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public Task ElasticsearchSearchingShouldWork() => | ||
ExecuteTestAsync( | ||
async context => | ||
{ | ||
await context.SignInDirectlyAndGoToRelativeUrlAsync("/search"); | ||
|
||
await context.ClickAndFillInWithRetriesAsync(By.Name("Terms"), "man"); | ||
await context.ClickReliablyOnAsync(By.XPath("//button[@class='btn btn-primary btn-sm']")); | ||
|
||
context.Exists(By.XPath("//h2[contains(., 'Man must explore, and this is exploration at its greatest')]")); | ||
}, | ||
setupOperation: async context => | ||
{ | ||
var homepageUri = await context.GoToSetupPageAndSetupOrchardCoreAsync( | ||
new OrchardCoreSetupParameters(context) | ||
{ | ||
SiteName = "Lombiq's OSOCE - UI Testing - Elasticsearch", | ||
RecipeId = "Lombiq.OSOCE.Tests.Elasticsearch", | ||
TablePrefix = "OSOCE", | ||
SiteTimeZoneValue = "Europe/Budapest", | ||
}); | ||
|
||
try | ||
{ | ||
context.Exists(By.Id("navbar")); | ||
} | ||
catch (NoSuchElementException) | ||
{ | ||
var validationErrors = context.GetAll(By.ClassName("field-validation-error")); | ||
|
||
if (validationErrors.Count == 0) throw; | ||
|
||
var errors = "\n- " + validationErrors.Select(element => element.Text.Trim()).Join("\n- "); | ||
throw new AssertionException($"Setup has failed with the following validation errors:{errors}"); | ||
} | ||
|
||
return homepageUri; | ||
}, | ||
changeConfigurationAsync: ConfigurationHelper.DisableHtmlValidation); | ||
} |