Skip to content

Add sample dashboard playwright test#4386

Merged
adamint merged 24 commits intomicrosoft:mainfrom
adamint:dev/adamint/playwright-dashboard-run-oop
Jul 9, 2024
Merged

Add sample dashboard playwright test#4386
adamint merged 24 commits intomicrosoft:mainfrom
adamint:dev/adamint/playwright-dashboard-run-oop

Conversation

@adamint
Copy link
Copy Markdown
Member

@adamint adamint commented Jun 4, 2024

Runs dashboard with a mocked dashboard client, adds example playwright test, as we will be adding many more dashboard playwright tests using the same infrastructure in the future.

Microsoft Reviewers: Open in CodeFlow

@ghost ghost added the area-dashboard label Jun 4, 2024
@Meir017
Copy link
Copy Markdown
Contributor

Meir017 commented Jun 5, 2024

related to #958

@adamint adamint changed the title [draft] dashboard frontend playwright tests Add sample dashboard playwright test Jun 17, 2024
@adamint adamint marked this pull request as ready for review June 17, 2024 19:35
@RussKie
Copy link
Copy Markdown
Contributor

RussKie commented Jun 18, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@adamint
Copy link
Copy Markdown
Member Author

adamint commented Jun 25, 2024

Could I get a review on this?

@adamint adamint requested review from danmoseley and radical June 25, 2024 18:21
Adam Ratzman added 2 commits June 25, 2024 14:22
@radical
Copy link
Copy Markdown
Member

radical commented Jun 25, 2024

Build failing with: tests/Aspire.Dashboard.Tests/Integration/Playwright/DashboardServerFixture.cs(30,35): error CS0117: (NETCORE_ENGINEERING_TELEMETRY=Build) 'DashboardConfigNames' does not contain a definition for 'DashboardOtlpUrlName'

@adamint
Copy link
Copy Markdown
Member Author

adamint commented Jun 26, 2024

DashboardOtlpUrlName

Sorry, @radical. That property name was seemingly changed and I did not notice after merge. It builds now 😄

Comment thread tests/Aspire.Dashboard.Tests/Integration/Playwright/DashboardServerFixture.cs Outdated
Comment thread tests/Aspire.Dashboard.Tests/Integration/Playwright/DashboardServerFixture.cs Outdated

public async Task InitializeAsync()
{
var installExitCode = Microsoft.Playwright.Program.Main(new[] {"install"});
Copy link
Copy Markdown
Member

@radical radical Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will run once for every class using this fixture.

EDIT: doing this once would be better.

throw new PlaywrightException($"Playwright exited with code {installExitCode}");
}

var installDepsExitCode = Microsoft.Playwright.Program.Main(new[] {"install-deps"});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the linux (ubuntu) build machine install-deps will install a whole bunch of packages with apt-get. Because this is a shared machine, we want to avoid installing packages on it.

The existing infrastructure for installing playwright available is partially broken right now due to package installation issues (#4623). And these tests are likely to run into the same issue randomly.

So, I would suggest not running the Playwright based tests on linux for now. You can add this to your test - [ActiveIssue("https://github.com/dotnet/aspire/issues/4623", TestPlatforms.Linux)].

Going forward:

  1. [tests] Extract playwright bits to Playwright.targets, and separate class #4689 - this will make the existing playwright targets reusable
  2. Once Install some playwright dependencies on Ubuntu.2204.Amd64* helix agents dotnet/dnceng#3122 is resolved, we can drop even this code.
    Neither of these need to block your PR though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could you please open an issue to track that the code here needs to be adjusted once #4689 is merged, and dotnet/dnceng#3122 is fixed?

Copy link
Copy Markdown

@mxschmitt mxschmitt Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we strongly recommend doing install and --with-deps from the outside. Since these require sudo and modify the system. These should not delay the test execution and skipping it on Linux seems like showing the drawbacks for it.

lets call it from the CI yaml instead? This follows what Playwright users are used to.

@dotnet-policy-service dotnet-policy-service Bot added the needs-author-action An issue or pull request that requires more info or actions from the author. label Jun 27, 2024
@adamint adamint requested a review from radical June 28, 2024 13:32
Comment thread tests/Aspire.Dashboard.Tests/Integration/Playwright/AppBarTests.cs Outdated
throw new PlaywrightException($"Playwright exited with code {installExitCode}");
}

