Skip to content

Commit

Permalink
Add E2E test
Browse files Browse the repository at this point in the history
  • Loading branch information
javiercn committed Apr 14, 2023
1 parent d372960 commit 6fda746
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,20 @@ public void CanPerformStreamingRendering()
Browser.FindElement(By.Id("end-response-link")).Click();
Browser.Equal("Finished", () => getStatusText().Text);
}

[Fact]
public void CanPerformFormPostWithStreamedResponses()
{
Navigate($"{ServerPathBase}/form-streaming");

// Initial "waiting" state
var submit = Browser.Exists(By.CssSelector("input[type=submit]"));
var getStatusText = () => Browser.Exists(By.Id("status"));
Assert.Equal("", getStatusText().Text);

submit.Click();

Assert.Equal("Processing form...", getStatusText().Text);
Assert.Equal("Completed", getStatusText().Text);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@page "/form-streaming"
@using Microsoft.AspNetCore.Components.Forms
@attribute [StreamRendering(true)]

<h1>Streaming Rendering</h1>

@* This just sets the context for the binding, this happens normally inside RouteView *@
<CascadingModelBinder Name="/form-streaming">
<EditForm id="process" method="POST" OnValidSubmit="ProcessForm">
<input type="submit" value="Process form" />
</EditForm>
</CascadingModelBinder>

<p id="status">
@if (_processing)
{
<text>Processing form...</text>
}
else if (_done)
{
<text>Completed</text>
}
</p>

@code {
bool _processing = false;
bool _done = false;

private async Task ProcessForm()
{
_processing = true;
await Task.Yield();
_processing = false;
_done = true;
}
}

0 comments on commit 6fda746

Please sign in to comment.