From 755f79bba24f843787f4582d329322a6ddaab973 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Wed, 22 Jan 2025 17:31:31 +0300 Subject: [PATCH 01/32] Add test scenarios and locators for ContactMomentSearch Added necessary using directives in ContactMomentSearchScenarios.cs and Locators.cs. Introduced a new namespace Kiss.Bff.EndToEndTest.ContactMomentSearch.Helpers in Locators.cs. Created ContactMomentSearchScenarios class inheriting from KissPlaywrightTest with two placeholder test methods: SearchByLastNameAndDOB_ValidAsync and SearchByLastNameAndDOB_NotFound. Added Locators static class with methods to retrieve various input fields and elements on a page. --- .../ContactMomentSearchScenarios.cs | 32 ++++++++++ .../ContactMomentSearch/Helpers/Locators.cs | 63 +++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs create mode 100644 Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs new file mode 100644 index 000000000..b024590a0 --- /dev/null +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Kiss.Bff.EndToEndTest.ContactMomentSearch.Helpers; + +namespace Kiss.Bff.EndToEndTest.ContactMomentSearch +{ + [TestClass] + public class ContactMomentSearchScenarios : KissPlaywrightTest + { + #region Test Cases + + // 1. Searching by Last Name and Date of Birth (Valid) + [TestMethod] + public async Task SearchByLastNameAndDOB_ValidAsync() + { + + + } + + // 2. Searching by Last Name and Date of Birth (Not Found) + [TestMethod] + public async Task SearchByLastNameAndDOB_NotFound() + { + + } + + #endregion + } +} diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs new file mode 100644 index 000000000..40dbb9245 --- /dev/null +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Kiss.Bff.EndToEndTest.ContactMomentSearch.Helpers +{ + internal static class Locators + { + // Get the Last Name input field + public static ILocator GetLastNameInputAsync(this IPage page) + { + return page.GetByRole(AriaRole.Textbox, new() { Name = "achternaam" }); + } + + // Get the Date of Birth input field + public static ILocator GetDOBInputAsync(this IPage page) + { + return page.GetByRole(AriaRole.Textbox, new() { Name = "geboortedatum" }); + } + + // Get the BSN input field + public static ILocator GetBSNInputAsync(this IPage page) + { + return page.GetByRole(AriaRole.Textbox, new() { Name = "bsn" }); + } + + // Get the Postcode input field + public static ILocator GetPostcodeInputAsync(this IPage page) + { + return page.GetByRole(AriaRole.Textbox, new() { Name = "postcode" }); + } + + // Get the Huisnummer input field + public static ILocator GetHuisnummerInputAsync(this IPage page) + { + return page.GetByRole(AriaRole.Textbox, new() { Name = "huisnummer" }); + } + + // Get the Search button + public static ILocator GetSearchButtonAsync(this IPage page) + { + return page.GetByRole(AriaRole.Button, new() { Name = "searchButton" }); + } + + // Get the error message element + public static ILocator GetErrorMessageAsync(this IPage page) + { + return page.GetByRole(AriaRole.Alert); + } + + // Get all the results list items + public static ILocator GetResultsListAsync(this IPage page) + { + return page.GetByRole(AriaRole.Listitem); + } + + } + + + } + From 455e00209ec0e3788563b0cfeb39c170b8065e76 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Wed, 22 Jan 2025 17:36:10 +0300 Subject: [PATCH 02/32] Rename variable 'nieuw' to 'nieuws' for consistency Updated variable name in NieuwsEnWerkInstructiesScenarios.cs: - Clicking on the arrow button of the 'nieuwsbericht'. - Verifying the news detail screen by checking the '#titel' locator. - Filling the search input with the title of the 'nieuwsbericht'. --- .../NieuwsEnWerkInstructiesScenarios.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies/NieuwsEnWerkInstructiesScenarios.cs b/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies/NieuwsEnWerkInstructiesScenarios.cs index 887f76ea7..e9dc17beb 100644 --- a/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies/NieuwsEnWerkInstructiesScenarios.cs +++ b/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies/NieuwsEnWerkInstructiesScenarios.cs @@ -756,11 +756,11 @@ public async Task Scenario23() await Step("And the user has clicked on the arrow button of the nieuwsbericht"); - await Page.GetBeheerRowByValue(nieuw.Title).GetByRole(AriaRole.Link).ClickAsync(); + await Page.GetBeheerRowByValue(nieuws.Title).GetByRole(AriaRole.Link).ClickAsync(); await Step("And the news detail screen is displayed"); - await Expect(Page.Locator("#titel")).ToHaveValueAsync(nieuw.Title); + await Expect(Page.Locator("#titel")).ToHaveValueAsync(nieuws.Title); await Expect(Page.GetByText("Nieuws", new() { Exact = true })).ToBeCheckedAsync(); await Expect(Page.GetByRole(AriaRole.Checkbox, new() { Name = skill.Naam })).ToBeCheckedAsync(); @@ -783,7 +783,7 @@ public async Task Scenario23() await Page.GotoAsync("/"); await Step("And navigates to the page containing the nieuwsbericht selected earlier"); - await Page.GetNieuwsAndWerkinstructiesSearch().FillAsync(nieuw.Title); + await Page.GetNieuwsAndWerkinstructiesSearch().FillAsync(nieuws.Title); await Page.GetNieuwsAndWerkinstructiesSearch().PressAsync("Enter"); await Step("Then the nieuwsbericht should be displayed with the ‘belangrijk’ flag"); From 17157211c39509dbc0c60d36295c2b61304e1e16 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Wed, 22 Jan 2025 23:25:10 +0300 Subject: [PATCH 03/32] Update ContactMomentSearch tests with detailed steps Updated the namespace in ContactMomentSearchScenarios.cs. Modified [TestMethod] attributes to include descriptions. Renamed and enhanced test methods with detailed steps: - SearchByLastNameAndDOB_Valid to SearchByLastNameAndDOB_ValidAsync * Added steps: start contact moment, perform search, verify navigation. - SearchByLastNameAndDOB_NotFound to SearchByLastNameAndDOB_NotFoundAsync * Added steps: start contact moment, perform search, check error message. --- .../ContactMomentSearchScenarios.cs | 44 ++++++++++++++++--- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index b024590a0..e6ebe6ec7 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -12,19 +12,49 @@ public class ContactMomentSearchScenarios : KissPlaywrightTest { #region Test Cases - // 1. Searching by Last Name and Date of Birth (Valid) - [TestMethod] + [TestMethod("1. Searching by Last Name and Date of Birth (Valid)")] public async Task SearchByLastNameAndDOB_ValidAsync() { + await Step("When user starts a new contactmoment"); + await Page.GetByRole(AriaRole.Button, new() { Name = "Nieuw contactmoment" }).ClickAsync(); + await Step("Perform the search"); + + var searchButton = Page.Locator("form").Filter(new() { HasText = "Achternaam Geboortedatum" }).GetByRole(AriaRole.Button); + await Page.GetByRole(AriaRole.Textbox, new() { Name = "Achternaam" }).FillAsync("Burck"); + await Page.GetByLabel("Geboortedatum").FillAsync("17-11-1952"); + await searchButton.ClickAsync(); + + await Step("Verify navigation to the Persoonsinformatie page"); + + await Page.WaitForNavigationAsync(); + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Persoonsinformatie" })).ToHaveTextAsync("Persoonsinformatie"); + } - // 2. Searching by Last Name and Date of Birth (Not Found) - [TestMethod] - public async Task SearchByLastNameAndDOB_NotFound() - { - + + [TestMethod("2. Searching by Last Name and Date of Birth (Not Found)")] + public async Task SearchByLastNameAndDOB_NotFoundAsync() + { + + await Step("When user starts a new contactmoment"); + + await Page.GetByRole(AriaRole.Button, new() { Name = "Nieuw contactmoment" }).ClickAsync(); + + await Step("Perform the search"); + + var searchButton = Page.Locator("form").Filter(new() { HasText = "Achternaam Geboortedatum" }).GetByRole(AriaRole.Button); + await Page.GetByRole(AriaRole.Textbox, new() { Name = "Achternaam" }).FillAsync("TestDB"); + await Page.GetByLabel("Geboortedatum").FillAsync("11-12-1990"); + await searchButton.ClickAsync(); + + await Step("Check for the error message"); + + await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor 'TestDB, 11-12-1990'."); + + + } #endregion From c14557e9daed3d814ce5d1b8840ab54a625a0531 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Thu, 23 Jan 2025 17:00:37 +0300 Subject: [PATCH 04/32] Refactor and update ContactMomentSearch tests Refactored test methods and helper methods in the `Kiss.Bff.EndToEndTest.ContactMomentSearch` namespace for improved readability and maintainability. - Updated `SearchByLastNameAndDOB_ValidAsync` and `SearchByLastNameAndDOB_NotFoundAsync` in `ContactMomentSearchScenarios.cs`: - Navigation to the contact moment page is now handled by `NavigateToContactMomentAsync`. - Search input fields and search button are accessed using new helper methods `Personen_LastNameInput`, `Personen_BirthDateInput`, and `PersonenFirst_SearchButton`. - Removed redundant `WaitForNavigationAsync` call in `SearchByLastNameAndDOB_ValidAsync`. - Refactored locator methods in `Locators.cs`: - Removed old locator methods for various input fields and buttons. - Added new locator methods `Personen_LastNameInput`, `Personen_BirthDateInput`, and `PersonenFirst_SearchButton`. - Added new file `Navigation.cs`: - Contains a new static class `Navigation` with a method `NavigateToContactMomentAsync` to handle navigation to the contact moment page. --- .../ContactMomentSearchScenarios.cs | 23 +++----- .../ContactMomentSearch/Helpers/Locators.cs | 58 ++++--------------- .../ContactMomentSearch/Helpers/Navigation.cs | 12 ++++ 3 files changed, 31 insertions(+), 62 deletions(-) create mode 100644 Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Navigation.cs diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index e6ebe6ec7..f26ba74a5 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -17,18 +17,16 @@ public async Task SearchByLastNameAndDOB_ValidAsync() { await Step("When user starts a new contactmoment"); - await Page.GetByRole(AriaRole.Button, new() { Name = "Nieuw contactmoment" }).ClickAsync(); + await Page.NavigateToContactMomentAsync(); await Step("Perform the search"); - - var searchButton = Page.Locator("form").Filter(new() { HasText = "Achternaam Geboortedatum" }).GetByRole(AriaRole.Button); - await Page.GetByRole(AriaRole.Textbox, new() { Name = "Achternaam" }).FillAsync("Burck"); - await Page.GetByLabel("Geboortedatum").FillAsync("17-11-1952"); - await searchButton.ClickAsync(); + await Page.Personen_LastNameInput().FillAsync("Burck"); + await Page.Personen_BirthDateInput().FillAsync("17-11-1952"); + await Page.PersonenFirst_SearchButton().ClickAsync(); + await Step("Verify navigation to the Persoonsinformatie page"); - await Page.WaitForNavigationAsync(); await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Persoonsinformatie" })).ToHaveTextAsync("Persoonsinformatie"); } @@ -40,21 +38,18 @@ public async Task SearchByLastNameAndDOB_NotFoundAsync() await Step("When user starts a new contactmoment"); - await Page.GetByRole(AriaRole.Button, new() { Name = "Nieuw contactmoment" }).ClickAsync(); + await Page.NavigateToContactMomentAsync(); await Step("Perform the search"); - var searchButton = Page.Locator("form").Filter(new() { HasText = "Achternaam Geboortedatum" }).GetByRole(AriaRole.Button); - await Page.GetByRole(AriaRole.Textbox, new() { Name = "Achternaam" }).FillAsync("TestDB"); - await Page.GetByLabel("Geboortedatum").FillAsync("11-12-1990"); - await searchButton.ClickAsync(); + await Page.Personen_LastNameInput().FillAsync("TestDB"); + await Page.Personen_BirthDateInput().FillAsync("11-12-1990"); + await Page.PersonenFirst_SearchButton().ClickAsync(); await Step("Check for the error message"); await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor 'TestDB, 11-12-1990'."); - - } #endregion diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index 40dbb9245..4b123884c 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -8,56 +8,18 @@ namespace Kiss.Bff.EndToEndTest.ContactMomentSearch.Helpers { internal static class Locators { - // Get the Last Name input field - public static ILocator GetLastNameInputAsync(this IPage page) - { - return page.GetByRole(AriaRole.Textbox, new() { Name = "achternaam" }); - } + public static ILocator Personen_LastNameInput(this IPage page) => + page.GetByRole(AriaRole.Textbox, new() { Name = "Achternaam" }); - // Get the Date of Birth input field - public static ILocator GetDOBInputAsync(this IPage page) - { - return page.GetByRole(AriaRole.Textbox, new() { Name = "geboortedatum" }); - } - - // Get the BSN input field - public static ILocator GetBSNInputAsync(this IPage page) - { - return page.GetByRole(AriaRole.Textbox, new() { Name = "bsn" }); - } - - // Get the Postcode input field - public static ILocator GetPostcodeInputAsync(this IPage page) - { - return page.GetByRole(AriaRole.Textbox, new() { Name = "postcode" }); - } - - // Get the Huisnummer input field - public static ILocator GetHuisnummerInputAsync(this IPage page) - { - return page.GetByRole(AriaRole.Textbox, new() { Name = "huisnummer" }); - } - - // Get the Search button - public static ILocator GetSearchButtonAsync(this IPage page) - { - return page.GetByRole(AriaRole.Button, new() { Name = "searchButton" }); - } - - // Get the error message element - public static ILocator GetErrorMessageAsync(this IPage page) - { - return page.GetByRole(AriaRole.Alert); - } - - // Get all the results list items - public static ILocator GetResultsListAsync(this IPage page) - { - return page.GetByRole(AriaRole.Listitem); - } + public static ILocator Personen_BirthDateInput(this IPage page) => + page.GetByRole(AriaRole.Textbox, new() { Name = "Geboortedatum" }); + public static ILocator PersonenFirst_SearchButton(this IPage page) => + page.Locator("form").Filter(new () { HasText = "Achternaam Geboortedatum" }).GetByRole(AriaRole.Button); + + } - - } + +} diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Navigation.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Navigation.cs new file mode 100644 index 000000000..3cdf93fcd --- /dev/null +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Navigation.cs @@ -0,0 +1,12 @@ +namespace Kiss.Bff.EndToEndTest.ContactMomentSearch.Helpers +{ + internal static class Navigation + { + + public static async Task NavigateToContactMomentAsync(this IPage page) + { + await page.GetByRole(AriaRole.Button, new() { Name = "Nieuw contactmoment" }).ClickAsync(); + + } + } +} From f2e6e24e5475ef8786acb7daa1fdb50b69795276 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Thu, 23 Jan 2025 17:03:46 +0300 Subject: [PATCH 05/32] removed redundant locators --- .../ContactMomentSearch/Helpers/Locators.cs | 49 +------------------ 1 file changed, 1 insertion(+), 48 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index 40dbb9245..82ddbcf1c 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -8,54 +8,7 @@ namespace Kiss.Bff.EndToEndTest.ContactMomentSearch.Helpers { internal static class Locators { - // Get the Last Name input field - public static ILocator GetLastNameInputAsync(this IPage page) - { - return page.GetByRole(AriaRole.Textbox, new() { Name = "achternaam" }); - } - - // Get the Date of Birth input field - public static ILocator GetDOBInputAsync(this IPage page) - { - return page.GetByRole(AriaRole.Textbox, new() { Name = "geboortedatum" }); - } - - // Get the BSN input field - public static ILocator GetBSNInputAsync(this IPage page) - { - return page.GetByRole(AriaRole.Textbox, new() { Name = "bsn" }); - } - - // Get the Postcode input field - public static ILocator GetPostcodeInputAsync(this IPage page) - { - return page.GetByRole(AriaRole.Textbox, new() { Name = "postcode" }); - } - - // Get the Huisnummer input field - public static ILocator GetHuisnummerInputAsync(this IPage page) - { - return page.GetByRole(AriaRole.Textbox, new() { Name = "huisnummer" }); - } - - // Get the Search button - public static ILocator GetSearchButtonAsync(this IPage page) - { - return page.GetByRole(AriaRole.Button, new() { Name = "searchButton" }); - } - - // Get the error message element - public static ILocator GetErrorMessageAsync(this IPage page) - { - return page.GetByRole(AriaRole.Alert); - } - - // Get all the results list items - public static ILocator GetResultsListAsync(this IPage page) - { - return page.GetByRole(AriaRole.Listitem); - } - + } From 66ab0b56dd945e37bf518a147b195f8628abd704 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Mon, 27 Jan 2025 20:09:38 +0300 Subject: [PATCH 06/32] Add BSN search tests and new locator for search button Added new test methods `SearchByBSN_Valid` and `SearchByBSN_Invalid` in `ContactMomentSearchScenarios.cs` to verify search functionality with valid and invalid BSNs, respectively. Updated `Locators.cs` to include `PersonenThird_SearchButton` for locating the search button in the BSN search form. --- .../ContactMomentSearchScenarios.cs | 43 +++++++++++++++++++ .../ContactMomentSearch/Helpers/Locators.cs | 9 ++-- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index f26ba74a5..d9fbd4dbe 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -51,6 +51,49 @@ public async Task SearchByLastNameAndDOB_NotFoundAsync() await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor 'TestDB, 11-12-1990'."); } + + [TestMethod("3. Searching by BSN (Valid)")] + public async Task SearchByBSN_Valid() + { + await Step("When user starts a new contactmoment"); + + await Page.NavigateToContactMomentAsync(); + + + await Step(" Perform the search with a valid BSN"); + + var bsnInput = Page.GetByRole(AriaRole.Textbox, new() { Name = "bsn" }); + + await bsnInput.FillAsync("999992223"); + await Page.PersonenThird_SearchButton().ClickAsync(); + + await Step("Verify navigation to the Persoonsinformatie page"); + + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Persoonsinformatie" })).ToHaveTextAsync("Persoonsinformatie"); + + } + + + [TestMethod(" 4. Searching by BSN (Invalid)")] + public async Task SearchByBSN_Invalid() + { + await Step("When user starts a new contactmoment"); + + await Page.NavigateToContactMomentAsync(); + + await Step(" Perform the search with a valid BSN"); + + var bsnInput = Page.GetByRole(AriaRole.Textbox, new() { Name = "bsn" }); + + await bsnInput.FillAsync("123456789"); + + await Page.PersonenThird_SearchButton().ClickAsync(); + + await Step("Check for the error message"); + + Assert.AreEqual( await bsnInput.EvaluateAsync("(el) => el.validationMessage"), "Dit is geen valide BSN."); + + } #endregion } diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index 2a33b2f4d..f49b257d5 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -17,9 +17,12 @@ public static ILocator Personen_BirthDateInput(this IPage page) => public static ILocator PersonenFirst_SearchButton(this IPage page) => page.Locator("form").Filter(new () { HasText = "Achternaam Geboortedatum" }).GetByRole(AriaRole.Button); - - } - + public static ILocator PersonenThird_SearchButton(this IPage page) => + page.Locator("form").Filter(new() { HasText = "Bsn Zoeken" }).GetByRole(AriaRole.Button); + + } + + } From 33a920399e9a7c6147cc58a15f84a1c3ae495236 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Tue, 28 Jan 2025 12:07:39 +0300 Subject: [PATCH 07/32] Refactor locators to use ARIA roles for form elements Updated `PersonenFirst_SearchButton` and `PersonenThird_SearchButton` methods in `Locators.cs` to use `page.GetByRole(AriaRole.Form)` instead of `page.Locator("form")`. This change enhances the accuracy and readability of locating form elements by leveraging ARIA roles. --- Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index f49b257d5..80742871a 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -16,10 +16,10 @@ public static ILocator Personen_BirthDateInput(this IPage page) => page.GetByRole(AriaRole.Textbox, new() { Name = "Geboortedatum" }); public static ILocator PersonenFirst_SearchButton(this IPage page) => - page.Locator("form").Filter(new () { HasText = "Achternaam Geboortedatum" }).GetByRole(AriaRole.Button); + page.GetByRole(AriaRole.Form).Filter(new () { HasText = "Achternaam Geboortedatum" }).GetByRole(AriaRole.Button); public static ILocator PersonenThird_SearchButton(this IPage page) => - page.Locator("form").Filter(new() { HasText = "Bsn Zoeken" }).GetByRole(AriaRole.Button); + page.GetByRole(AriaRole.Form).Filter(new() { HasText = "Bsn Zoeken" }).GetByRole(AriaRole.Button); } From 92b68819ed24dfe6a73a720b9bf13494a2c66fa0 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Tue, 28 Jan 2025 12:09:17 +0300 Subject: [PATCH 08/32] Refactor form locator to use ARIA role Updated the method `PersonenFirst_SearchButton` to use `page.GetByRole(AriaRole.Form)` instead of `page.Locator("form")` for locating the form element. This change improves the specificity and clarity of the form selection process by leveraging ARIA roles. --- Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index 2a33b2f4d..bae6eac08 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -16,7 +16,7 @@ public static ILocator Personen_BirthDateInput(this IPage page) => page.GetByRole(AriaRole.Textbox, new() { Name = "Geboortedatum" }); public static ILocator PersonenFirst_SearchButton(this IPage page) => - page.Locator("form").Filter(new () { HasText = "Achternaam Geboortedatum" }).GetByRole(AriaRole.Button); + page.GetByRole(AriaRole.Form).Filter(new () { HasText = "Achternaam Geboortedatum" }).GetByRole(AriaRole.Button); } From ba99f6e65dffbc365d314fd1fedb3dbf734e5b07 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Tue, 28 Jan 2025 12:34:37 +0300 Subject: [PATCH 09/32] Refactor search button locator in PersonenFirst_SearchButton Modified PersonenFirst_SearchButton to use page.Locator("form") instead of page.GetByRole(AriaRole.Form) for locating the search button within a form that has the text "Achternaam Geboortedatum". --- Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index bae6eac08..3bb5a14e4 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -16,7 +16,7 @@ public static ILocator Personen_BirthDateInput(this IPage page) => page.GetByRole(AriaRole.Textbox, new() { Name = "Geboortedatum" }); public static ILocator PersonenFirst_SearchButton(this IPage page) => - page.GetByRole(AriaRole.Form).Filter(new () { HasText = "Achternaam Geboortedatum" }).GetByRole(AriaRole.Button); + page.Locator("form").Filter(new () { HasText = "Achternaam Geboortedatum" }).GetByRole(AriaRole.Button); } From 759c6b6c343147486fecda07f5e1895d80c1e993 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Tue, 28 Jan 2025 14:45:14 +0300 Subject: [PATCH 10/32] Refactor test methods and add ManageContactmoment helper Updated test methods in ContactMomentSearchScenarios.cs to reflect changes in user flow, including renaming steps and methods for clarity. Added ManageContactmoment helper class with CreateNewContactmomentAsync method. Removed obsolete NavigateToContactMomentAsync method from Navigation.cs. --- .../ContactMomentSearchScenarios.cs | 14 +++++++------- .../Helpers/ManageContactmoment.cs | 16 ++++++++++++++++ .../ContactMomentSearch/Helpers/Navigation.cs | 6 +----- 3 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/ManageContactmoment.cs diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index f26ba74a5..5388eed77 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -15,11 +15,11 @@ public class ContactMomentSearchScenarios : KissPlaywrightTest [TestMethod("1. Searching by Last Name and Date of Birth (Valid)")] public async Task SearchByLastNameAndDOB_ValidAsync() { - await Step("When user starts a new contactmoment"); + await Step("Given the user is on the startpagina"); - await Page.NavigateToContactMomentAsync(); + await Page.CreateNewContactmomentAsync(); - await Step("Perform the search"); + await Step("User fills Lastname and Birthday and perform search"); await Page.Personen_LastNameInput().FillAsync("Burck"); await Page.Personen_BirthDateInput().FillAsync("17-11-1952"); @@ -36,17 +36,17 @@ public async Task SearchByLastNameAndDOB_ValidAsync() public async Task SearchByLastNameAndDOB_NotFoundAsync() { - await Step("When user starts a new contactmoment"); + await Step("Given the user is on the startpagina "); - await Page.NavigateToContactMomentAsync(); + await Page.CreateNewContactmomentAsync(); - await Step("Perform the search"); + await Step("User fills Lastname and Birthday and perform search"); await Page.Personen_LastNameInput().FillAsync("TestDB"); await Page.Personen_BirthDateInput().FillAsync("11-12-1990"); await Page.PersonenFirst_SearchButton().ClickAsync(); - await Step("Check for the error message"); + await Step("The message is displayed as “Geen resultaten gevonden voor ’TestDB, 11-12-1990"); await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor 'TestDB, 11-12-1990'."); diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/ManageContactmoment.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/ManageContactmoment.cs new file mode 100644 index 000000000..5e9f52ca8 --- /dev/null +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/ManageContactmoment.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Kiss.Bff.EndToEndTest.ContactMomentSearch.Helpers +{ + internal static class ManageContactmoment + { + public static async Task CreateNewContactmomentAsync(this IPage page) + { + await page.GetByRole(AriaRole.Button, new() { Name = "Nieuw contactmoment" }).ClickAsync(); + } + } +} diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Navigation.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Navigation.cs index 3cdf93fcd..49d06855d 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Navigation.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Navigation.cs @@ -3,10 +3,6 @@ internal static class Navigation { - public static async Task NavigateToContactMomentAsync(this IPage page) - { - await page.GetByRole(AriaRole.Button, new() { Name = "Nieuw contactmoment" }).ClickAsync(); - - } + } } From e577692b27e2c07edaf92ed9497ce7b0c60d4686 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Tue, 28 Jan 2025 15:30:24 +0300 Subject: [PATCH 11/32] Update test methods in ContactMomentSearchScenarios.cs Updated step descriptions and method names in `SearchByBSN_Valid` and `SearchByBSN_Invalid` to reflect new user starting point and improve clarity. Adjusted assertion in `SearchByBSN_Invalid` to check for specific error message "Dit is geen valide BSN." --- .../ContactMomentSearchScenarios.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index bbcf873b1..6b3e1c2a4 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -55,10 +55,9 @@ public async Task SearchByLastNameAndDOB_NotFoundAsync() [TestMethod("3. Searching by BSN (Valid)")] public async Task SearchByBSN_Valid() { - await Step("When user starts a new contactmoment"); - - await Page.NavigateToContactMomentAsync(); + await Step("Given the user is on the startpagina "); + await Page.CreateNewContactmomentAsync(); await Step(" Perform the search with a valid BSN"); @@ -77,11 +76,11 @@ public async Task SearchByBSN_Valid() [TestMethod(" 4. Searching by BSN (Invalid)")] public async Task SearchByBSN_Invalid() { - await Step("When user starts a new contactmoment"); + await Step("Given the user is on the startpagina "); - await Page.NavigateToContactMomentAsync(); + await Page.CreateNewContactmomentAsync(); - await Step(" Perform the search with a valid BSN"); + await Step(" Perform the search with a invalid BSN"); var bsnInput = Page.GetByRole(AriaRole.Textbox, new() { Name = "bsn" }); @@ -89,7 +88,7 @@ public async Task SearchByBSN_Invalid() await Page.PersonenThird_SearchButton().ClickAsync(); - await Step("Check for the error message"); + await Step("The message is displayed as “Dit is geen valide BSN"); Assert.AreEqual( await bsnInput.EvaluateAsync("(el) => el.validationMessage"), "Dit is geen valide BSN."); From 1b0c5a543056320f2b5e90a862dd3c19b1e49631 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Fri, 31 Jan 2025 11:48:05 +0300 Subject: [PATCH 12/32] Add new test methods and locators for search scenarios Introduced new test methods in ContactMomentSearchScenarios.cs: - Verify navigation to "Persoonsinformatie" page after search. - Handle searches by last name and DOB, BSN, postcode, and house number. - Check for valid and not found cases. Added new locators in Locators.cs to support search functionalities: - PersonenSecond_SearchButton, Personen_PostCodeInput, and Personen_HuisnummerInput. - Methods to locate table rows by column value and address lines. - Asynchronous method to search address table by column value. --- .../ContactMomentSearchScenarios.cs | 66 ++++++++++++++++--- .../ContactMomentSearch/Helpers/Locators.cs | 39 ++++++++++- 2 files changed, 95 insertions(+), 10 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index 6b3e1c2a4..32436dd3e 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -24,14 +24,14 @@ public async Task SearchByLastNameAndDOB_ValidAsync() await Page.Personen_LastNameInput().FillAsync("Burck"); await Page.Personen_BirthDateInput().FillAsync("17-11-1952"); await Page.PersonenFirst_SearchButton().ClickAsync(); - + await Step("Verify navigation to the Persoonsinformatie page"); await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Persoonsinformatie" })).ToHaveTextAsync("Persoonsinformatie"); - + } - + [TestMethod("2. Searching by Last Name and Date of Birth (Not Found)")] public async Task SearchByLastNameAndDOB_NotFoundAsync() { @@ -47,11 +47,11 @@ public async Task SearchByLastNameAndDOB_NotFoundAsync() await Page.PersonenFirst_SearchButton().ClickAsync(); await Step("The message is displayed as “Geen resultaten gevonden voor ’TestDB, 11-12-1990"); - - await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor 'TestDB, 11-12-1990'."); + + await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor 'TestDB, 11-12-1990'."); } - + [TestMethod("3. Searching by BSN (Valid)")] public async Task SearchByBSN_Valid() { @@ -89,10 +89,58 @@ public async Task SearchByBSN_Invalid() await Page.PersonenThird_SearchButton().ClickAsync(); await Step("The message is displayed as “Dit is geen valide BSN"); - - Assert.AreEqual( await bsnInput.EvaluateAsync("(el) => el.validationMessage"), "Dit is geen valide BSN."); - } + Assert.AreEqual(await bsnInput.EvaluateAsync("(el) => el.validationMessage"), "Dit is geen valide BSN."); + + } + + + [TestMethod("5. Searching by Postcode and Huisnummer (Valid)")] + public async Task SearchByPostcodeAndHuisnummer_Valid() + { + await Step("Given the user is on the startpagina "); + + await Page.CreateNewContactmomentAsync(); + + await Step("Perform the search with valid postcode and huisnummer"); + + var postCode = "3544 NG"; + var huisNummer = "10"; + + await Page.Personen_PostCodeInput().FillAsync(postCode); + await Page.Personen_HuisnummerInput().FillAsync(huisNummer); + await Page.PersonenSecond_SearchButton().ClickAsync(); + + + await Step("Verify that multiple results are displayed in the table"); + + var rowByAddressLine1 = await Page.SearchAddressTableByColumn(huisNummer, 3); + var rowByPostcode = await Page.SearchAddressTableByColumn(postCode, 4); + + Assert.IsTrue(await rowByPostcode.CountAsync() > 1); + Assert.IsTrue(await rowByAddressLine1.CountAsync() > 1); + } + + + [TestMethod("6. Searching by Postcode and Huisnummer (Not Found)")] + public async Task SearchByPostcodeAndHuisnummer_NotFound() + { + await Step("Given the user is on the startpagina"); + + await Page.CreateNewContactmomentAsync(); + + await Step(" Perform the search with non-existent data"); + + await Page.Personen_PostCodeInput().FillAsync("3544 NG"); + await Page.Personen_HuisnummerInput().FillAsync("11"); + await Page.PersonenSecond_SearchButton().ClickAsync(); + + await Step("Check for the error message"); + + await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor '3544NG, 11'."); + + + } #endregion } diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index 0030ad023..e50b994e2 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -17,10 +17,47 @@ public static ILocator Personen_BirthDateInput(this IPage page) => public static ILocator PersonenFirst_SearchButton(this IPage page) => page.Locator("form").Filter(new () { HasText = "Achternaam Geboortedatum" }).GetByRole(AriaRole.Button); - + public static ILocator PersonenSecond_SearchButton(this IPage page) => + page.Locator("form").Filter(new() { HasText = "Postcode Huisnummer" }).GetByRole(AriaRole.Button); + public static ILocator PersonenThird_SearchButton(this IPage page) => page.Locator("form").Filter(new() { HasText = "Bsn Zoeken" }).GetByRole(AriaRole.Button); + public static ILocator Personen_PostCodeInput(this IPage page) => + page.GetByRole(AriaRole.Textbox, new() { Name = "postcode" }); + public static ILocator Personen_HuisnummerInput(this IPage page) => + page.GetByRole(AriaRole.Textbox, new() { Name = "huisnummer" }); + + + + + public static ILocator GetTableRowByColumnValue(this IPage page, int columnIndex, string value, int tableIndex = 0) + { + var tableLocator = page.GetByRole(AriaRole.Table).Nth(tableIndex); + + // Ensure the row selection correctly finds rows where the nth-child(td) contains the specified text + var rowLocator = tableLocator.Locator($"tbody tr:has(td:nth-child({columnIndex}):has-text(\"{value}\"))"); + + return rowLocator; + } + + public static ILocator GetRowsByAddress(this IPage page, string addressLine1, string addressLine2, int columnIndex1 = 3, int columnIndex2 = 4) + { + var tableLocator = page.GetByRole(AriaRole.Table); // Locate the table + + // Fix: Use plain text matching instead of regex + return tableLocator.Locator($@"tbody tr:has(td:nth-child({columnIndex1}):has-text(""{addressLine1}"")) + :has(td:nth-child({columnIndex2}):has-text(""{addressLine2}""))"); + } + + public static async Task SearchAddressTableByColumn(this IPage page, string value, int columnIndex) + { + var tableLocator = page.GetByRole(AriaRole.Table); + string trimmedValue = value.Trim(); + await page.WaitForSelectorAsync("tbody tr"); + return tableLocator.Locator($"tbody tr:has(td:nth-child({columnIndex}):has-text(\"{trimmedValue}\"))"); + + } } From f1b93f07d129eb4ffdad7904787d0d218ebdb197 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Fri, 31 Jan 2025 11:50:30 +0300 Subject: [PATCH 13/32] Refactor table row locator methods Removed `GetTableRowByColumnValue` and `GetRowsByAddress` methods from `Locators.cs`. Added new asynchronous method `SearchAddressTableByColumn` which trims the input value and waits for `tbody tr` selector to be available before locating table rows. --- .../ContactMomentSearch/Helpers/Locators.cs | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index e50b994e2..4b1a32270 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -27,28 +27,7 @@ public static ILocator Personen_PostCodeInput(this IPage page) => public static ILocator Personen_HuisnummerInput(this IPage page) => page.GetByRole(AriaRole.Textbox, new() { Name = "huisnummer" }); - - - - public static ILocator GetTableRowByColumnValue(this IPage page, int columnIndex, string value, int tableIndex = 0) - { - var tableLocator = page.GetByRole(AriaRole.Table).Nth(tableIndex); - - // Ensure the row selection correctly finds rows where the nth-child(td) contains the specified text - var rowLocator = tableLocator.Locator($"tbody tr:has(td:nth-child({columnIndex}):has-text(\"{value}\"))"); - - return rowLocator; - } - - public static ILocator GetRowsByAddress(this IPage page, string addressLine1, string addressLine2, int columnIndex1 = 3, int columnIndex2 = 4) - { - var tableLocator = page.GetByRole(AriaRole.Table); // Locate the table - - // Fix: Use plain text matching instead of regex - return tableLocator.Locator($@"tbody tr:has(td:nth-child({columnIndex1}):has-text(""{addressLine1}"")) - :has(td:nth-child({columnIndex2}):has-text(""{addressLine2}""))"); - } - + public static async Task SearchAddressTableByColumn(this IPage page, string value, int columnIndex) { var tableLocator = page.GetByRole(AriaRole.Table); From 0f790adbb2387a6017e97c8d49ebf73dd275b836 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Fri, 31 Jan 2025 12:20:15 +0300 Subject: [PATCH 14/32] Refactor BSN input field locator logic Updated `ContactMomentSearchScenarios.cs` to use the new `PersonenBsnInput` method for locating the BSN input field. Added `PersonenBsnInput` method in `Locators.cs` to centralize the locator logic, improving code readability and maintainability. --- .../ContactMomentSearch/ContactMomentSearchScenarios.cs | 4 +--- Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index 6b3e1c2a4..ff25ec092 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -61,9 +61,7 @@ public async Task SearchByBSN_Valid() await Step(" Perform the search with a valid BSN"); - var bsnInput = Page.GetByRole(AriaRole.Textbox, new() { Name = "bsn" }); - - await bsnInput.FillAsync("999992223"); + await Page.PersonenBsnInput().FillAsync("999992223"); await Page.PersonenThird_SearchButton().ClickAsync(); await Step("Verify navigation to the Persoonsinformatie page"); diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index 0030ad023..9707a2661 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -20,6 +20,8 @@ public static ILocator PersonenFirst_SearchButton(this IPage page) => public static ILocator PersonenThird_SearchButton(this IPage page) => page.Locator("form").Filter(new() { HasText = "Bsn Zoeken" }).GetByRole(AriaRole.Button); + public static ILocator PersonenBsnInput(this IPage page) => + page.GetByRole(AriaRole.Textbox, new() { Name = "bsn" }); } From bffef3b7ef46fc89251574e549defae3dce5f5bb Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Fri, 31 Jan 2025 14:52:11 +0300 Subject: [PATCH 15/32] Refactor address search to combine postCode and huisNummer Refactored address search in ContactMomentSearchScenarios.cs and Locators.cs to use a combined search method for postCode and huisNummer. Removed separate search methods and assertions, and added a new method to improve search accuracy and efficiency. --- .../ContactMomentSearchScenarios.cs | 10 ++++------ .../ContactMomentSearch/Helpers/Locators.cs | 13 ++++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index 32436dd3e..60439a376 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -113,12 +113,10 @@ public async Task SearchByPostcodeAndHuisnummer_Valid() await Step("Verify that multiple results are displayed in the table"); - - var rowByAddressLine1 = await Page.SearchAddressTableByColumn(huisNummer, 3); - var rowByPostcode = await Page.SearchAddressTableByColumn(postCode, 4); - - Assert.IsTrue(await rowByPostcode.CountAsync() > 1); - Assert.IsTrue(await rowByAddressLine1.CountAsync() > 1); + + var rowByPostcode = await Page.SearchAddressByPostalAndHuisNummer(postCode,huisNummer); + + Assert.IsTrue(await rowByPostcode.CountAsync() > 1); } diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index 4b1a32270..0af6ecfb8 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -27,15 +27,14 @@ public static ILocator Personen_PostCodeInput(this IPage page) => public static ILocator Personen_HuisnummerInput(this IPage page) => page.GetByRole(AriaRole.Textbox, new() { Name = "huisnummer" }); - - public static async Task SearchAddressTableByColumn(this IPage page, string value, int columnIndex) + public static async Task SearchAddressByPostalAndHuisNummer(this IPage page, string postcode, string huisNummer) { - var tableLocator = page.GetByRole(AriaRole.Table); - string trimmedValue = value.Trim(); - await page.WaitForSelectorAsync("tbody tr"); + var tableLocator = page.GetByRole(AriaRole.Table); // Locate the table + await page.WaitForSelectorAsync("tbody tr"); // Ensure table rows are loaded - return tableLocator.Locator($"tbody tr:has(td:nth-child({columnIndex}):has-text(\"{trimmedValue}\"))"); - + // Construct the locator + return tableLocator.Locator($"tbody tr:has(td:nth-child(4):has-text(\"{postcode.Trim()}\"))" + + $":has(td:nth-child(3):has-text(\"{huisNummer.Trim()}\"))"); } } From f07d0468843dba62d2a74ce7e614a1fb1650a960 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Fri, 31 Jan 2025 16:40:51 +0300 Subject: [PATCH 16/32] Add new test and refactor search methods Introduce `SearchByPostcodeAndHuisnummer_Valid` test in `ContactMomentSearchScenarios.cs` to validate search functionality. Refactor to remove intermediate variable and directly assert search result count. Simplify `SearchAddressByPostalAndHuisNummer` in `Locators.cs` to return locator directly. Apply minor formatting adjustments in `Locators.cs`. --- .../ContactMomentSearchScenarios.cs | 11 +++++------ .../ContactMomentSearch/Helpers/Locators.cs | 14 ++++++-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index 60439a376..30b006c5d 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -94,7 +94,7 @@ public async Task SearchByBSN_Invalid() } - + [TestMethod("5. Searching by Postcode and Huisnummer (Valid)")] public async Task SearchByPostcodeAndHuisnummer_Valid() { @@ -113,12 +113,11 @@ public async Task SearchByPostcodeAndHuisnummer_Valid() await Step("Verify that multiple results are displayed in the table"); - - var rowByPostcode = await Page.SearchAddressByPostalAndHuisNummer(postCode,huisNummer); - - Assert.IsTrue(await rowByPostcode.CountAsync() > 1); - } + await Page.GetByRole(AriaRole.Table).WaitForAsync(); + + Assert.IsTrue(await Page.SearchAddressByPostalAndHuisNummer(postCode, huisNummer).CountAsync() > 1); + } [TestMethod("6. Searching by Postcode and Huisnummer (Not Found)")] public async Task SearchByPostcodeAndHuisnummer_NotFound() diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index 0af6ecfb8..4b317472b 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; +using System.Threading.Tasks; namespace Kiss.Bff.EndToEndTest.ContactMomentSearch.Helpers { @@ -27,15 +27,13 @@ public static ILocator Personen_PostCodeInput(this IPage page) => public static ILocator Personen_HuisnummerInput(this IPage page) => page.GetByRole(AriaRole.Textbox, new() { Name = "huisnummer" }); - public static async Task SearchAddressByPostalAndHuisNummer(this IPage page, string postcode, string huisNummer) - { - var tableLocator = page.GetByRole(AriaRole.Table); // Locate the table - await page.WaitForSelectorAsync("tbody tr"); // Ensure table rows are loaded - - // Construct the locator - return tableLocator.Locator($"tbody tr:has(td:nth-child(4):has-text(\"{postcode.Trim()}\"))" + + public static ILocator SearchAddressByPostalAndHuisNummer(this IPage page, string postcode, string huisNummer) + { + return page.GetByRole(AriaRole.Table).Locator($"tbody tr:has(td:nth-child(4):has-text(\"{postcode.Trim()}\"))" + $":has(td:nth-child(3):has-text(\"{huisNummer.Trim()}\"))"); } + + } From 4ba101586690f494e914455034f2e4d1c2f611a3 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Mon, 3 Feb 2025 20:23:10 +0300 Subject: [PATCH 17/32] Update test methods in ContactMomentSearchScenarios.cs Updated SearchByLastNameAndDOB_ValidAsync and SearchByLastNameAndDOB_NotFoundAsync methods: - Added steps to navigate to the homepage and start a new contact moment. - Updated descriptions for filling in last name and birth date fields. - Added steps to click the search button. - Updated descriptions for verifying navigation and "no results found" message. --- .../ContactMomentSearchScenarios.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index 5388eed77..48c97a31f 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -17,15 +17,22 @@ public async Task SearchByLastNameAndDOB_ValidAsync() { await Step("Given the user is on the startpagina"); + await Page.GotoAsync("/"); + + await Step("When user starts a new contactmoment"); + await Page.CreateNewContactmomentAsync(); - await Step("User fills Lastname and Birthday and perform search"); + await Step("And user enters \"Burck\" in the field achternaam and enters \"17-11-1952\" in the field geboortedatum "); await Page.Personen_LastNameInput().FillAsync("Burck"); await Page.Personen_BirthDateInput().FillAsync("17-11-1952"); + + await Step("And clicks the search button"); + await Page.PersonenFirst_SearchButton().ClickAsync(); - await Step("Verify navigation to the Persoonsinformatie page"); + await Step("Then user is navigated to Persoonsinformatie page "); await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Persoonsinformatie" })).ToHaveTextAsync("Persoonsinformatie"); @@ -38,15 +45,22 @@ public async Task SearchByLastNameAndDOB_NotFoundAsync() await Step("Given the user is on the startpagina "); + await Page.GotoAsync("/"); + + await Step("When user starts a new contactmoment"); + await Page.CreateNewContactmomentAsync(); - await Step("User fills Lastname and Birthday and perform search"); + await Step("And user enters \"TestDB” in the field achternaam and \"11-12-1990” in the field geboortedatum "); await Page.Personen_LastNameInput().FillAsync("TestDB"); await Page.Personen_BirthDateInput().FillAsync("11-12-1990"); + + await Step("And clicks the search button"); + await Page.PersonenFirst_SearchButton().ClickAsync(); - await Step("The message is displayed as “Geen resultaten gevonden voor ’TestDB, 11-12-1990"); + await Step("Then the message is displayed as “Geen resultaten gevonden voor ’TestDB, 11-12-1990’."); await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor 'TestDB, 11-12-1990'."); From 0dd48089d5ca2fff5f04283d43e5fd18d05591a4 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Mon, 3 Feb 2025 20:32:36 +0300 Subject: [PATCH 18/32] Refactor test methods in ContactMomentSearchScenarios.cs Updated SearchByBSN_Valid and SearchByBSN_Invalid methods to: - Add navigation to the start page using Page.GotoAsync("/") - Clarify step descriptions for entering BSN and clicking search - Use Page.PersonenBsnInput() for BSN field interactions - Ensure accurate validation message checks --- .../ContactMomentSearchScenarios.cs | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index e47528009..c35b852d3 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -70,15 +70,22 @@ public async Task SearchByLastNameAndDOB_NotFoundAsync() public async Task SearchByBSN_Valid() { await Step("Given the user is on the startpagina "); + + await Page.GotoAsync("/"); + + await Step("When user starts a new contactmoment"); await Page.CreateNewContactmomentAsync(); - await Step(" Perform the search with a valid BSN"); + await Step("And user enters \"999992223\" in the field bsn "); await Page.PersonenBsnInput().FillAsync("999992223"); + + await Step("And clicks the search button"); + await Page.PersonenThird_SearchButton().ClickAsync(); - await Step("Verify navigation to the Persoonsinformatie page"); + await Step("Then user is navigated to Persoonsinformatie page"); await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Persoonsinformatie" })).ToHaveTextAsync("Persoonsinformatie"); @@ -90,19 +97,23 @@ public async Task SearchByBSN_Invalid() { await Step("Given the user is on the startpagina "); + await Page.GotoAsync("/"); + + await Step("When user starts a new contactmoment"); + await Page.CreateNewContactmomentAsync(); - await Step(" Perform the search with a invalid BSN"); + await Step("And user enters \"123456789\" in the field bsn "); - var bsnInput = Page.GetByRole(AriaRole.Textbox, new() { Name = "bsn" }); + await Page.PersonenBsnInput().FillAsync("123456789"); - await bsnInput.FillAsync("123456789"); + await Step("And clicks the search button"); await Page.PersonenThird_SearchButton().ClickAsync(); - await Step("The message is displayed as “Dit is geen valide BSN"); + await Step("Then the message is displayed as “Dit is geen valide BSN.”"); - Assert.AreEqual( await bsnInput.EvaluateAsync("(el) => el.validationMessage"), "Dit is geen valide BSN."); + Assert.AreEqual( await Page.PersonenBsnInput().EvaluateAsync("(el) => el.validationMessage"), "Dit is geen valide BSN."); } From f2e35d6df7acbf895fea91a17ecfe2b93e4e23c7 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Mon, 3 Feb 2025 23:05:32 +0300 Subject: [PATCH 19/32] Add new test methods and locators for search scenarios Introduce new test methods in ContactMomentSearchScenarios.cs to cover additional search scenarios, including partial last name and date of birth, and company name searches. Add new locator methods in Locators.cs to support these tests. Reformat existing PersonenBsnInput method for consistency. --- .../ContactMomentSearchScenarios.cs | 106 ++++++++++++++++++ .../ContactMomentSearch/Helpers/Locators.cs | 23 +++- 2 files changed, 127 insertions(+), 2 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index 3ed330ad7..84dcdeda0 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -177,6 +177,112 @@ public async Task SearchByPostcodeAndHuisnummer_NotFound() await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor '3544NG, 11'."); + } + + + [TestMethod("7. Searching by Partial Last Name and Date of Birth (Multiple Results)")] + public async Task SearchByPartialLastNameAndDOB_MultipleResults() + { + await Step("Given the user is on the startpagina"); + + await Page.GotoAsync("/"); + + await Step("When user starts a new contactmoment"); + + await Page.CreateNewContactmomentAsync(); + + await Step("And user enters \"Mel\" in the field Achternaam and enters \"12091946\" in the field geboortedatum "); + + await Page.Personen_LastNameInput().FillAsync("Mel"); + await Page.Personen_BirthDateInput().FillAsync("12091946"); + + await Step("And clicks the search button"); + + await Page.PersonenFirst_SearchButton().ClickAsync(); + + await Step("Then the message as “2 resultaten gevonden voor ' Mel, 12-09-1946 '.” is displayed "); + + await Page.GetByRole(AriaRole.Table).WaitForAsync(); + + await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("2 resultaten gevonden voor 'Mel, 12-09-1946'."); + + await Step("And a list of two records is displayed"); + + await Expect(Page.GetByRole(AriaRole.Table).Locator("tr.row-link")).ToHaveCountAsync(2); + + await Step("One with the value \" Julia Christine Maria Melap\" in column Naam "); + + await Expect(Page.GetByRole(AriaRole.Table).Locator("tr.row-link") + .Nth(0).Locator("th[scope='row']")).ToHaveTextAsync("Julia Christine Maria Melap"); + + await Step("And one with value \"Julia Christina Melapatti\" in column Naam "); + + await Expect(Page.GetByRole(AriaRole.Table).Locator("tr.row-link") + .Nth(1).Locator("th[scope='row']")).ToHaveTextAsync("Julia Christina Melapatti"); + + + + + } + + [TestMethod("8. Searching by Partial Last Name and Date of Birth (Single Result)")] + public async Task SearchByBedrijfsnaam_MultipleRecordsAsync() + { + await Step("Given the user is on the startpagina"); + + await Page.GotoAsync("/"); + + await Step("When user starts a new contactmoment"); + + await Page.CreateNewContactmomentAsync(); + + await Step("When user clicks Bedrijf from the menu item "); + + await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); + + await Step("And user enters “Donald” in the field Bedrijfsnaam"); + + await Page.Company_BedrijfsnaamInput().FillAsync("Donald"); + + await Step("And clicks the search button"); + + await Page.Company_FirstSearchButton().ClickAsync(); + + await Step("Then the list displays multiple records associated with the name “Donald”."); + + await Page.WaitForSelectorAsync(AriaRole.Table.ToString()); + + Assert.IsTrue(await Page.GetByRole(AriaRole.Table).GetByRole(AriaRole.Row).CountAsync() > 1); + } + + [TestMethod("9. Search By Bedrijfsnaam Unique Result ")] + public async Task SearchByBedrijfsnaam_UniqueResultAsync() + { + await Step("Given the user is on the startpagina"); + + await Page.GotoAsync("/"); + + await Step("When user starts a new contactmoment"); + + await Page.CreateNewContactmomentAsync(); + + await Step("When user clicks Bedrijf from the menu item "); + + await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); + + await Step("And user enters “Test Stichting Bolderbast” in the field Bedrijfsnaam"); + + await Page.Company_BedrijfsnaamInput().FillAsync("Test Stichting Bolderbast"); + + await Step("And clicks the search button"); + + await Page.Company_FirstSearchButton().ClickAsync(); + + await Step("Then user is navigated to bedrijfsinformatie page"); + + await Page.WaitForLoadStateAsync(LoadState.NetworkIdle); + + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToHaveTextAsync("Bedrijfsinformatie"); } #endregion diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index a332b8b52..19412cdc6 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -32,11 +32,30 @@ public static ILocator SearchAddressByPostalAndHuisNummer(this IPage page, strin return page.GetByRole(AriaRole.Table).Locator($"tbody tr:has(td:nth-child(4):has-text(\"{postcode.Trim()}\"))" + $":has(td:nth-child(3):has-text(\"{huisNummer.Trim()}\"))"); } - + public static ILocator Company_BedrijfsnaamInput(this IPage page) => + page.GetByRole(AriaRole.Textbox, new() { Name = "Bedrijfsnaam" }); + + public static ILocator Company_KVKNumberInput(this IPage page) => + page.GetByRole(AriaRole.Textbox, new() { Name = "KVK-nummer" }); + + public static ILocator Company_PostcodeInput(this IPage page) => + page.GetByRole(AriaRole.Textbox, new() { Name = "Postcode" }); + + public static ILocator Company_HuisnummerInput(this IPage page) => + page.GetByRole(AriaRole.Textbox, new() { Name = "Huisnummer" }); + + public static ILocator Company_FirstSearchButton(this IPage page) => + page.Locator("form").Filter(new() { HasText= "Bedrijfsnaam Zoeken" }).GetByRole(AriaRole.Button); + + + public static ILocator GetSearchResultsByPostcodeAndHuisnummer(this IPage page, string postcode, string huisnummer) => + page.GetByRole(AriaRole.Table).Locator($"tbody tr:has(td:nth-child(4):has-text(\"{postcode.Trim()}\"))" + + $":has(td:nth-child(3):has-text(\"{huisnummer.Trim()}\"))"); public static ILocator PersonenBsnInput(this IPage page) => - page.GetByRole(AriaRole.Textbox, new() { Name = "bsn" }); + page.GetByRole(AriaRole.Textbox, new() { Name = "bsn" }); + } From 0547547b22c2f9f913cf907f49591dc0c15dcaf6 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Tue, 4 Feb 2025 11:14:30 +0300 Subject: [PATCH 20/32] Fix and reorganize BSN validation step in tests Reorganized and corrected steps in `ContactMomentSearchScenarios.cs` to ensure the validation message "Dit is geen valide BSN." is properly checked. Re-added the assertion to verify the validation message, aligning it with the step description. --- .../ContactMomentSearch/ContactMomentSearchScenarios.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index 3ed330ad7..a2d4f3508 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -111,10 +111,7 @@ public async Task SearchByBSN_Invalid() await Page.PersonenThird_SearchButton().ClickAsync(); - await Step("Then the message is displayed as “Dit is geen valide BSN.”"); - - Assert.AreEqual( await Page.PersonenBsnInput().EvaluateAsync("(el) => el.validationMessage"), "Dit is geen valide BSN."); - await Step("The message is displayed as “Dit is geen valide BSN"); + await Step("Then the message is displayed as “Dit is geen valide BSN.”"); Assert.AreEqual(await Page.PersonenBsnInput().EvaluateAsync("(el) => el.validationMessage"), "Dit is geen valide BSN."); From b5bb0d97f5986ef6eb49ef59ca6eaeebfd441900 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Tue, 4 Feb 2025 13:43:01 +0300 Subject: [PATCH 21/32] Refactor assertion to improve test clarity Refactored the assertion in `ContactMomentSearchScenarios.cs` to store the count of records in a variable `resultCount`. The assertion now includes a detailed error message specifying the expected condition and the actual count found, enhancing debugging capabilities. --- .../ContactMomentSearch/ContactMomentSearchScenarios.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index a2d4f3508..0f4958389 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -146,7 +146,9 @@ public async Task SearchByPostcodeAndHuisnummer_Valid() await Page.GetByRole(AriaRole.Table).WaitForAsync(); - Assert.IsTrue(await Page.SearchAddressByPostalAndHuisNummer(postCode, huisNummer).CountAsync() > 1); + var resultCount = await Page.SearchAddressByPostalAndHuisNummer(postCode, huisNummer).CountAsync(); + + Assert.IsTrue(resultCount > 1, $"Expected there to be multiple records associated with postCode {postCode} and huisNummer {huisNummer}, but found {resultCount}."); } [TestMethod("6. Searching by Postcode and Huisnummer (Not Found)")] From 7cc8b39a76d661d75b70376daf7abbdf85839374 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Tue, 4 Feb 2025 14:25:48 +0300 Subject: [PATCH 22/32] Replace `WaitForAsync` with `ToBeVisibleAsync` in tests Replaced the `WaitForAsync` method with the `ToBeVisibleAsync` method to ensure that the table element is visible before proceeding. This change aims to improve the reliability of the test by explicitly checking for the visibility of the table element rather than just waiting for its presence. --- .../ContactMomentSearch/ContactMomentSearchScenarios.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index 0f4958389..2082d0068 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -143,8 +143,8 @@ public async Task SearchByPostcodeAndHuisnummer_Valid() await Step("Then a list of multiple records associated with same huisnummer and postcode is displayed "); - - await Page.GetByRole(AriaRole.Table).WaitForAsync(); + + await Expect(Page.GetByRole(AriaRole.Table)).ToBeVisibleAsync(); var resultCount = await Page.SearchAddressByPostalAndHuisNummer(postCode, huisNummer).CountAsync(); From d59504e3a080a9ad23504e06c082fbce215bbf0b Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Tue, 4 Feb 2025 14:36:12 +0300 Subject: [PATCH 23/32] Update visibility checks in end-to-end tests Updated `ContactMomentSearchScenarios.cs` to use explicit visibility assertions: - Replaced `Page.WaitForSelectorAsync` with `Expect(Page.GetByRole(AriaRole.Table)).ToBeVisibleAsync()` for table element visibility. - Replaced `Page.WaitForLoadStateAsync` with `Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync()` for heading element visibility. --- .../ContactMomentSearch/ContactMomentSearchScenarios.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index 403560de8..55af43bea 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -249,7 +249,7 @@ public async Task SearchByBedrijfsnaam_MultipleRecordsAsync() await Step("Then the list displays multiple records associated with the name “Donald”."); - await Page.WaitForSelectorAsync(AriaRole.Table.ToString()); + await Expect(Page.GetByRole(AriaRole.Table)).ToBeVisibleAsync(); Assert.IsTrue(await Page.GetByRole(AriaRole.Table).GetByRole(AriaRole.Row).CountAsync() > 1); } @@ -279,7 +279,7 @@ public async Task SearchByBedrijfsnaam_UniqueResultAsync() await Step("Then user is navigated to bedrijfsinformatie page"); - await Page.WaitForLoadStateAsync(LoadState.NetworkIdle); + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync(); await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToHaveTextAsync("Bedrijfsinformatie"); } From 7dd84f6df03d47a90b05de7b990384e1598c5d66 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Tue, 4 Feb 2025 17:46:36 +0300 Subject: [PATCH 24/32] Update assertions and improve code readability Modified assertions in SearchAddressByPostalAndHuisNummer and SearchByPostcodeAndHuisnummer_NotFound methods to check for result count greater than 2, ensuring tests expect at least three records. Improved readability in SearchByPostcodeAndHuisnummer_NotFound by assigning company name "Donald" to a variable before use. --- .../ContactMomentSearchScenarios.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs index 55af43bea..ed39e0efd 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs @@ -148,7 +148,7 @@ public async Task SearchByPostcodeAndHuisnummer_Valid() var resultCount = await Page.SearchAddressByPostalAndHuisNummer(postCode, huisNummer).CountAsync(); - Assert.IsTrue(resultCount > 1, $"Expected there to be multiple records associated with postCode {postCode} and huisNummer {huisNummer}, but found {resultCount}."); + Assert.IsTrue(resultCount > 2, $"Expected there to be multiple records associated with postCode {postCode} and huisNummer {huisNummer}, but found {resultCount}."); } [TestMethod("6. Searching by Postcode and Huisnummer (Not Found)")] @@ -241,7 +241,9 @@ public async Task SearchByBedrijfsnaam_MultipleRecordsAsync() await Step("And user enters “Donald” in the field Bedrijfsnaam"); - await Page.Company_BedrijfsnaamInput().FillAsync("Donald"); + var lastName = "Donald"; + + await Page.Company_BedrijfsnaamInput().FillAsync(lastName); await Step("And clicks the search button"); @@ -251,7 +253,9 @@ public async Task SearchByBedrijfsnaam_MultipleRecordsAsync() await Expect(Page.GetByRole(AriaRole.Table)).ToBeVisibleAsync(); - Assert.IsTrue(await Page.GetByRole(AriaRole.Table).GetByRole(AriaRole.Row).CountAsync() > 1); + var resultCount = await Page.GetByRole(AriaRole.Table).GetByRole(AriaRole.Row).CountAsync(); + + Assert.IsTrue(resultCount > 2, $"Expected multiple records associated with the last name '{lastName}', but found {resultCount}."); } [TestMethod("9. Search By Bedrijfsnaam Unique Result ")] From 63951e57d5a4840d1d3707c2e20490aff27c1149 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Tue, 4 Feb 2025 19:13:02 +0300 Subject: [PATCH 25/32] Add and update search test scenarios for companies and persons Created SearchCompanyScenarios.cs with new test scenarios for searching companies, including necessary using directives and test methods. Renamed and modified SearchPersonScenarios.cs with updated test methods, improved organization, and minor formatting adjustments. --- .../SearchCompanyScenarios.cs | 80 ++++++++++++++++ ...hScenarios.cs => SearchPersonScenarios.cs} | 92 +++---------------- 2 files changed, 93 insertions(+), 79 deletions(-) create mode 100644 Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs rename Kiss.Bff.EndToEndTest/ContactMomentSearch/{ContactMomentSearchScenarios.cs => SearchPersonScenarios.cs} (72%) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs new file mode 100644 index 000000000..80345ec2f --- /dev/null +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Kiss.Bff.EndToEndTest.ContactMomentSearch.Helpers; + +namespace Kiss.Bff.EndToEndTest.ContactMomentSearch +{ + [TestClass] + public class SearchCompanyScenarios : KissPlaywrightTest + { + + + [TestMethod("1. Searching by Partial Last Name and Date of Birth (Single Result)")] + public async Task SearchByBedrijfsnaam_MultipleRecordsAsync() + { + await Step("Given the user is on the startpagina"); + + await Page.GotoAsync("/"); + + await Step("When user starts a new contactmoment"); + + await Page.CreateNewContactmomentAsync(); + + await Step("When user clicks Bedrijf from the menu item "); + + await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); + + await Step("And user enters “Donald” in the field Bedrijfsnaam"); + + var lastName = "Donald"; + + await Page.Company_BedrijfsnaamInput().FillAsync(lastName); + + await Step("And clicks the search button"); + + await Page.Company_FirstSearchButton().ClickAsync(); + + await Step("Then the list displays multiple records associated with the name “Donald”."); + + await Expect(Page.GetByRole(AriaRole.Table)).ToBeVisibleAsync(); + + var resultCount = await Page.GetByRole(AriaRole.Table).GetByRole(AriaRole.Row).CountAsync(); + + Assert.IsTrue(resultCount > 2, $"Expected multiple records associated with the last name '{lastName}', but found {resultCount}."); + } + + [TestMethod("2. Search By Bedrijfsnaam Unique Result ")] + public async Task SearchByBedrijfsnaam_UniqueResultAsync() + { + await Step("Given the user is on the startpagina"); + + await Page.GotoAsync("/"); + + await Step("When user starts a new contactmoment"); + + await Page.CreateNewContactmomentAsync(); + + await Step("When user clicks Bedrijf from the menu item "); + + await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); + + await Step("And user enters “Test Stichting Bolderbast” in the field Bedrijfsnaam"); + + await Page.Company_BedrijfsnaamInput().FillAsync("Test Stichting Bolderbast"); + + await Step("And clicks the search button"); + + await Page.Company_FirstSearchButton().ClickAsync(); + + await Step("Then user is navigated to bedrijfsinformatie page"); + + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync(); + + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToHaveTextAsync("Bedrijfsinformatie"); + } + + } +} diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchPersonScenarios.cs similarity index 72% rename from Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs rename to Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchPersonScenarios.cs index ed39e0efd..7bd11533c 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/ContactMomentSearchScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchPersonScenarios.cs @@ -8,9 +8,8 @@ namespace Kiss.Bff.EndToEndTest.ContactMomentSearch { [TestClass] - public class ContactMomentSearchScenarios : KissPlaywrightTest + internal class SearchPersonScenarios : KissPlaywrightTest { - #region Test Cases [TestMethod("1. Searching by Last Name and Date of Birth (Valid)")] public async Task SearchByLastNameAndDOB_ValidAsync() @@ -31,7 +30,7 @@ public async Task SearchByLastNameAndDOB_ValidAsync() await Step("And clicks the search button"); await Page.PersonenFirst_SearchButton().ClickAsync(); - + await Step("Then user is navigated to Persoonsinformatie page "); await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Persoonsinformatie" })).ToHaveTextAsync("Persoonsinformatie"); @@ -61,8 +60,8 @@ public async Task SearchByLastNameAndDOB_NotFoundAsync() await Page.PersonenFirst_SearchButton().ClickAsync(); await Step("Then the message is displayed as “Geen resultaten gevonden voor ’TestDB, 11-12-1990’."); - - await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor 'TestDB, 11-12-1990'."); + + await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor 'TestDB, 11-12-1990'."); } @@ -70,7 +69,7 @@ public async Task SearchByLastNameAndDOB_NotFoundAsync() public async Task SearchByBSN_Valid() { await Step("Given the user is on the startpagina "); - + await Page.GotoAsync("/"); await Step("When user starts a new contactmoment"); @@ -111,7 +110,7 @@ public async Task SearchByBSN_Invalid() await Page.PersonenThird_SearchButton().ClickAsync(); - await Step("Then the message is displayed as “Dit is geen valide BSN.”"); + await Step("Then the message is displayed as “Dit is geen valide BSN.”"); Assert.AreEqual(await Page.PersonenBsnInput().EvaluateAsync("(el) => el.validationMessage"), "Dit is geen valide BSN."); @@ -143,14 +142,14 @@ public async Task SearchByPostcodeAndHuisnummer_Valid() await Step("Then a list of multiple records associated with same huisnummer and postcode is displayed "); - + await Expect(Page.GetByRole(AriaRole.Table)).ToBeVisibleAsync(); var resultCount = await Page.SearchAddressByPostalAndHuisNummer(postCode, huisNummer).CountAsync(); Assert.IsTrue(resultCount > 2, $"Expected there to be multiple records associated with postCode {postCode} and huisNummer {huisNummer}, but found {resultCount}."); } - + [TestMethod("6. Searching by Postcode and Huisnummer (Not Found)")] public async Task SearchByPostcodeAndHuisnummer_NotFound() { @@ -161,15 +160,15 @@ public async Task SearchByPostcodeAndHuisnummer_NotFound() await Step("When user starts a new contactmoment"); await Page.CreateNewContactmomentAsync(); - + await Step("And user enters \"3544NG\" in the field postcode and “11” in field"); - + await Page.Personen_PostCodeInput().FillAsync("3544 NG"); await Page.Personen_HuisnummerInput().FillAsync("11"); await Step("And clicks the search button"); - await Page.PersonenSecond_SearchButton().ClickAsync(); + await Page.PersonenSecond_SearchButton().ClickAsync(); await Step("Then the message as “Geen resultaten gevonden voor '3544NG, 11'.” is displayed "); @@ -179,7 +178,7 @@ public async Task SearchByPostcodeAndHuisnummer_NotFound() } - [TestMethod("7. Searching by Partial Last Name and Date of Birth (Multiple Results)")] + [TestMethod("7. Searching by Partial Last Name and Date of Birth (Multiple Results)")] public async Task SearchByPartialLastNameAndDOB_MultipleResults() { await Step("Given the user is on the startpagina"); @@ -211,83 +210,18 @@ public async Task SearchByPartialLastNameAndDOB_MultipleResults() await Step("One with the value \" Julia Christine Maria Melap\" in column Naam "); - await Expect(Page.GetByRole(AriaRole.Table).Locator("tr.row-link") + await Expect(Page.GetByRole(AriaRole.Table).Locator("tr.row-link") .Nth(0).Locator("th[scope='row']")).ToHaveTextAsync("Julia Christine Maria Melap"); await Step("And one with value \"Julia Christina Melapatti\" in column Naam "); await Expect(Page.GetByRole(AriaRole.Table).Locator("tr.row-link") .Nth(1).Locator("th[scope='row']")).ToHaveTextAsync("Julia Christina Melapatti"); - - - - - } - - [TestMethod("8. Searching by Partial Last Name and Date of Birth (Single Result)")] - public async Task SearchByBedrijfsnaam_MultipleRecordsAsync() - { - await Step("Given the user is on the startpagina"); - - await Page.GotoAsync("/"); - - await Step("When user starts a new contactmoment"); - - await Page.CreateNewContactmomentAsync(); - - await Step("When user clicks Bedrijf from the menu item "); - - await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); - - await Step("And user enters “Donald” in the field Bedrijfsnaam"); - - var lastName = "Donald"; - - await Page.Company_BedrijfsnaamInput().FillAsync(lastName); - - await Step("And clicks the search button"); - - await Page.Company_FirstSearchButton().ClickAsync(); - - await Step("Then the list displays multiple records associated with the name “Donald”."); - - await Expect(Page.GetByRole(AriaRole.Table)).ToBeVisibleAsync(); - - var resultCount = await Page.GetByRole(AriaRole.Table).GetByRole(AriaRole.Row).CountAsync(); - - Assert.IsTrue(resultCount > 2, $"Expected multiple records associated with the last name '{lastName}', but found {resultCount}."); - } - - [TestMethod("9. Search By Bedrijfsnaam Unique Result ")] - public async Task SearchByBedrijfsnaam_UniqueResultAsync() - { - await Step("Given the user is on the startpagina"); - - await Page.GotoAsync("/"); - - await Step("When user starts a new contactmoment"); - - await Page.CreateNewContactmomentAsync(); - - await Step("When user clicks Bedrijf from the menu item "); - - await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); - - await Step("And user enters “Test Stichting Bolderbast” in the field Bedrijfsnaam"); - - await Page.Company_BedrijfsnaamInput().FillAsync("Test Stichting Bolderbast"); - - await Step("And clicks the search button"); - await Page.Company_FirstSearchButton().ClickAsync(); - await Step("Then user is navigated to bedrijfsinformatie page"); - await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync(); - await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToHaveTextAsync("Bedrijfsinformatie"); } - #endregion } } From 506101d5884ab640084588c8ed85a1e7f269d501 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Wed, 5 Feb 2025 16:52:49 +0300 Subject: [PATCH 26/32] Add new locators and test methods for company search Introduced new methods and test cases in the `Kiss.Bff.EndToEndTest.ContactMomentSearch.Helpers` and `Kiss.Bff.EndToEndTest.ContactMomentSearch` namespaces. In `Locators.cs`: - Added `Company_KvknummerInput` to locate the textbox for entering the "KVK-nummer of vestigingsnummer". - Added `Company_KvknummerSearchButton` to locate the search button within a form that has the text "KVK-nummer of". In `SearchCompanyScenarios.cs`: - Added `SearchByNonExistentBedrijfsnaamAsync` to verify that searching for a non-existent "Bedrijfsnaam" displays "Geen resultaten gevonden voor 'test automation'". - Added `SearchByKvknummerAsync` to verify that searching for a specific "KVK-nummer" navigates to the "Bedrijfsinformatie" page of "Test Stichting Bolderbast". - Added `SearchByKvknummer_MultipleRecordsAsync` to verify that searching for a "KVK-nummer" with multiple records displays a list of associated records. --- .../ContactMomentSearch/Helpers/Locators.cs | 8 +- .../SearchCompanyScenarios.cs | 92 +++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index 19412cdc6..c18130f9c 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -55,7 +55,13 @@ public static ILocator GetSearchResultsByPostcodeAndHuisnummer(this IPage page, public static ILocator PersonenBsnInput(this IPage page) => page.GetByRole(AriaRole.Textbox, new() { Name = "bsn" }); - + + public static ILocator Company_KvknummerInput(this IPage page) => + page.GetByRole(AriaRole.Textbox, new() { Name = "KVK-nummer of vestigingsnummer" }); + + public static ILocator Company_KvknummerSearchButton(this IPage page) => + page.Locator("form").Filter(new() { HasText = "KVK-nummer of" }).GetByRole(AriaRole.Button); + } diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs index 80345ec2f..0f023259d 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs @@ -76,5 +76,97 @@ public async Task SearchByBedrijfsnaam_UniqueResultAsync() await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToHaveTextAsync("Bedrijfsinformatie"); } + + + [TestMethod("3. Searching for a company by Bedrijfsnaam not available in the database")] + public async Task SearchByNonExistentBedrijfsnaamAsync() + { + await Step("Given user is on the startpagina"); + + await Page.GotoAsync("/"); + + await Step("And starts a new Contactmoment"); + + await Page.CreateNewContactmomentAsync(); + + await Step("When user click Bedrijf from the menu item"); + + await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); + + await Step("And the user enters 'test automation' in the field Bedrijfsnaam"); + + await Page.Company_BedrijfsnaamInput().FillAsync("test automation"); + + await Step("And clicks the search button"); + + await Page.Company_FirstSearchButton().ClickAsync(); + + await Step("Then message is displayed as Geen resultaten gevonden voor 'test automation'."); + + await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor 'test automation'."); + } + + [TestMethod("4. Searching a company by KVK-nummer")] + public async Task SearchByKvknummerAsync() + { + await Step("Given user is on the startpagina"); + + await Page.GotoAsync("/"); + + await Step("And starts a new Contactmoment"); + + await Page.CreateNewContactmomentAsync(); + + await Step("When user click Bedrijf from the menu item"); + + await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); + + await Step("And user enters '69599068' in the field KVK-nummer of vestigingsnummer"); + + await Page.Company_KvknummerInput().FillAsync("69599068"); + + await Step("And clicks the search button"); + + await Page.Company_KvknummerSearchButton().ClickAsync(); + + await Step("Then user is navigated to bedrijfinformatie page of Test Stichting Bolderbast"); + + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync(); + + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToHaveTextAsync("Bedrijfsinformatie"); + } + + [TestMethod("5. Searching a company using KVK-nummer with multiple records")] + public async Task SearchByKvknummer_MultipleRecordsAsync() + { + await Step("Given user is on the startpagina"); + + await Page.GotoAsync("/"); + + await Step("And starts a new Contactmoment"); + + await Page.CreateNewContactmomentAsync(); + + await Step("When user clicks Bedrijf from the menu item"); + + await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); + + await Step("And the user enters '68750110' in the field KVK-nummer of vestigingsnummer"); + + await Page.Company_KvknummerInput().FillAsync("68750110"); + + await Step("And clicks the search button"); + + await Page.Company_KvknummerSearchButton().ClickAsync(); + + await Step("Then the list displays multiple records associated with the kvknummer '68750110'"); + + await Expect(Page.GetByRole(AriaRole.Table)).ToBeVisibleAsync(); + + var resultCount = await Page.GetByRole(AriaRole.Table).GetByRole(AriaRole.Row).CountAsync(); + + Assert.IsTrue(resultCount > 2, $"Expected there to be multiple records associated with kvknummer '68750110', but found {resultCount}."); + } + } } From 38a424427a473b095bfd36f80b0aed6674585ed1 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Wed, 5 Feb 2025 18:26:51 +0300 Subject: [PATCH 27/32] Remove heading assertions; add new search test methods Removed assertions checking for "Bedrijfsinformatie" in the heading of a page in `SearchCompanyScenarios.cs`. Added two new test methods: `SearchByNonExistentBedrijfsnaamAsync` and `SearchByKvknummer_MultipleRecordsAsync`. --- .../ContactMomentSearch/SearchCompanyScenarios.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs index 0f023259d..119417054 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs @@ -73,8 +73,7 @@ public async Task SearchByBedrijfsnaam_UniqueResultAsync() await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync(); - await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToHaveTextAsync("Bedrijfsinformatie"); - } + } @@ -133,8 +132,7 @@ public async Task SearchByKvknummerAsync() await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync(); - await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToHaveTextAsync("Bedrijfsinformatie"); - } + } [TestMethod("5. Searching a company using KVK-nummer with multiple records")] public async Task SearchByKvknummer_MultipleRecordsAsync() From 0a5679cc55fa50effcf29c16a9a724613aa3cee2 Mon Sep 17 00:00:00 2001 From: Felix Cornelissen Date: Wed, 5 Feb 2025 16:58:40 +0100 Subject: [PATCH 28/32] fix: make SearchPersonScenarios testclass public --- .../ContactMomentSearch/SearchPersonScenarios.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchPersonScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchPersonScenarios.cs index 7bd11533c..fadacc886 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchPersonScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchPersonScenarios.cs @@ -8,7 +8,7 @@ namespace Kiss.Bff.EndToEndTest.ContactMomentSearch { [TestClass] - internal class SearchPersonScenarios : KissPlaywrightTest + public class SearchPersonScenarios : KissPlaywrightTest { [TestMethod("1. Searching by Last Name and Date of Birth (Valid)")] From aac1a6c0ce50b0a5cb644d5b2728c6cac3295f9d Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Thu, 6 Feb 2025 17:20:39 +0300 Subject: [PATCH 29/32] Add new search tests and update class visibility - Added `Company_PostcodeHuisnummerSearchButton` method in `Locators.cs` for locating the search button by postcode and house number. - Added three new test methods in `SearchCompanyScenarios.cs`: * `SearchByVestigingsnummer_UniqueResultAsync` * `SearchByNonExistentKvknummerAsync` * `SearchByPostcodeAndHuisnummerAsync` - Changed `SearchPersonScenarios` class visibility from `internal` to `public` in `SearchPersonScenarios.cs`. --- .../ContactMomentSearch/Helpers/Locators.cs | 3 + .../SearchCompanyScenarios.cs | 92 +++++++++++++++++++ .../SearchPersonScenarios.cs | 2 +- 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index c18130f9c..48169f556 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -62,6 +62,9 @@ public static ILocator Company_KvknummerInput(this IPage page) => public static ILocator Company_KvknummerSearchButton(this IPage page) => page.Locator("form").Filter(new() { HasText = "KVK-nummer of" }).GetByRole(AriaRole.Button); + public static ILocator Company_PostcodeHuisnummerSearchButton(this IPage page) => + page.Locator("form").Filter(new() { HasText = "Postcode Huisnummer Zoeken" }).GetByRole(AriaRole.Button); + } diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs index 0f023259d..c02baa07e 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs @@ -168,5 +168,97 @@ public async Task SearchByKvknummer_MultipleRecordsAsync() Assert.IsTrue(resultCount > 2, $"Expected there to be multiple records associated with kvknummer '68750110', but found {resultCount}."); } + + [TestMethod("6. Searching a company using vestigingsnummer which is unique")] + public async Task SearchByVestigingsnummer_UniqueResultAsync() + { + await Step("Given user is on the startpagina"); + + await Page.GotoAsync("/"); + + await Step("And user starts a new Contactmoment"); + + await Page.CreateNewContactmomentAsync(); + + await Step("When user clicks Bedrijf from the menu item"); + + await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); + + await Step("And user enters '000037178601' in the field KVK-nummer of vestigingsnummer"); + + await Page.Company_KvknummerInput().FillAsync("000037178601"); + + await Step("And clicks the search button"); + + await Page.Company_KvknummerSearchButton().ClickAsync(); + + await Step("Then user is navigated to bedrijfinformatie page of Test BV Donald Nevenvestiging"); + + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync(); + + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToHaveTextAsync("Bedrijfsinformatie"); + } + + + [TestMethod("7. Searching a company by a kvknummer which is not available in DB")] + public async Task SearchByNonExistentKvknummerAsync() + { + await Step("Given user is on the startpagina"); + + await Page.GotoAsync("/"); + + await Step("And user starts a new Contactmoment"); + + await Page.CreateNewContactmomentAsync(); + + await Step("When user clicks Bedrijf from the menu item"); + + await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); + + await Step("And user enters '12345678' in the field KVK-nummer of vestigingsnummer"); + + await Page.Company_KvknummerInput().FillAsync("12345678"); + + await Step("And clicks the search button"); + + await Page.Company_KvknummerSearchButton().ClickAsync(); + + await Step("Then message is displayed as 'Geen resultaten gevonden voor 12345678'."); + + await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor '12345678'."); + } + [TestMethod("8. Searching a company by postcode and huisnummer")] + public async Task SearchByPostcodeAndHuisnummerAsync() + { + await Step("Given user is on the startpagina"); + + await Page.GotoAsync("/"); + + await Step("And user starts a new Contactmoment"); + + await Page.CreateNewContactmomentAsync(); + + await Step("When user clicks Bedrijf from the menu item"); + + await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); + + await Step("And the user enters '7431BX' in the field postcode and '3' in Huisnummer field"); + + await Page.Company_PostcodeInput().FillAsync("7431BX"); + await Page.Company_HuisnummerInput().FillAsync("3"); + + await Step("And clicks the search button"); + + await Page.Company_PostcodeHuisnummerSearchButton().ClickAsync(); + + await Step("Then user is navigated to Bedrijfinformatie page of Test BV Donald Nevenvestiging"); + + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync(); + + } + + + + } } diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchPersonScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchPersonScenarios.cs index 7bd11533c..7a96e033b 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchPersonScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchPersonScenarios.cs @@ -8,7 +8,7 @@ namespace Kiss.Bff.EndToEndTest.ContactMomentSearch { [TestClass] - internal class SearchPersonScenarios : KissPlaywrightTest + public class SearchPersonScenarios : KissPlaywrightTest { [TestMethod("1. Searching by Last Name and Date of Birth (Valid)")] From a1f0789e4303396812f22dba5ed3d63be3e588f0 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Thu, 6 Feb 2025 18:33:07 +0300 Subject: [PATCH 30/32] Add test for non-existent kvknummer; remove redundant check Added a new test method `SearchByNonExistentKvknummerAsync` to verify the behavior when searching for a company by a kvknummer not present in the database. Removed a redundant line that checked if the heading "Bedrijfsinformatie" contains the text "Bedrijfsinformatie". --- .../ContactMomentSearch/SearchCompanyScenarios.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs index c02baa07e..debc87919 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs @@ -195,8 +195,7 @@ public async Task SearchByVestigingsnummer_UniqueResultAsync() await Step("Then user is navigated to bedrijfinformatie page of Test BV Donald Nevenvestiging"); await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync(); - - await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToHaveTextAsync("Bedrijfsinformatie"); + } From 25c6427c83efcce90c2045d4c3a1b9cbdc2f43a1 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Thu, 6 Feb 2025 19:41:35 +0300 Subject: [PATCH 31/32] Add search by postcode and house number with tests Added a new locator method `SearchCompanyByPostalAndHuisNummer` in `Locators.cs` to search for a company by postcode and house number within a table. Introduced a new test method `SearchByPostcodeAndHuisnummer_MultipleRecordsAsync` in `SearchCompanyScenarios.cs` to verify the functionality of searching a company using a postcode and house number that is associated with multiple records. This test navigates to the start page, initiates a new contact moment, navigates to the company search page, fills in the postcode and house number, clicks the search button, and verifies that multiple records are displayed. Added another test method `SearchByNonExistentPostcodeAndHuisnummerAsync` in `SearchCompanyScenarios.cs` to verify the behavior when searching for a company using a postcode and house number that does not exist in the database. This test follows similar steps as the previous one but checks for a message indicating no results found. These changes enhance the application's functionality and robustness by ensuring the search feature works correctly in different scenarios. --- .../ContactMomentSearch/Helpers/Locators.cs | 6 +- .../SearchCompanyScenarios.cs | 67 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs index 48169f556..9698460bc 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/Helpers/Locators.cs @@ -64,7 +64,11 @@ public static ILocator Company_KvknummerSearchButton(this IPage page) => public static ILocator Company_PostcodeHuisnummerSearchButton(this IPage page) => page.Locator("form").Filter(new() { HasText = "Postcode Huisnummer Zoeken" }).GetByRole(AriaRole.Button); - + + public static ILocator SearchCompanyByPostalAndHuisNummer(this IPage page, string postcode, string huisNummer) + { + return page.GetByRole(AriaRole.Table).Locator($"tbody tr:has(td:nth-child(4):has-text(\"{postcode.Trim()} {huisNummer.Trim()}\"))"); + } } diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs index 4d167a4f5..45cc25a46 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs @@ -254,6 +254,73 @@ public async Task SearchByPostcodeAndHuisnummerAsync() } + [TestMethod("9. Searching a company using postcode and huisnummer associated with multiple records")] + public async Task SearchByPostcodeAndHuisnummer_MultipleRecordsAsync() + { + await Step("Given user is on the startpagina"); + + await Page.GotoAsync("/"); + + await Step("And user starts a new Contactmoment"); + + await Page.CreateNewContactmomentAsync(); + + await Step("When user clicks Bedrijf from the menu item"); + + await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); + + await Step("And the user enters '2352SZ' in the field postcode and '37' in field Huisnummer"); + + var postCode = "2352SZ"; + var huisNummer = "37"; + await Page.Company_PostcodeInput().FillAsync(postCode); + await Page.Company_HuisnummerInput().FillAsync(huisNummer); + + await Step("And clicks the search button"); + + await Page.Company_PostcodeHuisnummerSearchButton().ClickAsync(); + + await Step("Then list of multiple records associated with postcode '2352SZ' and huisnummer '37' is displayed"); + + await Expect(Page.GetByRole(AriaRole.Table)).ToBeVisibleAsync(); + + var resultCount = await Page.SearchCompanyByPostalAndHuisNummer(postCode, huisNummer).CountAsync(); + + Assert.IsTrue(resultCount > 1, $"Expected multiple records associated with postcode '2352SZ' and huisnummer '37', but found {resultCount}."); + } + + + [TestMethod("10. Searching a company using postcode and huisnummer which is not present in DB")] + public async Task SearchByNonExistentPostcodeAndHuisnummerAsync() + { + await Step("Given user is on the startpagina"); + + await Page.GotoAsync("/"); + + await Step("And user starts a new Contactmoment"); + + await Page.CreateNewContactmomentAsync(); + + await Step("When user clicks Bedrijf from the menu item"); + + await Page.GetByRole(AriaRole.Link, new() { Name = "Bedrijven" }).ClickAsync(); + + await Step("And the user enters '1234AB' in the field postcode and '10' in field Huisnummer"); + + await Page.Company_PostcodeInput().FillAsync("1234AB"); + await Page.Company_HuisnummerInput().FillAsync("10"); + + await Step("And clicks the search button"); + + await Page.Company_PostcodeHuisnummerSearchButton().ClickAsync(); + + await Step("Then message is displayed as 'Geen resultaten gevonden voor '1234AB, 10''."); + + await Expect(Page.GetByRole(AriaRole.Caption)).ToHaveTextAsync("Geen resultaten gevonden voor '1234AB, 10'."); + } + + + From df04972bb0e700df215e185f0a953d061ab2d426 Mon Sep 17 00:00:00 2001 From: Henok Solomon Date: Tue, 11 Feb 2025 18:19:14 +0300 Subject: [PATCH 32/32] Add assertions for company name visibility in tests Enhanced SearchCompanyScenarios.cs by adding `await Expect` statements to verify the visibility of company names after search actions. This ensures the correct company name is displayed on the information page. Minor formatting adjustments were also made for better code structure. --- .../ContactMomentSearch/SearchCompanyScenarios.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs index 4d167a4f5..433e45f7a 100644 --- a/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs +++ b/Kiss.Bff.EndToEndTest/ContactMomentSearch/SearchCompanyScenarios.cs @@ -72,8 +72,9 @@ public async Task SearchByBedrijfsnaam_UniqueResultAsync() await Step("Then user is navigated to bedrijfsinformatie page"); await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync(); + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Test Stichting Bolderbast" })).ToBeVisibleAsync(); - } + } @@ -131,8 +132,9 @@ public async Task SearchByKvknummerAsync() await Step("Then user is navigated to bedrijfinformatie page of Test Stichting Bolderbast"); await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync(); + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Test Stichting Bolderbast" })).ToBeVisibleAsync(); - } + } [TestMethod("5. Searching a company using KVK-nummer with multiple records")] public async Task SearchByKvknummer_MultipleRecordsAsync() @@ -193,7 +195,8 @@ public async Task SearchByVestigingsnummer_UniqueResultAsync() await Step("Then user is navigated to bedrijfinformatie page of Test BV Donald Nevenvestiging"); await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync(); - + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Test BV Donald Nevenvestiging" })).ToBeVisibleAsync(); + } @@ -251,8 +254,9 @@ public async Task SearchByPostcodeAndHuisnummerAsync() await Step("Then user is navigated to Bedrijfinformatie page of Test BV Donald Nevenvestiging"); await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Bedrijfsinformatie" })).ToBeVisibleAsync(); + await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Test BV Donald Nevenvestiging" })).ToBeVisibleAsync(); - } + }