Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#827 playwright test stappen nieuwswerkinstructies skills filter #921

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 35 additions & 58 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 @@ -246,35 +244,35 @@ private async Task<int> 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]
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
Loading