diff --git a/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies.cs b/Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies.cs index 633499485..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 @@ -246,35 +244,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 = "Playwright 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] @@ -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();