Skip to content

Commit

Permalink
test: Fix expectation on windows (#11808)
Browse files Browse the repository at this point in the history
Windows receives a different error string
so we need to check the target os when
running the test.

Fixes #11777
  • Loading branch information
caalador authored and vaadin-bot committed Sep 10, 2021
1 parent fe93cb4 commit 1b1c9d9
Showing 1 changed file with 10 additions and 2 deletions.
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

0 comments on commit 1b1c9d9

Please sign in to comment.