Skip to content

Commit 6fda746

Browse files
committed
Add E2E test
1 parent d372960 commit 6fda746

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

src/Components/test/E2ETest/ServerExecutionTests/StreamingRenderingTest.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,20 @@ public void CanPerformStreamingRendering()
6464
Browser.FindElement(By.Id("end-response-link")).Click();
6565
Browser.Equal("Finished", () => getStatusText().Text);
6666
}
67+
68+
[Fact]
69+
public void CanPerformFormPostWithStreamedResponses()
70+
{
71+
Navigate($"{ServerPathBase}/form-streaming");
72+
73+
// Initial "waiting" state
74+
var submit = Browser.Exists(By.CssSelector("input[type=submit]"));
75+
var getStatusText = () => Browser.Exists(By.Id("status"));
76+
Assert.Equal("", getStatusText().Text);
77+
78+
submit.Click();
79+
80+
Assert.Equal("Processing form...", getStatusText().Text);
81+
Assert.Equal("Completed", getStatusText().Text);
82+
}
6783
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@page "/form-streaming"
2+
@using Microsoft.AspNetCore.Components.Forms
3+
@attribute [StreamRendering(true)]
4+
5+
<h1>Streaming Rendering</h1>
6+
7+
@* This just sets the context for the binding, this happens normally inside RouteView *@
8+
<CascadingModelBinder Name="/form-streaming">
9+
<EditForm id="process" method="POST" OnValidSubmit="ProcessForm">
10+
<input type="submit" value="Process form" />
11+
</EditForm>
12+
</CascadingModelBinder>
13+
14+
<p id="status">
15+
@if (_processing)
16+
{
17+
<text>Processing form...</text>
18+
}
19+
else if (_done)
20+
{
21+
<text>Completed</text>
22+
}
23+
</p>
24+
25+
@code {
26+
bool _processing = false;
27+
bool _done = false;
28+
29+
private async Task ProcessForm()
30+
{
31+
_processing = true;
32+
await Task.Yield();
33+
_processing = false;
34+
_done = true;
35+
}
36+
}

0 commit comments

Comments
 (0)