E2ETests: Use ElwigTestDB.sqlite3 instead of default
All checks were successful
Test / Run tests (push) Successful in 2m38s
All checks were successful
Test / Run tests (push) Successful in 2m38s
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ bin/
|
|||||||
Tests/Resources/Sql/Create.sql
|
Tests/Resources/Sql/Create.sql
|
||||||
*.exe
|
*.exe
|
||||||
!WinziPrint.exe
|
!WinziPrint.exe
|
||||||
|
*.sqlite3
|
||||||
|
@ -31,8 +31,8 @@ namespace Elwig {
|
|||||||
public static readonly string DataPath = @"C:\ProgramData\Elwig\";
|
public static readonly string DataPath = @"C:\ProgramData\Elwig\";
|
||||||
public static readonly string ExePath = @"C:\Program Files\Elwig\";
|
public static readonly string ExePath = @"C:\Program Files\Elwig\";
|
||||||
public static readonly string TempPath = Path.Combine(Path.GetTempPath(), "Elwig");
|
public static readonly string TempPath = Path.Combine(Path.GetTempPath(), "Elwig");
|
||||||
public static readonly Config Config = new(DataPath + "config.ini");
|
|
||||||
|
|
||||||
|
public static Config Config { get; private set; } = new(Path.Combine(DataPath, "config.ini"));
|
||||||
public static int VersionMajor { get; private set; }
|
public static int VersionMajor { get; private set; }
|
||||||
public static int VersionMinor { get; private set; }
|
public static int VersionMinor { get; private set; }
|
||||||
public static int VersionPatch { get; private set; }
|
public static int VersionPatch { get; private set; }
|
||||||
@ -74,6 +74,11 @@ namespace Elwig {
|
|||||||
CurrentApp = this;
|
CurrentApp = this;
|
||||||
OverrideCulture();
|
OverrideCulture();
|
||||||
|
|
||||||
|
var args = Environment.GetCommandLineArgs();
|
||||||
|
if (args.Length >= 2) {
|
||||||
|
Config = new(Path.GetFullPath(args[1]));
|
||||||
|
}
|
||||||
|
|
||||||
ContextTimer.Tick += (object? sender, EventArgs evt) => {
|
ContextTimer.Tick += (object? sender, EventArgs evt) => {
|
||||||
if (CurrentLastWrite > LastChanged) {
|
if (CurrentLastWrite > LastChanged) {
|
||||||
LastChanged = CurrentLastWrite;
|
LastChanged = CurrentLastWrite;
|
||||||
|
@ -98,15 +98,15 @@ namespace Elwig.Helpers {
|
|||||||
SavedChanges += OnSavedChanges;
|
SavedChanges += OnSavedChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SqliteConnection Connect() {
|
public static SqliteConnection Connect(string? connectionString = null) {
|
||||||
var cnx = new SqliteConnection(ConnectionString);
|
var cnx = new SqliteConnection(connectionString ?? ConnectionString);
|
||||||
cnx.CreateFunction<string, string?, bool?>("REGEXP", (pattern, value) => value == null ? null : Regex.Match(value, pattern).Success, true);
|
cnx.CreateFunction<string, string?, bool?>("REGEXP", (pattern, value) => value == null ? null : Regex.Match(value, pattern).Success, true);
|
||||||
cnx.Open();
|
cnx.Open();
|
||||||
return cnx;
|
return cnx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<SqliteConnection> ConnectAsync() {
|
public static async Task<SqliteConnection> ConnectAsync(string? connectionString = null) {
|
||||||
var cnx = new SqliteConnection(ConnectionString);
|
var cnx = new SqliteConnection(connectionString ?? ConnectionString);
|
||||||
cnx.CreateFunction<string, string?, bool?>("REGEXP", (pattern, value) => value == null ? null : Regex.Match(value, pattern).Success, true);
|
cnx.CreateFunction<string, string?, bool?>("REGEXP", (pattern, value) => value == null ? null : Regex.Match(value, pattern).Success, true);
|
||||||
await cnx.OpenAsync();
|
await cnx.OpenAsync();
|
||||||
return cnx;
|
return cnx;
|
||||||
|
@ -17,7 +17,7 @@ namespace Elwig.Helpers {
|
|||||||
using var cnx = AppDbContext.Connect();
|
using var cnx = AppDbContext.Connect();
|
||||||
|
|
||||||
var applId = (long?)await AppDbContext.ExecuteScalar(cnx, "PRAGMA application_id") ?? 0;
|
var applId = (long?)await AppDbContext.ExecuteScalar(cnx, "PRAGMA application_id") ?? 0;
|
||||||
if (applId != 0x454C5747) throw new Exception("Invalid application_id of database");
|
if (applId != 0x454C5747) throw new Exception($"Invalid application_id in database (0x{applId:X08})");
|
||||||
|
|
||||||
var schemaVers = (long?)await AppDbContext.ExecuteScalar(cnx, "PRAGMA schema_version") ?? 0;
|
var schemaVers = (long?)await AppDbContext.ExecuteScalar(cnx, "PRAGMA schema_version") ?? 0;
|
||||||
VersionOffset = (int)(schemaVers % 100);
|
VersionOffset = (int)(schemaVers % 100);
|
||||||
|
@ -69,9 +69,9 @@ namespace Elwig.Helpers {
|
|||||||
public void Read() {
|
public void Read() {
|
||||||
var config = new ConfigurationBuilder().AddIniFile(FileName).Build();
|
var config = new ConfigurationBuilder().AddIniFile(FileName).Build();
|
||||||
|
|
||||||
DatabaseFile = Path.Combine(App.DataPath, config["database:file"] ?? "database.sqlite3");
|
DatabaseFile = Path.Combine(Path.GetDirectoryName(FileName) ?? App.DataPath, config["database:file"] ?? "database.sqlite3");
|
||||||
var log = config["database:log"];
|
var log = config["database:log"];
|
||||||
DatabaseLog = log != null ? Path.Combine(App.DataPath, log) : null;
|
DatabaseLog = log != null ? Path.Combine(Path.GetDirectoryName(FileName) ?? App.DataPath, log) : null;
|
||||||
Branch = config["general:branch"];
|
Branch = config["general:branch"];
|
||||||
Debug = TrueValues.Contains(config["general:debug"]?.ToLower());
|
Debug = TrueValues.Contains(config["general:debug"]?.ToLower());
|
||||||
UpdateUrl = config["update:url"];
|
UpdateUrl = config["update:url"];
|
||||||
|
@ -9,10 +9,12 @@ namespace Tests.E2ETests {
|
|||||||
public readonly WindowsDriver<WindowsElement> App;
|
public readonly WindowsDriver<WindowsElement> App;
|
||||||
public readonly WindowsDriver<WindowsElement> Desktop;
|
public readonly WindowsDriver<WindowsElement> Desktop;
|
||||||
|
|
||||||
public AppSession(string appPath, string winAppDriverUrl) {
|
public AppSession(string appPath, string? appArgs, string winAppDriverUrl) {
|
||||||
WinAppDriverUrl = winAppDriverUrl;
|
WinAppDriverUrl = winAppDriverUrl;
|
||||||
var appiumOptions = new AppiumOptions();
|
var appiumOptions = new AppiumOptions();
|
||||||
appiumOptions.AddAdditionalCapability("app", appPath);
|
appiumOptions.AddAdditionalCapability("app", appPath);
|
||||||
|
if (appArgs != null)
|
||||||
|
appiumOptions.AddAdditionalCapability("appArguments", appArgs);
|
||||||
appiumOptions.AddAdditionalCapability("deviceName", "WindowsPC");
|
appiumOptions.AddAdditionalCapability("deviceName", "WindowsPC");
|
||||||
appiumOptions.AddAdditionalCapability("ms:waitForAppLaunch", WaitForAppLaunch);
|
appiumOptions.AddAdditionalCapability("ms:waitForAppLaunch", WaitForAppLaunch);
|
||||||
App = new WindowsDriver<WindowsElement>(new Uri(WinAppDriverUrl), appiumOptions);
|
App = new WindowsDriver<WindowsElement>(new Uri(WinAppDriverUrl), appiumOptions);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
[OneTimeSetUp]
|
[OneTimeSetUp]
|
||||||
public void Setup() {
|
public void Setup() {
|
||||||
Session = new(Utils.ApplicationPath, WinAppDriver.WinAppDriverUrl);
|
Session = new(Utils.ApplicationPath, Utils.ConfigPath, WinAppDriver.WinAppDriverUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
[OneTimeTearDown]
|
[OneTimeTearDown]
|
||||||
|
@ -9,7 +9,7 @@ namespace Tests.E2ETests {
|
|||||||
|
|
||||||
[OneTimeSetUp]
|
[OneTimeSetUp]
|
||||||
public void WindowSetup() {
|
public void WindowSetup() {
|
||||||
Session = new(Utils.ApplicationPath, WinAppDriver.WinAppDriverUrl);
|
Session = new(Utils.ApplicationPath, Utils.ConfigPath, WinAppDriver.WinAppDriverUrl);
|
||||||
Session.App.FindElementByName("Mitglieder").Click();
|
Session.App.FindElementByName("Mitglieder").Click();
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
Window = Session.CreateWindowDriver("MemberAdminWindow");
|
Window = Session.CreateWindowDriver("MemberAdminWindow");
|
||||||
@ -33,10 +33,10 @@ namespace Tests.E2ETests {
|
|||||||
Window!.FindById("NewMemberButton").Click();
|
Window!.FindById("NewMemberButton").Click();
|
||||||
|
|
||||||
Window.FindById("MgNrInput").Clear();
|
Window.FindById("MgNrInput").Clear();
|
||||||
Window.FindById("MgNrInput").SendKeys("10003");
|
Window.FindById("MgNrInput").SendKeys("9999");
|
||||||
|
|
||||||
Window.FindById("GivenNameInput").SendKeys("Max");
|
Window.FindById("GivenNameInput").SendKeys("Norbert");
|
||||||
Window.FindById("FamilyNameInput").SendKeys("Mustermann");
|
Window.FindById("FamilyNameInput").SendKeys("Neuling");
|
||||||
Window.FindById("PrefixInput").SendKeys("Ing.");
|
Window.FindById("PrefixInput").SendKeys("Ing.");
|
||||||
Window.FindById("SuffixInput").SendKeys("jun.");
|
Window.FindById("SuffixInput").SendKeys("jun.");
|
||||||
Window.FindById("BirthdayInput").SendKeys("1987");
|
Window.FindById("BirthdayInput").SendKeys("1987");
|
||||||
@ -45,8 +45,8 @@ namespace Tests.E2ETests {
|
|||||||
Window.FindById("PlzInput").SendKeys("2120");
|
Window.FindById("PlzInput").SendKeys("2120");
|
||||||
Window.SelectComboBoxItemByCount("OrtInput", 1);
|
Window.SelectComboBoxItemByCount("OrtInput", 1);
|
||||||
|
|
||||||
Window.FindById("EmailAddress1Input").SendKeys("max.mustermann@aon.at");
|
Window.FindById("EmailAddress1Input").SendKeys("norbert.neuling@aon.at");
|
||||||
Window.FindById("EmailAddress2Input").SendKeys("erika.mustermann@aon.at");
|
Window.FindById("EmailAddress2Input").SendKeys("nathalie.neuling@aon.at");
|
||||||
|
|
||||||
Window.SelectComboBoxItemByCount("PhoneNr1TypeInput", 1);
|
Window.SelectComboBoxItemByCount("PhoneNr1TypeInput", 1);
|
||||||
Window.FindById("PhoneNr1Input").SendKeys("012345678");
|
Window.FindById("PhoneNr1Input").SendKeys("012345678");
|
||||||
@ -57,13 +57,13 @@ namespace Tests.E2ETests {
|
|||||||
Window.FindById("IbanInput").SendKeys("AT611904300234573201");
|
Window.FindById("IbanInput").SendKeys("AT611904300234573201");
|
||||||
Window.FindById("BicInput").SendKeys("RLNWATWWWDF");
|
Window.FindById("BicInput").SendKeys("RLNWATWWWDF");
|
||||||
|
|
||||||
Window.FindById("UstIdNrInput").SendKeys("ATU66192906"); //TODO: Testdaten?
|
Window.FindById("UstIdNrInput").SendKeys("ATU66192906"); // TODO: Testdaten?
|
||||||
Window.FindById("LfbisNrInput").SendKeys("1251074"); //TODO: Testdaten?
|
Window.FindById("LfbisNrInput").SendKeys("1251074"); // TODO: Testdaten?
|
||||||
|
|
||||||
Window.FindById("BuchführendInput").Click();
|
Window.FindById("BuchführendInput").Click();
|
||||||
Window.FindById("OrganicInput").Click();
|
Window.FindById("OrganicInput").Click();
|
||||||
|
|
||||||
Window.FindById("BillingNameInput").SendKeys("Mustermann KG");
|
Window.FindById("BillingNameInput").SendKeys("Neuling KG");
|
||||||
Window.FindById("BillingAddressInput").SendKeys("Betriebsstraße 1");
|
Window.FindById("BillingAddressInput").SendKeys("Betriebsstraße 1");
|
||||||
Window.FindById("BillingPlzInput").SendKeys("2120");
|
Window.FindById("BillingPlzInput").SendKeys("2120");
|
||||||
Window.SelectComboBoxItemByCount("BillingOrtInput", 2);
|
Window.SelectComboBoxItemByCount("BillingOrtInput", 2);
|
||||||
@ -80,20 +80,20 @@ namespace Tests.E2ETests {
|
|||||||
|
|
||||||
Window.FindById("SaveButton").Click();
|
Window.FindById("SaveButton").Click();
|
||||||
|
|
||||||
Window.FindById("SearchInput").SendKeys("10003 Max Mustermann");
|
Window.FindById("SearchInput").SendKeys("9999");
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
var memberListRow = Window.FindById("MemberList").FindElementByClassName("DataGridRow");
|
var memberListRow = Window.FindById("MemberList").FindElementByClassName("DataGridRow");
|
||||||
Assert.Multiple(() => {
|
Assert.Multiple(() => {
|
||||||
Assert.That(memberListRow, Is.Not.Null);
|
Assert.That(memberListRow, Is.Not.Null);
|
||||||
Assert.That(memberListRow.FindElementByName("10003 "), Is.Not.Null);
|
Assert.That(memberListRow.FindElementByName("9999 "), Is.Not.Null);
|
||||||
Assert.That(memberListRow.FindElementByName("Max"), Is.Not.Null);
|
Assert.That(memberListRow.FindElementByName("Norbert"), Is.Not.Null);
|
||||||
Assert.That(memberListRow.FindElementByName("Mustermann"), Is.Not.Null);
|
Assert.That(memberListRow.FindElementByName("Neuling"), Is.Not.Null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Test_2_EditMember() {
|
public void Test_2_EditMember() {
|
||||||
Window!.FindById("SearchInput").SendKeys("10003 Max Mustermann");
|
Window!.FindById("SearchInput").SendKeys("9999");
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
var memberList = Window.FindById("MemberList");
|
var memberList = Window.FindById("MemberList");
|
||||||
Assert.That(memberList, Is.Not.Null);
|
Assert.That(memberList, Is.Not.Null);
|
||||||
@ -118,7 +118,7 @@ namespace Tests.E2ETests {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Test_3_DeleteMember() {
|
public void Test_3_DeleteMember() {
|
||||||
Window!.FindById("SearchInput").SendKeys("10003 Max Mustermann");
|
Window!.FindById("SearchInput").SendKeys("9999");
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
var memberList = Window.FindById("MemberList");
|
var memberList = Window.FindById("MemberList");
|
||||||
Assert.That(memberList, Is.Not.Null);
|
Assert.That(memberList, Is.Not.Null);
|
||||||
@ -129,14 +129,14 @@ namespace Tests.E2ETests {
|
|||||||
var memberListRow = memberListRows.First();
|
var memberListRow = memberListRows.First();
|
||||||
Assert.Multiple(() => {
|
Assert.Multiple(() => {
|
||||||
Assert.That(memberListRow, Is.Not.Null);
|
Assert.That(memberListRow, Is.Not.Null);
|
||||||
Assert.That(memberListRow.FindElementByName("10003 "), Is.Not.Null);
|
Assert.That(memberListRow.FindElementByName("9999 "), Is.Not.Null);
|
||||||
Assert.That(memberListRow.FindElementByName("Max"), Is.Not.Null);
|
Assert.That(memberListRow.FindElementByName("Norbert"), Is.Not.Null);
|
||||||
Assert.That(memberListRow.FindElementByName("Mustermann"), Is.Not.Null);
|
Assert.That(memberListRow.FindElementByName("Neuling"), Is.Not.Null);
|
||||||
});
|
});
|
||||||
|
|
||||||
Window.FindById("DeleteMemberButton").Click();
|
Window.FindById("DeleteMemberButton").Click();
|
||||||
var dialog = Session.CreateWindowDriver("DeleteMemberDialog");
|
var dialog = Session.CreateWindowDriver("DeleteMemberDialog");
|
||||||
dialog.FindById("NameInput").SendKeys("10003 Ing. Max Mustermann jun.");
|
dialog.FindById("NameInput").SendKeys("9999 Ing. Norbert Neuling jun.");
|
||||||
dialog.FindById("ConfirmButton").Click();
|
dialog.FindById("ConfirmButton").Click();
|
||||||
|
|
||||||
memberListRows = memberList.FindElementsByClassName("DataGridRow");
|
memberListRows = memberList.FindElementsByClassName("DataGridRow");
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
namespace Tests.E2ETests {
|
using Elwig.Helpers;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Tests.E2ETests {
|
||||||
[SetUpFixture]
|
[SetUpFixture]
|
||||||
public static class Setup {
|
public static class Setup {
|
||||||
|
|
||||||
@ -9,9 +12,25 @@
|
|||||||
Driver = new();
|
Driver = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[OneTimeSetUp]
|
||||||
|
public static async Task SetupDatabase() {
|
||||||
|
if (File.Exists(Utils.TestDatabasePath)) File.Delete(Utils.TestDatabasePath);
|
||||||
|
using var cnx = await AppDbContext.ConnectAsync($"Data Source=\"{Utils.TestDatabasePath}\"; Mode=ReadWriteCreate; Foreign Keys=True; Cache=Default");
|
||||||
|
await AppDbContext.ExecuteEmbeddedScript(cnx, Assembly.GetExecutingAssembly(), "Tests.Resources.Sql.Create.sql");
|
||||||
|
await AppDbContext.ExecuteEmbeddedScript(cnx, Assembly.GetExecutingAssembly(), "Tests.Resources.Sql.Insert.sql");
|
||||||
|
}
|
||||||
|
|
||||||
[OneTimeTearDown]
|
[OneTimeTearDown]
|
||||||
public static void TeardownWinAppDriver() {
|
public static void TeardownWinAppDriver() {
|
||||||
Driver?.Dispose();
|
Driver?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[OneTimeTearDown]
|
||||||
|
public static void TeardownDatabase() {
|
||||||
|
try {
|
||||||
|
// FIXME not working - other process using file
|
||||||
|
File.Delete(Utils.TestDatabasePath);
|
||||||
|
} catch { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@ using OpenQA.Selenium.Appium.Windows;
|
|||||||
namespace Tests.E2ETests {
|
namespace Tests.E2ETests {
|
||||||
public static class Utils {
|
public static class Utils {
|
||||||
|
|
||||||
public const string ApplicationPath = @"..\..\..\..\Elwig\bin\Debug\net8.0-windows\Elwig.exe";
|
public static readonly string ApplicationPath = Path.GetFullPath(@"..\..\..\..\Elwig\bin\Debug\net8.0-windows\Elwig.exe");
|
||||||
|
public static readonly string ConfigPath = Path.GetFullPath(@"..\..\..\..\Tests\config.test.ini");
|
||||||
|
public static readonly string TestDatabasePath = Path.GetFullPath(@"..\..\..\..\Tests\ElwigTestDB.sqlite3");
|
||||||
|
|
||||||
public static WindowsElement FindById(this WindowsDriver<WindowsElement> session, string accessibilityId) {
|
public static WindowsElement FindById(this WindowsDriver<WindowsElement> session, string accessibilityId) {
|
||||||
return session.FindElementByAccessibilityId(accessibilityId);
|
return session.FindElementByAccessibilityId(accessibilityId);
|
||||||
|
7
Tests/config.test.ini
Normal file
7
Tests/config.test.ini
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
[general]
|
||||||
|
debug = true
|
||||||
|
|
||||||
|
[database]
|
||||||
|
file = ElwigTestDB.sqlite3
|
||||||
|
|
Reference in New Issue
Block a user