From 3e66cebdbbcff3858528055d4cfa4c501c21d132 Mon Sep 17 00:00:00 2001 From: Erwin van der Valk Date: Thu, 13 Feb 2025 14:43:52 +0100 Subject: [PATCH] write traces to artifacts --- .github/workflow-gen/Program.cs | 17 +++++++++++++++++ .github/workflows/bff-ci.yml | 8 ++++++++ .../PageModels/PerComponentPageModel.cs | 4 +--- bff/test/Hosts.Tests/PlaywrightTestBase.cs | 2 +- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflow-gen/Program.cs b/.github/workflow-gen/Program.cs index 97037c3ae..044062195 100644 --- a/.github/workflow-gen/Program.cs +++ b/.github/workflow-gen/Program.cs @@ -202,6 +202,8 @@ void GenerateBffWorkflow(Product product) job.StepTest(product.Solution); + job.StepUploadPlaywrightTestTraces(product.Name); + job.StepToolRestore(); job.StepPack(product.Solution); @@ -476,6 +478,21 @@ public static Step StepPush(this Job job, string destination, string sourceUrl, .Run($"dotnet nuget push artifacts/*.nupkg --source {sourceUrl} --api-key {apiKey} --skip-duplicate"); } + public static Step StepUploadPlaywrightTestTraces(this Job job, string componentName) + { + var path = $"{componentName}/tests/**/playwright-traces/*.zip"; + return job.Step() + .Name("Upload playwright traces") + .If("success() || failure()") + .Uses("actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882") // 4.4.3 + .With( + ("name", "playwright-traces"), + ("path", path), + ("overwrite", "true"), + ("retention-days", "15")); + } + + public static Step StepUploadArtifacts(this Job job, string componentName) { var path = $"{componentName}/artifacts/*.nupkg"; diff --git a/.github/workflows/bff-ci.yml b/.github/workflows/bff-ci.yml index 5bbfe1d0e..450460472 100644 --- a/.github/workflows/bff-ci.yml +++ b/.github/workflows/bff-ci.yml @@ -60,6 +60,14 @@ jobs: reporter: dotnet-trx fail-on-error: true fail-on-empty: true + - name: Upload playwright traces + if: success() || failure() + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 + with: + name: playwright-traces + path: bff/tests/**/playwright-traces/*.zip + overwrite: true + retention-days: 15 - name: Tool restore run: dotnet tool restore - name: Pack bff.slnf diff --git a/bff/test/Hosts.Tests/PageModels/PerComponentPageModel.cs b/bff/test/Hosts.Tests/PageModels/PerComponentPageModel.cs index 93b1919f3..d3d9b5b64 100644 --- a/bff/test/Hosts.Tests/PageModels/PerComponentPageModel.cs +++ b/bff/test/Hosts.Tests/PageModels/PerComponentPageModel.cs @@ -26,9 +26,7 @@ public class CallApiPageModel : PerComponentPageModel { protected override async Task Verify() { - await Page.WaitForLoadStateAsync(); - - (await Page.TitleAsync()).ShouldBe("Call API"); + await Expect(Page.GetByText("InteractiveServer")).ToBeVisibleAsync(); } public async Task InvokeCallApi(string headingName) diff --git a/bff/test/Hosts.Tests/PlaywrightTestBase.cs b/bff/test/Hosts.Tests/PlaywrightTestBase.cs index 0ded85e3a..39f6b6384 100644 --- a/bff/test/Hosts.Tests/PlaywrightTestBase.cs +++ b/bff/test/Hosts.Tests/PlaywrightTestBase.cs @@ -39,6 +39,7 @@ public PlaywrightTestBase(ITestOutputHelper output, AppHostFixture fixture) public override async Task InitializeAsync() { await base.InitializeAsync(); + Context.SetDefaultTimeout(10_000); await Context.Tracing.StartAsync(new() { Title = $"{WithTestNameAttribute.CurrentClassName}.{WithTestNameAttribute.CurrentTestName}", @@ -81,7 +82,6 @@ public override BrowserNewContextOptions ContextOptions() // Even though we use dotnet dev-certs https --trust on the build agent, // it still claims the certs are invalid. IgnoreHTTPSErrors = true, - }; }