Vibe Google Analytics

This commit is contained in:
2026-06-25 18:55:04 -04:00
parent fdf8e754f5
commit 73ae3eac53
86 changed files with 53925 additions and 46039 deletions
+9 -10
View File
@@ -1,5 +1,4 @@
using Microsoft.Playwright;
using Microsoft.Playwright.NUnit;
using Microsoft.Playwright.NUnit;
using Tests.PageObjects;
namespace Tests;
@@ -8,10 +7,6 @@ namespace Tests;
[TestFixture]
public class FeatureTests : PageTest
{
private DecksPage _decksPage;
private DeckDetailPage _deckDetailPage;
private AgentsPage _agentsPage;
[SetUp]
public void Setup()
{
@@ -20,17 +15,21 @@ public class FeatureTests : PageTest
_agentsPage = new AgentsPage(Page);
}
private DecksPage _decksPage;
private DeckDetailPage _deckDetailPage;
private AgentsPage _agentsPage;
[Test]
public async Task DeckManaCurve_ShouldBeVisibleOnDetail()
{
await _decksPage.GotoAsync();
// Assuming there is at least one deck. If not, this might need a more robust approach.
var deckCards = _decksPage.GetDeckCards();
await Expect(deckCards.First).ToBeVisibleAsync();
await deckCards.First.ClickAsync();
await Expect(_deckDetailPage.ManaCurve).ToBeVisibleAsync();
var barCount = await _deckDetailPage.GetManaBarCountAsync();
Assert.That(barCount, Is.GreaterThan(0));
@@ -43,4 +42,4 @@ public class FeatureTests : PageTest
await _agentsPage.WaitForGridAsync();
await Expect(_agentsPage.Grid).ToBeVisibleAsync();
}
}
}
+10 -5
View File
@@ -4,15 +4,20 @@ namespace Tests.PageObjects;
public class AgentsPage : BasePage
{
public AgentsPage(IPage page) : base(page) { }
public async Task GotoAsync() => await NavigateToAsync("/agents");
public AgentsPage(IPage page) : base(page)
{
}
public ILocator Grid => Page.Locator(".agents-grid");
public async Task GotoAsync()
{
await NavigateToAsync("/agents");
}
public async Task WaitForGridAsync()
{
await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
await Grid.WaitForAsync();
}
}
}
+6 -3
View File
@@ -4,8 +4,8 @@ namespace Tests.PageObjects;
public abstract class BasePage
{
protected readonly IPage Page;
protected readonly string BaseUrl = "http://localhost:5256";
protected readonly IPage Page;
protected BasePage(IPage page)
{
@@ -17,5 +17,8 @@ public abstract class BasePage
await Page.GotoAsync($"{BaseUrl}{path}");
}
public ILocator GetHeading() => Page.Locator("h1");
}
public ILocator GetHeading()
{
return Page.Locator("h1");
}
}
+8 -3
View File
@@ -4,12 +4,17 @@ namespace Tests.PageObjects;
public class DeckDetailPage : BasePage
{
public DeckDetailPage(IPage page) : base(page) { }
public DeckDetailPage(IPage page) : base(page)
{
}
public ILocator ManaCurve => Page.Locator(".mana-curve");
public ILocator ManaBars => Page.Locator(".mana-bar");
public ILocator ManaBarLabels => Page.Locator(".mana-bar-label");
public ILocator ManaCosts => Page.Locator(".mana-cost");
public async Task<int> GetManaBarCountAsync() => await ManaBars.CountAsync();
}
public async Task<int> GetManaBarCountAsync()
{
return await ManaBars.CountAsync();
}
}
+15 -6
View File
@@ -4,14 +4,23 @@ namespace Tests.PageObjects;
public class DecksPage : BasePage
{
public DecksPage(IPage page) : base(page) { }
public DecksPage(IPage page) : base(page)
{
}
public async Task GotoAsync() => await NavigateToAsync("/decks");
public async Task GotoAsync()
{
await NavigateToAsync("/decks");
}
public ILocator GetDeckCards()
{
return Page.Locator(".deck-card");
}
public ILocator GetDeckCards() => Page.Locator(".deck-card");
public async Task ClickDeckByNameAsync(string name)
{
await Page.Locator(".deck-card-title").GetByText(name, new() { Exact = true }).ClickAsync();
await Page.Locator(".deck-card-title").GetByText(name, new LocatorGetByTextOptions { Exact = true })
.ClickAsync();
}
}
}
+3 -2
View File
@@ -1,3 +1,4 @@
using System.Text.RegularExpressions;
using Microsoft.Playwright;
using Microsoft.Playwright.NUnit;
@@ -13,8 +14,8 @@ public class PlaywrightTests : PageTest
public async Task HomePage_ShouldLoad()
{
await Page.GotoAsync(BaseUrl);
await Expect(Page).ToHaveTitleAsync(new System.Text.RegularExpressions.Regex("Chrono CCG"));
await Expect(Page).ToHaveTitleAsync(new Regex("Chrono CCG"));
// Check for some content that should be on the home page
var heading = Page.Locator("h1");
await Expect(heading).ToBeVisibleAsync();
+1 -2
View File
@@ -7,14 +7,13 @@ namespace Tests;
[TestFixture]
public class TelerikLicenseTests : PageTest
{
private const string BaseUrl = "http://localhost:5256";
[Test]
public async Task TelerikLicenseBannerIsNotVisible()
{
await Page.GotoAsync(BaseUrl + "/agents");
await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
var grid = Page.Locator(".agents-grid");
await Expect(grid).ToBeVisibleAsync();
+16 -21
View File
@@ -1,30 +1,24 @@
using System.Diagnostics;
using System.Net.Http;
namespace Tests;
[SetUpFixture]
public class TestSetup
{
private Process? _serverProcess;
private const string ServerUrl = "http://localhost:5256";
private Process? _serverProcess;
[OneTimeSetUp]
public async Task BeforeAllTests()
{
Console.WriteLine("[DEBUG_LOG] Starting Server...");
// Find solution root
var currentDir = AppContext.BaseDirectory;
while (currentDir != null && !File.Exists(Path.Combine(currentDir, "Chrono.sln")))
{
currentDir = Path.GetDirectoryName(currentDir);
}
if (currentDir == null)
{
throw new Exception("Could not find Chrono.sln to determine project path.");
}
if (currentDir == null) throw new Exception("Could not find Chrono.sln to determine project path.");
var projectPath = Path.Combine(currentDir, "Server", "Server.csproj");
@@ -40,25 +34,27 @@ public class TestSetup
};
_serverProcess = Process.Start(startInfo);
_serverProcess.OutputDataReceived += (s, e) => { if (e.Data != null) Console.WriteLine($"[SERVER OUT] {e.Data}"); };
_serverProcess.ErrorDataReceived += (s, e) => { if (e.Data != null) Console.WriteLine($"[SERVER ERR] {e.Data}"); };
_serverProcess.OutputDataReceived += (s, e) =>
{
if (e.Data != null) Console.WriteLine($"[SERVER OUT] {e.Data}");
};
_serverProcess.ErrorDataReceived += (s, e) =>
{
if (e.Data != null) Console.WriteLine($"[SERVER ERR] {e.Data}");
};
_serverProcess.BeginOutputReadLine();
_serverProcess.BeginErrorReadLine();
if (_serverProcess == null)
{
throw new Exception("Failed to start server process.");
}
if (_serverProcess == null) throw new Exception("Failed to start server process.");
// Wait for the server to be ready
using var client = new HttpClient();
var sw = Stopwatch.StartNew();
var timeout = TimeSpan.FromSeconds(30);
bool isReady = false;
var isReady = false;
while (sw.Elapsed < timeout)
{
try
{
var response = await client.GetAsync(ServerUrl);
@@ -73,14 +69,13 @@ public class TestSetup
// Wait and retry
await Task.Delay(1000);
}
}
if (!isReady)
{
_serverProcess.Kill(true);
throw new Exception($"Server did not start within {timeout.TotalSeconds} seconds.");
}
Console.WriteLine("[DEBUG_LOG] Server is ready.");
}
@@ -94,4 +89,4 @@ public class TestSetup
_serverProcess.Dispose();
}
}
}
}