E2ETests: Add DeliveryAdminWindowReceiptTest
All checks were successful
Test / Run tests (push) Successful in 1m56s

This commit is contained in:
2024-07-18 23:56:23 +02:00
parent ffe0ff5508
commit dd5049faae
10 changed files with 116 additions and 5 deletions

View File

@ -164,7 +164,7 @@ namespace Elwig {
list.Add(Scale.FromConfig(s)); list.Add(Scale.FromConfig(s));
} catch (Exception e) { } catch (Exception e) {
list.Add(new InvalidScale(s.Id)); list.Add(new InvalidScale(s.Id));
if (Config.Debug || s.Required) if (s.Required)
MessageBox.Show($"Unable to create scale {s.Id}:\n\n{e.Message}", "Scale Error", MessageBox.Show($"Unable to create scale {s.Id}:\n\n{e.Message}", "Scale Error",
MessageBoxButton.OK, MessageBoxImage.Error); MessageBoxButton.OK, MessageBoxImage.Error);
} }

View File

@ -1,4 +1,5 @@
<Window x:Class="Elwig.Dialogs.NewSeasonDialog" <Window x:Class="Elwig.Dialogs.NewSeasonDialog"
AutomationProperties.AutomationId="NewSeasonDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

View File

@ -1,4 +1,5 @@
<Window x:Class="Elwig.Windows.DocumentViewerWindow" <Window x:Class="Elwig.Windows.DocumentViewerWindow"
AutomationProperties.AutomationId="DocumentViewerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

View File

@ -0,0 +1,85 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.Windows;
using Tests.WeighingTests;
namespace Tests.E2ETests {
[TestFixture]
public class DeliveryAdminWindowReceiptTest {
private MockScale Mock;
private AppSession Session;
[OneTimeSetUp]
public void Setup() {
Mock = new CommandMockScale(12345, ScaleHandlers.Handle_IT3000A) {
Weight = 3210,
};
Session = new(Utils.ApplicationPath, Utils.ConfigPath, WinAppDriver.WinAppDriverUrl);
Session.App.FindElementByName("Stammdaten").Click();
Thread.Sleep(500);
var window = Session.CreateWindowDriver("BaseDataWindow");
window.FindElementByName("Saisons").Click();
window.FindElementByName("Neu anlegen...").Click();
var dialog = Session.CreateWindowDriver("NewSeasonDialog");
dialog.FindElementByName("Bestätigen").Click();
dialog.Close();
Thread.Sleep(500);
window.Close();
}
[OneTimeTearDown]
public void Teardown() {
Session.Dispose();
Mock.Dispose();
}
private WindowsDriver<WindowsElement> OpenReceiptWindow() {
Session.App.FindElementByName("Übernahme").Click();
Thread.Sleep(Utils.WINDOW_OPEN_SLEEP);
return Session.CreateWindowDriver("DeliveryAdminWindow");
}
private void FinishDeliveryNote(WindowsDriver<WindowsElement> window) {
window.FindElementByName("Abschließen").Click();
Thread.Sleep(2000);
var doc = Session.CreateWindowDriver("DocumentViewerWindow");
Assert.That(doc.Title, Contains.Substring("Traubenübernahmeschein"));
Thread.Sleep(500);
doc.Close();
Thread.Sleep(500);
}
[Test]
public void Test_1_Minimal() {
var window = OpenReceiptWindow();
window.FindById("MgNrInput").SendKeys("101" + Keys.Enter + "GV" + Keys.Enter + "73" + Keys.Enter + Keys.Enter);
Thread.Sleep(500);
FinishDeliveryNote(window);
window.Close();
}
[Test]
public void Test_2_OtherInputs() {
var window = OpenReceiptWindow();
window.FindById("MemberInput").SendKeys("Mustermann Max");
window.SelectComboBoxItemByText("WineVarietyInput", "Zweigelt");
window.FindById("GradationKmwInput").SendKeys("18");
window.FindElementByName("Wiegen").Click();
Thread.Sleep(500);
FinishDeliveryNote(window);
window.Close();
}
[Test]
public void Test_3_AttributeCultivationModifier() {
var window = OpenReceiptWindow();
window.FindById("MgNrInput").SendKeys("102" + Keys.Enter + "GVK");
window.SelectComboBoxItemByText("CultivationInput", "Bio");
window.FindById("GradationOeInput").SendKeys("73" + Keys.Enter + Keys.Enter);
Thread.Sleep(500);
FinishDeliveryNote(window);
window.Close();
}
}
}

View File

@ -18,7 +18,7 @@
public void Test_Open_MemberAdminWindow() { public void Test_Open_MemberAdminWindow() {
Assert.DoesNotThrow(() => { Assert.DoesNotThrow(() => {
Session.App.FindElementByName("Mitglieder").Click(); Session.App.FindElementByName("Mitglieder").Click();
Thread.Sleep(1500); Thread.Sleep(Utils.WINDOW_OPEN_SLEEP);
var window = Session.CreateWindowDriver("MemberAdminWindow"); var window = Session.CreateWindowDriver("MemberAdminWindow");
Assert.That(window.Title, Is.EqualTo("Mitglieder - Elwig")); Assert.That(window.Title, Is.EqualTo("Mitglieder - Elwig"));
window.Close(); window.Close();
@ -29,7 +29,7 @@
public void Test_Open_DeliveryAdminWindow() { public void Test_Open_DeliveryAdminWindow() {
Assert.DoesNotThrow(() => { Assert.DoesNotThrow(() => {
Session.App.FindElementByName("Lieferungen").Click(); Session.App.FindElementByName("Lieferungen").Click();
Thread.Sleep(1500); Thread.Sleep(Utils.WINDOW_OPEN_SLEEP);
var window = Session.CreateWindowDriver("DeliveryAdminWindow"); var window = Session.CreateWindowDriver("DeliveryAdminWindow");
Assert.That(window.Title, Is.EqualTo("Lieferungen - Elwig")); Assert.That(window.Title, Is.EqualTo("Lieferungen - Elwig"));
window.Close(); window.Close();
@ -40,7 +40,7 @@
public void Test_Open_BaseDataWindow() { public void Test_Open_BaseDataWindow() {
Assert.DoesNotThrow(() => { Assert.DoesNotThrow(() => {
Session.App.FindElementByName("Stammdaten").Click(); Session.App.FindElementByName("Stammdaten").Click();
Thread.Sleep(1500); Thread.Sleep(Utils.WINDOW_OPEN_SLEEP);
var window = Session.CreateWindowDriver("BaseDataWindow"); var window = Session.CreateWindowDriver("BaseDataWindow");
Assert.That(window.Title, Is.EqualTo("Stammdaten - Elwig")); Assert.That(window.Title, Is.EqualTo("Stammdaten - Elwig"));
window.Close(); window.Close();

View File

@ -11,7 +11,7 @@ namespace Tests.E2ETests {
public void WindowSetup() { public void WindowSetup() {
Session = new(Utils.ApplicationPath, Utils.ConfigPath, 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(Utils.WINDOW_OPEN_SLEEP);
Window = Session.CreateWindowDriver("MemberAdminWindow"); Window = Session.CreateWindowDriver("MemberAdminWindow");
} }

View File

@ -18,6 +18,7 @@ namespace Tests.E2ETests {
using var cnx = await AppDbContext.ConnectAsync($"Data Source=\"{Utils.TestDatabasePath}\"; Mode=ReadWriteCreate; Foreign Keys=True; Cache=Default"); 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.Create.sql");
await AppDbContext.ExecuteEmbeddedScript(cnx, Assembly.GetExecutingAssembly(), "Tests.Resources.Sql.Insert.sql"); await AppDbContext.ExecuteEmbeddedScript(cnx, Assembly.GetExecutingAssembly(), "Tests.Resources.Sql.Insert.sql");
await AppDbContext.ExecuteEmbeddedScript(cnx, Assembly.GetExecutingAssembly(), "Tests.Resources.Sql.E2EInsert.sql");
} }
[OneTimeTearDown] [OneTimeTearDown]

View File

@ -4,6 +4,8 @@ using OpenQA.Selenium.Appium.Windows;
namespace Tests.E2ETests { namespace Tests.E2ETests {
public static class Utils { public static class Utils {
public const int WINDOW_OPEN_SLEEP = 2000;
public static readonly string ApplicationPath = Path.GetFullPath(@"..\..\..\..\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 ConfigPath = Path.GetFullPath(@"..\..\..\..\Tests\config.test.ini");
public static readonly string TestDatabasePath = Path.GetFullPath(@"..\..\..\..\Tests\ElwigTestDB.sqlite3"); public static readonly string TestDatabasePath = Path.GetFullPath(@"..\..\..\..\Tests\ElwigTestDB.sqlite3");

View File

@ -0,0 +1,9 @@
-- inserts for E2ETests
INSERT INTO wine_cultivation (cultid, name, description) VALUES
('KIP', 'KIP', 'Kontrollierte Integrierte Produktion'),
('B', 'Bio', 'AT-BIO-302');
INSERT INTO wine_attribute (attrid, name, active, max_kg_per_ha, strict, fill_lower) VALUES
('K', 'Kabinett', TRUE, NULL, FALSE, 0),
('D', 'DAC', TRUE, 7500, FALSE, 0);

View File

@ -5,3 +5,15 @@ debug = true
[database] [database]
file = ElwigTestDB.sqlite3 file = ElwigTestDB.sqlite3
[scale.1]
type = SysTec-IT
model = IT3000A
connection = tcp://127.0.0.1:12345
required = false
[scale.2]
type = Avery-Async
model = L320
connection = tcp://127.0.0.1:12346
required = false