From b3878d3a8ce475c16426a12f94bc7044ceea4377 Mon Sep 17 00:00:00 2001 From: Justin Alink Date: Wed, 23 Oct 2024 17:07:07 +0200 Subject: [PATCH 1/2] Nieuwe Test --- .../NieuwsEnWerkInstructies.cs | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies.cs b/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies.cs index 633499485..d4be710c7 100644 --- a/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies.cs +++ b/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies.cs @@ -246,35 +246,35 @@ private async Task GetFeaturedCount() } + // This test covers Step 12. 13. 14. + [TestMethod] + public async Task Als_ik_een_skill_toevoeg_wordt_deze_vermeld_in_de_filter() + { + // Define the new skill name to be added and tested + var newSkill = "Test Skill"; - //[TestMethod] - //public async Task Als_ik_een_skill_toevoeg_wordt_deze_vermeld_in_de_filter() - //{ - // // Define the new skill name to be added and tested - // var newSkill = "Test Skill"; - - // try - // { - // // Step 1: Navigate to the Skills management page - // await NavigateToSkillsBeheer(); + try + { + // Step 1: Navigate to the Skills management page + await NavigateToSkillsBeheer(); - // // Step 2: Add the new skill - // await CreateSkill(newSkill); - // await Page.GotoAsync("/"); - // // Step 3: Open the filter dropdown to verify the skill - // await Page.ClickAsync("summary:has-text('Filter op categorie')"); + // Step 2: Add the new skill + await CreateSkill(newSkill); + await Page.GotoAsync("/"); + // Step 3: Open the filter dropdown to verify the skill + await Page.ClickAsync("summary:has-text('Filter op categorie')"); - // // Step 4: Verify the newly added skill appears in the filter list as a checkbox option - // var addedSkillCheckbox = Page.GetByRole(AriaRole.Checkbox, new() { Name = newSkill }).First; - // await Expect(addedSkillCheckbox).ToBeVisibleAsync(); + // Step 4: Verify the newly added skill appears in the filter list as a checkbox option + var addedSkillCheckbox = Page.GetByRole(AriaRole.Checkbox, new() { Name = newSkill }).First; + await Expect(addedSkillCheckbox).ToBeVisibleAsync(); - // } - // finally - // { - // // Optional clean-up: Remove the skill after test completion if necessary - // await DeleteSkill(newSkill); - // } - //} + } + finally + { + // clean-up: Remove the skill after test completion + await DeleteSkill(newSkill); + } + } //// Made private because the test isn't done yet, this is just a stepping stone made with the playwright editor //[TestMethod] From 0f84af5ee62558b2d921963e081e094e25be964b Mon Sep 17 00:00:00 2001 From: Felix Cornelissen Date: Tue, 17 Dec 2024 12:08:28 +0100 Subject: [PATCH 2/2] fix skill deletion --- .../NieuwsEnWerkInstructies.cs | 45 +++++-------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies.cs b/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies.cs index d4be710c7..d62bd6822 100644 --- a/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies.cs +++ b/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies.cs @@ -1,6 +1,4 @@ -using System.Xml.Linq; - -namespace Kiss.Bff.EndToEndTest; +namespace Kiss.Bff.EndToEndTest; [TestClass] public class NieuwsEnWerkInstructies : BaseTestInitializer @@ -251,7 +249,7 @@ private async Task GetFeaturedCount() public async Task Als_ik_een_skill_toevoeg_wordt_deze_vermeld_in_de_filter() { // Define the new skill name to be added and tested - var newSkill = "Test Skill"; + var newSkill = "Playwright Test Skill"; try { @@ -517,39 +515,18 @@ private async Task DeleteSkill(string skillName) // Step 1: Navigate to the Skills management page await NavigateToSkillsBeheer(); - // Step 2: Locate the skill item by its name - var skillLocator = Page.Locator($"li.listItem:has-text('{skillName}')").First; + // Step 2: Locate the skill listitem by its name + var skillLocator = Page.GetByRole(AriaRole.Listitem).Filter(new() { HasText = skillName }); - // Step 3: Check if the skill exists - if (await skillLocator.CountAsync() > 0) - { - // Step 4: Click the delete button for the specified skill - var deleteButton = skillLocator.Locator("button[title='Verwijderen']").First; - await Expect(deleteButton).ToBeVisibleAsync(); - await Expect(deleteButton).ToBeEnabledAsync(); - if (await deleteButton.IsVisibleAsync()) - { - // Handle the confirmation dialog - Page.Dialog += async (sender, dialog) => - { - await dialog.AcceptAsync(); // Accept the confirmation dialog - }; + // Step 3: Locate the delete button within the listitem + var deleteButton = skillLocator.GetByRole(AriaRole.Button).And(Page.GetByTitle("Verwijderen")); - await deleteButton.ClickAsync(); // Click the delete button - } - else - { - throw new Exception("Delete button is not visible."); - } + // Step 4: Click the delete button and accept the dialog + Page.Dialog += Accept; + await deleteButton.ClickAsync(); - // Step 7: Verify the skill is no longer present in the list - await Expect(skillLocator).ToBeHiddenAsync(); - } - else - { - // Handle the case where the skill does not exist - throw new Exception($"Skill '{skillName}' not found for deletion."); - } + // Step 5: Verify the skill is no longer present in the list + await Expect(skillLocator).ToBeHiddenAsync(); } static async void Accept(object? _, IDialog dialog) => await dialog.AcceptAsync();