Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix expectation on windows #11808

Merged
merged 1 commit into from
Sep 10, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;

import com.vaadin.flow.testutil.ChromeBrowserTest;

public class ClientSideExceptionHandlingIT extends ChromeBrowserTest {

private static final By ERROR_LOCATOR = By.className("v-system-error");
public static final String UNIX_PATTERN = ".*TypeError.* property 'foo' of.*null.*";
public static final String WINDOWS_PATTERN = ".*TypeError.* : Cannot read properties of null .*reading 'foo'.*";

@Test
public void developmentModeExceptions() {
Expand All @@ -35,9 +38,14 @@ public void developmentModeExceptions() {

String errorMessage = findElement(ERROR_LOCATOR).getText();

// Windows formats the error differently from unix
final boolean isWindows = (boolean) ((JavascriptExecutor) getDriver())
.executeScript(
"return navigator.appVersion.indexOf(\"Win\")!=-1");
String testPattern = isWindows ? WINDOWS_PATTERN : UNIX_PATTERN;

Assert.assertTrue("Unexpected error message: " + errorMessage,
Pattern.matches(".*TypeError.* property 'foo' of.*null.*",
errorMessage));
Pattern.matches(testPattern, errorMessage));
}

@Test
Expand Down