Repository: dotnet/aspnetcore
File: src/Components/test/E2ETest/Tests/StatePersistenceTest.cs (C#)

Code before:
            interactive: streaming == null,
            stateFound: true,
            stateValue: stateValue,
            streamingId: streaming,
            streamingCompleted: false,
            interactiveRuntime: interactiveRuntime);

        if (streaming == null)
        {
            return;
        }

        Browser.Click(By.Id("end-streaming"));

        AssertPageState(
            mode: mode,
            renderMode: renderMode.Name,
            interactive: true,
            stateFound: true,
            stateValue: stateValue,
            streamingId: streaming,
            streamingCompleted: true,
            interactiveRuntime: interactiveRuntime);
    }

    [Fact]
    public void PersistentStateIsSupportedInDynamicJSRoots()
    {
        Navigate("subdir/dynamic-js-root.html");

        Browser.Equal("Counter", () => Browser.Exists(By.TagName("h1")).Text);
        Browser.Equal("Current count: 0", () => Browser.Exists(By.CssSelector("p[role='status']")).Text);

        Browser.Click(By.CssSelector("button.btn-primary"));
        Browser.Equal("Current count: 1", () => Browser.Exists(By.CssSelector("p[role='status']")).Text);
    }

    private void AssertPageState(
        string mode,
        string renderMode,
        bool interactive,
        bool stateFound,
        string stateValue,
        string streamingId = null,
        bool streamingCompleted = false,
        string interactiveRuntime = null)
    {
        Browser.Equal($"Render mode: {renderMode}", () => Browser.FindElement(By.Id("render-mode")).Text);
        Browser.Equal($"Streaming id:{streamingId}", () => Browser.FindElement(By.Id("streaming-id")).Text);
        Browser.Equal($"Interactive: {interactive}", () => Browser.FindElement(By.Id("interactive")).Text);
        if (streamingId == null || streamingCompleted)

Review comment (suggestion):
This should be a theory that would test not only `RemoteRenderer` but also `WebAssemblyRenderer`.

Code after:
            interactive: streaming == null,
            stateFound: true,
            stateValue: stateValue,
            streamingId: streaming,
            streamingCompleted: false,
            interactiveRuntime: interactiveRuntime);

        if (streaming == null)
        {
            return;
        }

        Browser.Click(By.Id("end-streaming"));

        AssertPageState(
            mode: mode,
            renderMode: renderMode.Name,
            interactive: true,
            stateFound: true,
            stateValue: stateValue,
            streamingId: streaming,
            streamingCompleted: true,
            interactiveRuntime: interactiveRuntime);
    }

    private void AssertPageState(
        string mode,
        string renderMode,
        bool interactive,
        bool stateFound,
        string stateValue,
        string streamingId = null,
        bool streamingCompleted = false,
        string interactiveRuntime = null)
    {
        Browser.Equal($"Render mode: {renderMode}", () => Browser.FindElement(By.Id("render-mode")).Text);
        Browser.Equal($"Streaming id:{streamingId}", () => Browser.FindElement(By.Id("streaming-id")).Text);
        Browser.Equal($"Interactive: {interactive}", () => Browser.FindElement(By.Id("interactive")).Text);
        if (streamingId == null || streamingCompleted)
        {
            interactiveRuntime = !interactive ? "none" : mode == "server" || mode == "wasm" ? mode : (interactiveRuntime ?? throw new InvalidOperationException("Specify interactiveRuntime for auto mode"));

            Browser.Equal($"Interactive runtime: {interactiveRuntime}", () => Browser.FindElement(By.Id("interactive-runtime")).Text);
            Browser.Equal($"State found:{stateFound}", () => Browser.FindElement(By.Id("state-found")).Text);
            Browser.Equal($"State value:{stateValue}", () => Browser.FindElement(By.Id("state-value")).Text);
        }
        else
        {
            Browser.Equal("Streaming: True", () => Browser.FindElement(By.Id("streaming")).Text);
        }
    }