Skip to content

Conversation

ilonatommy
Copy link
Member

Use Photino sample app in E2E tests

The test was quarantined with 100% failure rate. The issue was with the test setup - we did not create _framework dir and because of that, no blazor was started, the test was failing. I did not track down the direct reason why the test broke at some point. The test is launching a process with .dll pointing to its own project. That project has an entry point that manages opening Photino window, communication between .net and JS and checking if buttons were clicked properly.

We have a sample application that is launching blazor app with Photino framework. That sample did not manifest any issues, was creating _framework dir and the code copied from E2E test is able to run there without problems. Because we were already using dotnet process to run the .dll in the original E2E test, we can as well run the sample app .dll from our E2E test. It cleans up some code and removes duplicating similar functionality in two projects.

Description

  • Sample Photino application was changed to serve multiple modes: basic test mode (new) and sample launch mode (old). It's easy to add more of them later if needed. The basic test mode is 1:1 copy of code that used to be in E2E project. There's a bunch of changes connected with moving the code from Microsoft.AspNetCore.Components.WebViewE2E.Test.csproj to PhotinoTestApp.csproj.
  • PhotinoTestApp.csproj had a hardcoded configuration name in assets path, it did not have a direct impact on the issue but it got fixed.
  • Microsoft.AspNetCore.Components.WebViewE2E.Test.csproj does not need an entrypoint anymore, the sdk type got changed and a cleanup was done.

Fixes #54017.

@ilonatommy ilonatommy added this to the 10.0-rc2 milestone Sep 1, 2025
@ilonatommy ilonatommy self-assigned this Sep 1, 2025
@Copilot Copilot AI review requested due to automatic review settings September 1, 2025 14:23
@ilonatommy ilonatommy requested a review from a team as a code owner September 1, 2025 14:23
@github-actions github-actions bot added the area-blazor Includes: Blazor, Razor Components label Sep 1, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the failing Photino E2E tests by refactoring the test setup to use the existing PhotinoTestApp sample instead of running the test assembly directly. The key issue was that the test was not creating the required _framework directory, preventing Blazor from starting.

  • Consolidates the E2E test functionality into the existing PhotinoTestApp sample
  • Adds multiple execution modes to PhotinoTestApp (basic test mode and sample launch mode)
  • Updates the E2E test to launch PhotinoTestApp with --basic-test argument instead of running its own assembly

Reviewed Changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Components/WebView/test/E2ETest/Microsoft.AspNetCore.Components.WebViewE2E.Test.csproj Changed SDK type and removed executable configuration since it no longer needs an entry point
src/Components/WebView/test/E2ETest/WebViewManagerE2ETests.cs Updated test to launch PhotinoTestApp.dll with --basic-test argument instead of the test assembly
src/Components/WebView/test/E2ETest/Program.cs Removed entry point since test now uses PhotinoTestApp
src/Components/WebView/test/E2ETest/wwwroot/css/app.css Removed CSS file as it's no longer needed
src/Components/WebView/test/E2ETest/_Imports.razor Removed imports file as it's no longer needed
src/Components/WebView/Samples/PhotinoPlatform/testassets/PhotinoTestApp/Program.cs Refactored to support multiple execution modes via command line arguments
src/Components/WebView/Samples/PhotinoPlatform/testassets/PhotinoTestApp/LaunchSample.cs New class containing the original sample app functionality
src/Components/WebView/Samples/PhotinoPlatform/testassets/PhotinoTestApp/BasicTest.cs New class containing the E2E test functionality moved from the test project
src/Components/WebView/Samples/PhotinoPlatform/testassets/PhotinoTestApp/IExecutionMode.cs New interface for different execution modes
src/Components/WebView/Samples/PhotinoPlatform/testassets/PhotinoTestApp/PhotinoTestApp.csproj Fixed hardcoded configuration name in assets path

Copy link
Member

@javiercn javiercn left a comment

Choose a reason for hiding this comment

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

Looks great.

Minor comments

@ilonatommy
Copy link
Member Author

ilonatommy commented Sep 1, 2025

The failure is connected, the way we're finding the dll on CI is faulty:

System.IO.FileNotFoundException : Could not find PhotinoTestApp.dll at: C:\h\w\B4240959\w\A4C608BF\e\PhotinoTestApp.dll

@ilonatommy
Copy link
Member Author

ilonatommy commented Sep 2, 2025

This is not the best logging:

