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

Disregarding result tags in model diff #117

Merged
merged 4 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Exposed issue
  • Loading branch information
therealryan committed Oct 14, 2022
commit 936cf801dd95b4b382c50b74f09331be8728398e
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.mastercard.test.flow.example.app.webui;

import static com.mastercard.test.flow.util.Tags.tags;

import java.util.function.Consumer;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -9,6 +13,7 @@

import com.mastercard.test.flow.assrt.Assertion;
import com.mastercard.test.flow.assrt.Replay;
import com.mastercard.test.flow.assrt.junit5.Flocessor;
import com.mastercard.test.flow.example.app.WebUi;
import com.mastercard.test.flow.example.app.assrt.AbstractServiceTest;
import com.mastercard.test.flow.example.app.assrt.Browser;
Expand Down Expand Up @@ -53,6 +58,15 @@ public WebUiTest() {
super( service, Actors.WEB_UI, LOG );
}

@Override
protected Consumer<Flocessor> custom() {
// The flows that hit the web UI are tagged as such, so we can avoid having to
// build all the other flows that will never be exercised by this test
return flocessor -> flocessor
.filtering( config -> config
.includedTags( tags( "web" ) ) );
}

@Override
protected byte[] getResponse( Assertion assrt ) {
WebDriver driver = Browser.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static com.mastercard.test.flow.report.Mdl.Actrs.AVA;
import static com.mastercard.test.flow.report.Mdl.Actrs.BEN;
import static com.mastercard.test.flow.util.Tags.add;
import static com.mastercard.test.flow.util.Tags.remove;
import static com.mastercard.test.flow.util.Tags.set;

import org.junit.jupiter.api.AfterAll;
Expand Down Expand Up @@ -56,9 +58,11 @@ static void setup() throws Exception {
Flow before = Deriver.build( removed, flow -> flow
.meta( data -> data
.description( "updated" )
.tags( set( "c", "d", "e" ) ) ) );
.tags( set( "c", "d", "e", "PASS", "FAIL" ) ) ) );

Flow after = Deriver.build( before, flow -> flow
.meta( data -> data
.tags( remove( "PASS", "FAIL" ), add( "SKIP", "ERROR" ) ) )
.update( i -> true, i -> {
i.request().set( "i", "iii" );
i.request().set( "e", "eee" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;

import io.github.bonigarcia.wdm.WebDriverManager;

Expand Down Expand Up @@ -49,6 +53,11 @@ public class Browser implements
*/
private static final String SKIP_PRP = "browser.skip";

/**
* The system property that controls which driver we use
*/
private static final String DRIVER_PRP = "browser.driver";

/**
* Causes all tests that use the browser to be skipped
*/
Expand All @@ -67,26 +76,16 @@ public static WebDriver get() {
+ "You've asked for the browser before the shutdown hook has been set.\n"
+ "Only call Browser.get() in test classes with @ExtendWith(Browser.class) annotation" );
}
Driver type = Driver.CHROME;

WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
if( !SHOW ) {
options.addArguments( "--headless" );
for( Driver d : Driver.values() ) {
if( d.name().equalsIgnoreCase( System.getProperty( DRIVER_PRP ) ) ) {
type = d;
break;
}
}
// some oddness around browser locale changing with headful/less mode, possibly
// related to https://bugs.chromium.org/p/chromium/issues/detail?id=755338
// I'm seeing the opposite effect: headless mode used the correct locale,
// headful mode did not. In any case, let's set it explicitly
options.addArguments( "--lang=en_GB" );
options.addArguments( "--disable-gpu" );
options.addArguments( "--window-size=1400,800" );

// suppress most stdout noise. We still get a "ChromeDriver was started
// successfully." line for some reason
System.setProperty( CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true" );
Logger.getLogger( "org.openqa.selenium" ).setLevel( Level.OFF );

driver = new ChromeDriver( options );

driver = type.get();
}
return driver;
}
Expand Down Expand Up @@ -139,4 +138,55 @@ private static void quitBrowser() {
driver = null;
}
}

private enum Driver {
CHROME {
@Override
public WebDriver get() {
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
if( !SHOW ) {
options.addArguments( "--headless" );
}
// some oddness around browser locale changing with headful/less mode, possibly
// related to https://bugs.chromium.org/p/chromium/issues/detail?id=755338
// I'm seeing the opposite effect: headless mode used the correct locale,
// headful mode did not. In any case, let's set it explicitly
options.addArguments( "--lang=en_GB" );
options.addArguments( "--disable-gpu" );
options.addArguments( "--window-size=1400,800" );

// suppress most stdout noise. We still get a "ChromeDriver was started
// successfully." line for some reason
System.setProperty( CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true" );
Logger.getLogger( "org.openqa.selenium" ).setLevel( Level.OFF );

return new ChromeDriver( options );
}
},
FIREFOX {
@Override
public WebDriver get() {
WebDriverManager.firefoxdriver().setup();

FirefoxOptions options = new FirefoxOptions();

if( !SHOW ) {
FirefoxBinary binary = new FirefoxBinary();
binary.addCommandLineOptions( "--headless" );
options.setBinary( binary );
}

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference( "intl.accept_languages", "en-GB" );
options.setProfile( profile );

options.addArguments( "--width=1400", "--height=800" );

return new FirefoxDriver( options );
}
};

public abstract WebDriver get();
}
}