Files
ChronoCCG/Chrono/Tests/PlaywrightTests.cs
T

47 lines
1.6 KiB
C#

using Microsoft.Playwright.NUnit;
namespace Tests;
[Parallelizable(ParallelScope.Self)]
[TestFixture]
public class PlaywrightTests : PageTest
{
[Test]
public async Task CanWriteAndSaveNote()
{
// 1. Navigate to the cards gallery
await Page.GotoAsync("http://localhost:8080/cards");
// 2. Wait for cards to load - looking for at least one card-cell
await Expect(Page.Locator(".card-cell").First).ToBeVisibleAsync();
// 3. Find an Agent card and click it.
var agentCard = Page.Locator(".card-cell:has(.card-category-badge.agent)").First;
await agentCard.ClickAsync();
// 4. Wait for the detail view to show the note textarea
var noteInput = Page.Locator(".note-input");
await Expect(noteInput).ToBeVisibleAsync();
// 5. Type a unique note
var uniqueNote = "Test note " + Guid.NewGuid();
await noteInput.FillAsync(uniqueNote);
// 6. Blur to trigger save
await noteInput.BlurAsync();
// 7. Wait for saving indicator to disappear (if it appeared)
var savingIndicator = Page.Locator(".saving-indicator");
if (await savingIndicator.IsVisibleAsync()) await Expect(savingIndicator).Not.ToBeVisibleAsync();
// 8. Close the detail view by clicking the backdrop
await Page.Locator(".modal-backdrop").ClickAsync();
await Expect(noteInput).Not.ToBeVisibleAsync();
// 9. Re-open the same agent card
await agentCard.ClickAsync();
// 10. Verify the note is still there
await Expect(noteInput).ToHaveValueAsync(uniqueNote);
}
}