2025-09-02T14:31:19.2176998Z [xUnit.net 00:00:11.07]     Microsoft.AspNetCore.Components.WebViewE2E.Test.WebViewManagerE2ETests.CanLaunchPhotinoWebViewAndClickButton [FAIL]
2025-09-02T14:31:19.2181608Z [xUnit.net 00:00:11.07]       Assert.Contains() Failure: Sub-string not found
2025-09-02T14:31:19.2184931Z [xUnit.net 00:00:11.07]       String:    "Current directory: C:\\h\\w\\BFF00A1F\\w\\AC23"···
2025-09-02T14:31:19.2188089Z [xUnit.net 00:00:11.07]       Not found: "Test passed? True"
2025-09-02T14:31:19.2191800Z [xUnit.net 00:00:11.07]       Stack Trace:
2025-09-02T14:31:19.2201617Z [xUnit.net 00:00:11.08]         /_/src/Components/WebView/test/E2ETest/WebViewManagerE2ETests.cs(54,0): at Microsoft.AspNetCore.Components.WebViewE2E.Test.WebViewManagerE2ETests.CanLaunchPhotinoWebViewAndClickButton()
2025-09-02T14:31:19.2204714Z [xUnit.net 00:00:11.08]         --- End of stack trace from previous location ---
2025-09-02T14:31:19.3753557Z [xUnit.net 00:00:11.23]   Finished:    Microsoft.AspNetCore.Components.WebViewE2E.Test
2025-09-02T14:31:19.4035302Z Data collector 'Blame' message: VSTEST_DUMP_PATH is specified. Dump files will be saved in: C:\cores, and won't be added to attachments..

Locally it's passing. We have to log the details better and check how to fix it.

[Edit]
that's better:

2025-09-02T16:45:55.0585772Z [xUnit.net 00:00:19.64]       Exception System.IO.DirectoryNotFoundException while creating window: C:\h\w\A18C0893\w\A7AF08C3\e\wwwroot\
2025-09-02T16:45:55.0587843Z [xUnit.net 00:00:19.64]          at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters)
2025-09-02T16:45:55.0590165Z [xUnit.net 00:00:19.64]          at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root)
2025-09-02T16:45:55.0592529Z [xUnit.net 00:00:19.64]          at Microsoft.AspNetCore.Components.WebView.Photino.BlazorWindow..ctor(String title, String hostPage, IServiceProvider services, Action`1 configureWindow, String pathBase) in D:\a\_work\1\s\src\Components\WebView\Samples\PhotinoPlatform\src\BlazorWindow.cs:line 47
2025-09-02T16:45:55.0594814Z [xUnit.net 00:00:19.64]          at BasicTest.Run() in D:\a\_work\1\s\src\Components\WebView\Samples\PhotinoPlatform\testassets\PhotinoTestApp\BasicTest.cs:line 48

wwwroot is not copied to artifacts on CI.

@ilonatommy
Copy link
Member Author

ilonatommy commented Sep 3, 2025

wwwroot problem is solved, now we have a problem with WebView communication with the C# code (or with blazor start):

2025-09-03T08:30:24.9480856Z [xUnit.net 00:00:20.28]       Asking WebView for current controlDiv value...
2025-09-03T08:30:24.9483861Z [xUnit.net 00:00:20.28]       Photino.NET: "Hello, world!".SendWebMessage(wvt:GetControlDivValue)
2025-09-03T08:30:24.9487804Z [xUnit.net 00:00:20.28]       Waiting for controlDiv to have value '0', but it's still '', so waiting 250ms.
2025-09-03T08:30:24.9491007Z [xUnit.net 00:00:20.28]       Waited 7500ms but couldn't get controlDiv to have value '0' (last value is '').
2025-09-03T08:30:24.9494388Z [xUnit.net 00:00:20.28]       Photino.NET: "Hello, world!".Close()
2025-09-03T08:30:24.9497499Z [xUnit.net 00:00:20.28]       Test passed? False

@ilonatommy
Copy link
Member Author

ilonatommy commented Sep 3, 2025

This time web view did not even get ready, last time it got ready in the middle of the timeout but we added some logging, it might have slowed it down enough to pass the deadline. Is CI significantly slower than my local machine? Let's increase timeouts.

[edit]
This might be tricky. Originally, the issue was quarantined due to timeouts. This is an attempt of investigating the issue: #54608.

@ilonatommy
Copy link
Member Author

Dropping for now. It's a purely test issue, what's more - it's failing only on CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing test CanLaunchPhotinoWebViewAndClickButton in 8.0 on Windows.Amd64.Server.2022
2 participants