diff --git a/Elwig/App.xaml.cs b/Elwig/App.xaml.cs index 343712f..012f617 100644 --- a/Elwig/App.xaml.cs +++ b/Elwig/App.xaml.cs @@ -164,7 +164,7 @@ namespace Elwig { list.Add(Scale.FromConfig(s)); } catch (Exception e) { 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", MessageBoxButton.OK, MessageBoxImage.Error); } diff --git a/Elwig/Dialogs/NewSeasonDialog.xaml b/Elwig/Dialogs/NewSeasonDialog.xaml index 1720c41..1fed465 100644 --- a/Elwig/Dialogs/NewSeasonDialog.xaml +++ b/Elwig/Dialogs/NewSeasonDialog.xaml @@ -1,4 +1,5 @@  OpenReceiptWindow() { + Session.App.FindElementByName("Übernahme").Click(); + Thread.Sleep(Utils.WINDOW_OPEN_SLEEP); + return Session.CreateWindowDriver("DeliveryAdminWindow"); + } + + private void FinishDeliveryNote(WindowsDriver 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(); + } + } +} diff --git a/Tests/E2ETests/MainWindowTest.cs b/Tests/E2ETests/MainWindowTest.cs index cfa5aa0..7224323 100644 --- a/Tests/E2ETests/MainWindowTest.cs +++ b/Tests/E2ETests/MainWindowTest.cs @@ -18,7 +18,7 @@ public void Test_Open_MemberAdminWindow() { Assert.DoesNotThrow(() => { Session.App.FindElementByName("Mitglieder").Click(); - Thread.Sleep(1500); + Thread.Sleep(Utils.WINDOW_OPEN_SLEEP); var window = Session.CreateWindowDriver("MemberAdminWindow"); Assert.That(window.Title, Is.EqualTo("Mitglieder - Elwig")); window.Close(); @@ -29,7 +29,7 @@ public void Test_Open_DeliveryAdminWindow() { Assert.DoesNotThrow(() => { Session.App.FindElementByName("Lieferungen").Click(); - Thread.Sleep(1500); + Thread.Sleep(Utils.WINDOW_OPEN_SLEEP); var window = Session.CreateWindowDriver("DeliveryAdminWindow"); Assert.That(window.Title, Is.EqualTo("Lieferungen - Elwig")); window.Close(); @@ -40,7 +40,7 @@ public void Test_Open_BaseDataWindow() { Assert.DoesNotThrow(() => { Session.App.FindElementByName("Stammdaten").Click(); - Thread.Sleep(1500); + Thread.Sleep(Utils.WINDOW_OPEN_SLEEP); var window = Session.CreateWindowDriver("BaseDataWindow"); Assert.That(window.Title, Is.EqualTo("Stammdaten - Elwig")); window.Close(); diff --git a/Tests/E2ETests/MemberAdminWindowTest.cs b/Tests/E2ETests/MemberAdminWindowTest.cs index b225939..476290d 100644 --- a/Tests/E2ETests/MemberAdminWindowTest.cs +++ b/Tests/E2ETests/MemberAdminWindowTest.cs @@ -11,7 +11,7 @@ namespace Tests.E2ETests { public void WindowSetup() { Session = new(Utils.ApplicationPath, Utils.ConfigPath, WinAppDriver.WinAppDriverUrl); Session.App.FindElementByName("Mitglieder").Click(); - Thread.Sleep(1000); + Thread.Sleep(Utils.WINDOW_OPEN_SLEEP); Window = Session.CreateWindowDriver("MemberAdminWindow"); } diff --git a/Tests/E2ETests/Setup.cs b/Tests/E2ETests/Setup.cs index 0adf3a6..86a6f9b 100644 --- a/Tests/E2ETests/Setup.cs +++ b/Tests/E2ETests/Setup.cs @@ -18,6 +18,7 @@ namespace Tests.E2ETests { 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"); + await AppDbContext.ExecuteEmbeddedScript(cnx, Assembly.GetExecutingAssembly(), "Tests.Resources.Sql.E2EInsert.sql"); } [OneTimeTearDown] diff --git a/Tests/E2ETests/Utils.cs b/Tests/E2ETests/Utils.cs index 184eff0..43af331 100644 --- a/Tests/E2ETests/Utils.cs +++ b/Tests/E2ETests/Utils.cs @@ -4,6 +4,8 @@ using OpenQA.Selenium.Appium.Windows; namespace Tests.E2ETests { 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 ConfigPath = Path.GetFullPath(@"..\..\..\..\Tests\config.test.ini"); public static readonly string TestDatabasePath = Path.GetFullPath(@"..\..\..\..\Tests\ElwigTestDB.sqlite3"); diff --git a/Tests/Resources/Sql/E2EInsert.sql b/Tests/Resources/Sql/E2EInsert.sql new file mode 100644 index 0000000..a2492aa --- /dev/null +++ b/Tests/Resources/Sql/E2EInsert.sql @@ -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); diff --git a/Tests/config.test.ini b/Tests/config.test.ini index eb7ea1a..c19858d 100644 --- a/Tests/config.test.ini +++ b/Tests/config.test.ini @@ -5,3 +5,15 @@ debug = true [database] 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 +