Skip to content

Commit

Permalink
fix skill deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
felixcicatt committed Dec 17, 2024
1 parent 3c2de0f commit eb030b8
Showing 1 changed file with 11 additions and 34 deletions.
45 changes: 11 additions & 34 deletions Kiss.Bff.EndToEndTest/NieuwsEnWerkInstructies.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Xml.Linq;

namespace Kiss.Bff.EndToEndTest;
namespace Kiss.Bff.EndToEndTest;

[TestClass]
public class NieuwsEnWerkInstructies : BaseTestInitializer
Expand Down Expand Up @@ -251,7 +249,7 @@ private async Task<int> 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
{
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit eb030b8

Please sign in to comment.