<commit_before>﻿using DotVVM.Samples.Tests.Base;
using DotVVM.Testing.Abstractions;
using Riganti.Selenium.Core;
using Xunit;
using Xunit.Abstractions;

namespace DotVVM.Samples.Tests.Complex
{
    public class SPAViewModelReapplicationTests : AppSeleniumTest
    {
        [Fact]
        [SampleReference(nameof(SamplesRouteUrls.ComplexSamples_SPAViewModelReapplication_pageA))]
        [SampleReference(nameof(SamplesRouteUrls.ComplexSamples_SPAViewModelReapplication_pageB))]
        public void Complex_SPAViewModelReapplication()
        {
            RunInAllBrowsers(browser => {
                browser.NavigateToUrl(SamplesRouteUrls.ComplexSamples_SPAViewModelReapplication_pageA);
                WaitForExecutor.WaitFor(() => {
                    // verify items count
                    browser.FindElements("ul#first li").ThrowIfDifferentCountThan(3);
                });
                AssertUI.InnerText(browser.Single("#first"), s => s.Contains("Entry 1") && s.Contains("Entry 2") && s.Contains("Entry 3"));

                AssertUI.InnerTextEquals(browser.First("#test2"), "A");

                // verify first page values
                browser.First("input[type=text]").GetAttribute("value").Contains("Hello");
                browser.Last("input[type=text]").GetAttribute("value").Contains("1");

                //check url
                AssertUI.Url(browser, s => s.Contains("SPAViewModelReapplication/page"));

                // try the postback
                browser.First("input[type=button]").Click();
                AssertUI.InnerTextEquals(browser.First("#testResult"), "Hello1");

                // go to the second page
                browser.Single("#pageB").Click();

                // verify items count and
                browser.FindElements("ul#first li").ThrowIfDifferentCountThan(3);
                AssertUI.InnerText(browser.Single("#first"), s => s.Contains("Entry 1") && s.Contains("Entry 2") && s.Contains("Entry 3"));

                // verify second page values
                browser.First("input[type=text]").GetAttribute("value").Contains("World");
                browser.Last("input[type=text]").GetAttribute("value").Contains("2");
                AssertUI.InnerTextEquals(browser.First("#test2"), "B");

                // try the postback<commit_msg>Added WaitForOptions to Complex_SPAViewModelReapplication<commit_after>﻿using DotVVM.Samples.Tests.Base;
using DotVVM.Testing.Abstractions;
using Riganti.Selenium.Core;
using Xunit;
using Xunit.Abstractions;

namespace DotVVM.Samples.Tests.Complex
{
    public class SPAViewModelReapplicationTests : AppSeleniumTest
    {
        [Fact]
        [SampleReference(nameof(SamplesRouteUrls.ComplexSamples_SPAViewModelReapplication_pageA))]
        [SampleReference(nameof(SamplesRouteUrls.ComplexSamples_SPAViewModelReapplication_pageB))]
        public void Complex_SPAViewModelReapplication()
        {
            RunInAllBrowsers(browser => {
                browser.NavigateToUrl(SamplesRouteUrls.ComplexSamples_SPAViewModelReapplication_pageA);
                WaitForExecutor.WaitFor(() => {
                    // verify items count
                    browser.FindElements("ul#first li").ThrowIfDifferentCountThan(3, WaitForOptions.Disabled);
                });
                AssertUI.InnerText(browser.Single("#first"), s => s.Contains("Entry 1") && s.Contains("Entry 2") && s.Contains("Entry 3"));

                AssertUI.InnerTextEquals(browser.First("#test2"), "A");

                // verify first page values
                browser.First("input[type=text]").GetAttribute("value").Contains("Hello");
                browser.Last("input[type=text]").GetAttribute("value").Contains("1");

                //check url
                AssertUI.Url(browser, s => s.Contains("SPAViewModelReapplication/page"));

                // try the postback
                browser.First("input[type=button]").Click();
                AssertUI.InnerTextEquals(browser.First("#testResult"), "Hello1");

                // go to the second page
                browser.Single("#pageB").Click();

                // verify items count and
                browser.FindElements("ul#first li").ThrowIfDifferentCountThan(3);
                AssertUI.InnerText(browser.Single("#first"), s => s.Contains("Entry 1") && s.Contains("Entry 2") && s.Contains("Entry 3"));

                // verify second page values
                browser.First("input[type=text]").GetAttribute("value").Contains("World");
                browser.Last("input[type=text]").GetAttribute("value").Contains("2");
                AssertUI.InnerTextEquals(browser.First("#test2"), "B");

                // try the postback
{'fraction_non_alphanumeric': 0.13245595414986203, 'fraction_numerical': 0.005518998089577585, 'mean_word_length': 2.564296520423601, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3109198', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1183, 'n_words': 179}