Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions admin/tests/FluentCMS.Admin.EndToEnd/NavigationProgressTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ public sealed class NavigationProgressTests(EndToEndHost host) : BrowserTest(hos
// Past the shell's limit for the reads of a new content locale, 75 s, and short of the client's 100 s per attempt.
private static readonly LocatorAssertionsToBeVisibleOptions PastTheLimit = new() { Timeout = 95_000 };

// Not on WebKit (spec 7, #3649): WebKit takes the assembly from its cache on the reload, and the route that holds it never sees it.
[Fact]
[Trait("NotOn", "webkit")]
public async Task AReloadOfAnAdministrationRouteShowsTheShellAndALoadingStateBeforeThePage()
{
var browser = await OpenBrowserAsync();
var tab = await SignedInTabAsync(browser, "users", await Host.CreateEditorAsync("Super Admin"));
var tab = await SignedInTabNotStoringAsync(browser, "users", Administration);
await Expect(AreaHeading(tab, "Users")).ToBeVisibleAsync();
var fetched = Requests(tab, Administration);
var download = await HoldAsync(tab, url => Administration.IsMatch(url.AbsolutePath));
Expand All @@ -45,13 +43,11 @@ public async Task AReloadOfAnAdministrationRouteShowsTheShellAndALoadingStateBef
browser.PolicyViolations.ShouldBeEmpty();
}

// Not on WebKit, as the case above.
[Fact]
[Trait("NotOn", "webkit")]
public async Task AReloadOfAHalfsRouteShowsTheShellAndALoadingStateBeforeThePage()
{
var browser = await OpenBrowserAsync();
var tab = await SignedInTabAsync(browser, "media", await Host.CreateEditorAsync("Super Admin"));
var tab = await SignedInTabNotStoringAsync(browser, "media", MediaHalf);
await Expect(MediaHeading(tab)).ToBeVisibleAsync();
var fetched = Requests(tab, MediaHalf);
var download = await HoldAsync(tab, url => MediaHalf.IsMatch(url.AbsolutePath));
Expand Down Expand Up @@ -155,6 +151,30 @@ private static async Task ChangeLocaleAsync(AdminTab tab, string route, ILocator
await Expect(tab.Page).ToHaveURLAsync(new Regex(Regex.Escape(route) + "$"));
}

// A tab signed in at the route. On WebKit its assembly is answered as not to be stored, so that a reload downloads it again:
// WebKit would take it from its cache, and the route that holds it would never see it (#3649). Not on Chromium, which
// accepts the host's certificate by its key alone, a flag Playwright's own fetch of the answer does not have.
private async Task<AdminTab> SignedInTabNotStoringAsync(AdminBrowser browser, string path, Regex file)
{
var tab = await browser.NewTabAsync();
if (Host.Engine == BrowserEngine.WebKit)
{
await tab.Page.RouteAsync(url => file.IsMatch(new Uri(url).AbsolutePath), async route =>
{
var response = await route.FetchAsync();
await route.FulfillAsync(new RouteFulfillOptions
{
Response = response,
Headers = new Dictionary<string, string> { ["content-type"] = response.Headers["content-type"], ["cache-control"] = "no-store" },
});
});
}

await tab.Page.GotoAsync(new Uri(Host.Admin, path).AbsoluteUri);
await browser.SignInOnTheHostedPageAsync(tab, await Host.CreateEditorAsync("Super Admin"));
return tab;
}

// The requests the predicate matches wait until the returned source is set; one the page has given up on meanwhile is
// left as it is.
private static async Task<TaskCompletionSource> HoldAsync(AdminTab tab, Func<Uri, bool> held)
Expand Down
2 changes: 1 addition & 1 deletion docs/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The admin is built for the last two versions of Chrome, Edge, Firefox and Safari

The repository's end-to-end tests drive the admin in Chromium, against a publish of the reference host and against its image, and check every view with axe-core in the light and the dark theme, and on the publish right to left as well. Some cases also run at the width of a tablet.

Every night the same tests run in Firefox and in WebKit, Safari's engine, against the publish. Three cases are left out in WebKit, each with an issue: closing a tab with nothing unsaved ([#3648](https://github.com/fluentcms/FluentCMS/issues/3648)) and the loading state on the reload of a lazily loaded page, in two cases ([#3649](https://github.com/fluentcms/FluentCMS/issues/3649)). The list is in section 7 of the [admin technical specification](planning/admin-technical-spec.md#7-testing).
Every night the same tests run in Firefox and in WebKit, Safari's engine, against the publish. One case is left out in WebKit, with an issue: closing a tab with nothing unsaved ([#3648](https://github.com/fluentcms/FluentCMS/issues/3648)). The list is in section 7 of the [admin technical specification](planning/admin-technical-spec.md#7-testing).

## Language and formats

Expand Down
3 changes: 2 additions & 1 deletion docs/planning/admin-technical-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,8 @@ The nightly run has a job for each, `End-to-end (admin, firefox)` and `End-to-en
| Case | Left out on | Why | Issue |
| --- | --- | --- | --- |
| `FormBehaviourTests.ATabWithoutUnsavedChangesClosesWithoutAQuestion` | WebKit | Playwright's WebKit runs the unload handlers of `close` with `RunBeforeUnload` and never closes the page, with or without a handler | [#3648] |
| `NavigationProgressTests.AReloadOfAnAdministrationRouteShowsTheShellAndALoadingStateBeforeThePage` and `.AReloadOfAHalfsRouteShowsTheShellAndALoadingStateBeforeThePage` | WebKit | on the reload WebKit takes the lazily loaded assembly from its cache, often enough to fail a run, so the route that holds its download never sees a request and the page shows at once | [#3649] |

The two reload cases of `NavigationProgressTests` run in WebKit too ([#3649]): there the case answers the lazily loaded assembly of its first visit as not to be stored, since WebKit would take it from its cache on the reload and the route that holds its download would never see a request.

## 8. Feature inventory

Expand Down