@Test public void shouldCheckCustomHttpStatusCodes() throws ConfigValidationException { UrlConfig urlConfig = UrlConfig.urlConfigBuilder() .withHttpCheck(new HttpCheckConfig(true, ImmutableList.of(304))) .withPaths(ImmutableList.of("/")).build(); JobConfig jobConfig = localTestConfig("200", Browser.Type.CHROME_HEADLESS, false, urlConfig); try { runJLineup(jobConfig, Step.before); fail(); } catch (Exception e) { assertThat(e.getCause().getCause().getCause().getMessage(), containsString("Accessibility check")); assertThat(e.getCause().getCause().getCause().getMessage(), containsString("returned status code 200")); } }
public static Builder newBuilder(UrlConfig copy) { Builder builder = new Builder(); builder.paths = copy.paths; builder.maxDiff = copy.maxDiff; builder.cookies = copy.cookies; builder.envMapping = copy.envMapping; builder.localStorage = copy.localStorage; builder.sessionStorage = copy.sessionStorage; builder.windowWidths = copy.windowWidths; builder.maxScrollHeight = copy.maxScrollHeight; builder.waitAfterPageLoad = copy.waitAfterPageLoad; builder.waitAfterScroll = copy.waitAfterScroll; builder.waitForNoAnimationAfterScroll = copy.waitForNoAnimationAfterScroll; builder.warmupBrowserCacheTime = copy.warmupBrowserCacheTime; builder.waitForFontsTime = copy.waitForFontsTime; builder.javaScript = copy.javaScript; builder.httpCheck = copy.httpCheck; builder.maxColorDiffPerPixel = copy.maxColorDiffPerPixel; builder.hideImages = copy.hideImages; return builder; }
public static Builder urlConfigBuilder() { return new Builder().withHttpCheck(new HttpCheckConfig()); }
@Test public void shouldCheckHttpStatusCodeError() { UrlConfig urlConfig = UrlConfig.urlConfigBuilder() .withHttpCheck(new HttpCheckConfig(true)) .withPaths(ImmutableList.of("/")).build(); JobConfig jobConfig = localTestConfig("500", Browser.Type.CHROME_HEADLESS, false, urlConfig); try { runJLineup(jobConfig, Step.before); fail(); } catch (Exception e) { assertThat(e.getCause().getCause().getCause().getMessage(), containsString("Accessibility check")); assertThat(e.getCause().getCause().getCause().getMessage(), containsString("returned status code 500")); } }
@Test public void shouldNotCheckHttpStatusCodeErrorIfNotConfigured() throws ConfigValidationException { UrlConfig urlConfig = UrlConfig.urlConfigBuilder() .withHttpCheck(new HttpCheckConfig(false)) .withPaths(ImmutableList.of("/")).build(); JobConfig jobConfig = localTestConfig("500", Browser.Type.CHROME_HEADLESS, false, urlConfig); runJLineup(jobConfig, Step.before); //no exception }
@Test public void shouldSetCookieOnCorrectPath() throws ConfigValidationException { UrlConfig urlConfig = UrlConfig.urlConfigBuilder() .withCookie(new Cookie("CookieName", "CookieValue")) .withPaths(ImmutableList.of("/")).build(); JobConfig jobConfig = localTestConfig("somerootpath/somevalidsubpath", Browser.Type.CHROME_HEADLESS, true, urlConfig); runJLineup(jobConfig, Step.before); }
@Test public void shouldNotAppendSlashToDomain() throws ConfigValidationException { UrlConfig urlConfig = UrlConfig.urlConfigBuilder().withCookie(new Cookie("CookieName", "CookieValue")).build(); JobConfig jobConfig = localTestConfig("params?param1=1¶m2=2", Browser.Type.CHROME_HEADLESS, true, urlConfig); runJLineup(jobConfig, Step.before); }