var installDepsExitCode = Microsoft.Playwright.Program.Main(new[] {"install-deps"});
Copy link
Copy Markdown

@mxschmitt mxschmitt Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we strongly recommend doing install and --with-deps from the outside. Since these require sudo and modify the system. These should not delay the test execution and skipping it on Linux seems like showing the drawbacks for it.

lets call it from the CI yaml instead? This follows what Playwright users are used to.


public async Task GoToHomeAndWaitForDataGridLoad(IPage page)
{
await page.GotoAsync("/");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend page -> Page like we have in our base classes.

Suggested change
await page.GotoAsync("/");
await Page.GotoAsync("/");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a method parameter, that does not follow naming conventions. If page were a property, I would agree

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thought its a property on the class where page gets created in TestInitialize etc. Feel free to ignore then.

Comment thread tests/Aspire.Dashboard.Tests/Integration/Playwright/PlaywrightFixture.cs Outdated
@adamint
Copy link
Copy Markdown
Member Author

adamint commented Jun 28, 2024

Usually we strongly recommend doing install and --with-deps from the outside. Since these require sudo and modify the system. These should not delay the test execution and skipping it on Linux seems like showing the drawbacks for it.

lets call it from the CI yaml instead?

This code was removed.

@danmoseley
Copy link
Copy Markdown
Member

Thanks @adamint . Does any of my feedback from your original PR apply here? (IDK)

Comment thread tests/Aspire.Dashboard.Tests/Aspire.Dashboard.Tests.csproj Outdated
@radical radical requested a review from eerhardt as a code owner June 28, 2024 21:50
public async Task AppBar_Change_Theme()
{
// Arrange
await RunTestAsync(async page =>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this can return RunTestAsync(..) directly.

@radical radical dismissed their stale review June 28, 2024 21:55

changes made

public async Task InitializeAsync()
{
PlaywrightProvider.DetectAndSetInstalledPlaywrightDependenciesPath();
Browser = await PlaywrightProvider.CreateBrowserAsync();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would create the browser instance, and launch the browser for every test class using this fixture. For workload tests we use:
https://github.com/adamint/aspire/blob/64ea4ab15976fbf903c9663aa6982205be8b1e2f/tests/Aspire.Workload.Tests/WorkloadTestsBase.cs#L22-L34
and private static Lazy<IBrowser> Browser => new(CreateBrowser);

@radical
Copy link
Copy Markdown
Member

radical commented Jun 29, 2024

Screenshot 2024-06-28 at 20 43 46

And the test was skipped on linux.

@dotnet-bot
Copy link
Copy Markdown
Contributor

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.ServiceDiscovery Branch 81 79.31 🔻
Microsoft.Extensions.ServiceDiscovery Line 81 79.01 🔻

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=724697&view=codecoverage-tab

…t-dashboard-run-oop

# Conflicts:
#	tests/Aspire.Workload.Tests/EmptyTemplateRunTests.cs
#	tests/Aspire.Workload.Tests/StarterTemplateRunTestsBase.cs
#	tests/Shared/Playwright/PlaywrightProvider.cs
@radical
Copy link
Copy Markdown
Member

radical commented Jul 2, 2024

@adamint I merged the base playwright changes in a separate PR, and update this one to fix the merge conflicts.

@adamint
Copy link
Copy Markdown
Member Author

adamint commented Jul 8, 2024

@adamint I merged the base playwright changes in a separate PR, and update this one to fix the merge conflicts.

Is anything else needed here? @radical
thank you 😄

@danmoseley not that I'm aware of. The recommendation is to avoid assuming the structure of the page, so locating elements by text instead of css classes is preferred

Copy link
Copy Markdown
Member

@radical radical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The infra bits LGTM 👍

@adamint adamint merged commit f647a66 into microsoft:main Jul 9, 2024
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants