Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Merge branch 'color-scheme-acceptance-tests'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzmitry Yurkavets committed Feb 26, 2014
2 parents 1c7c536 + 30ad0da commit 85fcdaf
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ public void I_click_Toggle_all_makes_checkbox() {
findToggleAllMakesCheckbox().click();
}

@When("^I select (.*) color scheme for (.*) theme$")
public void I_select_color_scheme_for_theme(String colorSchemeName, String themeName) {
I_select_color_scheme(colorSchemeName);
I_select_theme(themeName);
}

@Then("^I should see '(.*)' as applied (.*) Api key$")
public void I_should_see_value_as_applied_Api_key(String expectedValue, String apiKeyType) {
InputGroupControl apiKeyControl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ public void NVC_widget_should_be_loaded() {
iframe = findNVCWidgetRootElement().findElement(By.tagName("iframe"));
}

@Then("^NVC widget should be rendered with (.*) color scheme for (.*) theme$")
public void NVC_widget_should_be_rendered_with_color_scheme_for_theme(String colorSchemeName, String themeName) {
By locator = By.cssSelector("Theme 3".equals(themeName) ? "#nvcwidget .nvcwidget-inner" :
"#nvcwidget");
String expectedColor = "Light".equals(colorSchemeName) ? "rgba(242, 242, 242, 1)" :
"rgba(63, 63, 63, 1)";
String cssProperty = "background-color";
switchToNVCWidgetContent();
WaitFor.cssValue(locator, cssProperty, expectedColor);
WebElement element = getDriver().findElement(locator);
assertEquals(element.getCssValue(cssProperty), expectedColor);
switchToDefaultContent();
}

public void switchToNVCWidgetContent() {
NVC_widget_should_be_loaded();
getDriver().switchTo().frame(findNVCWidgetRootElement().findElement(By.tagName("iframe")));
Expand Down
147 changes: 129 additions & 18 deletions test/acceptance/java/com/edmunds/widgets/TMVConfiguratorStepdefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import com.edmunds.widgets.ui.WaitFor;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.util.ArrayList;
import java.util.List;

import static com.edmunds.widgets.RunCukesTest.getDriver;
import static com.edmunds.widgets.ui.WidgetConfigurator.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

public class TMVConfiguratorStepdefs {
Expand All @@ -34,28 +37,17 @@ public void TMV_widget_should_be_displayed_with_ZIP_code(String zipCode) {

@Then("^TMV widget should be displayed with border$")
public void TMV_widget_should_be_displayed_with_border() {
String propertyName = "border-top-width";
String expectedValue = "1px";
WebElement widgetRootElement = findTMVWidgetRootElement();
WaitFor.cssValue(widgetRootElement, propertyName, expectedValue);
assertEquals(widgetRootElement.getCssValue(propertyName), expectedValue);
assertRootElementCssValue("border-top-width", "1px");
}

@Then("^TMV widget should be displayed without border$")
public void TMV_widget_should_be_displayed_without_border() {
String propertyName = "border-top-width";
String expectedValue = "0px";
WebElement widgetRootElement = findTMVWidgetRootElement();
WaitFor.cssValue(widgetRootElement, propertyName, expectedValue);
assertEquals(widgetRootElement.getCssValue(propertyName), expectedValue);
assertRootElementCssValue("border-top-width", "0px");
}

@Then("^TMV widget should be displayed with '(.*)' border radius$")
public void TMV_widget_should_be_displayed_with_border_radius(String borderRadius) {
String propertyName = "border-top-left-radius";
WebElement widgetRootElement = findTMVWidgetRootElement();
WaitFor.cssValue(widgetRootElement, propertyName, borderRadius);
assertEquals(widgetRootElement.getCssValue(propertyName), borderRadius);
assertRootElementCssValue("border-top-left-radius", borderRadius);
}

@Then("^width of TMV widget should be equal to '(.*)'$")
Expand All @@ -64,10 +56,7 @@ public void width_of_TMV_widget_should_be_equal(String width) {
if (hasBorder) {
width = Long.valueOf(width.replace("px", "")) - 2 + "px";
}
String propertyName = "width";
WebElement widgetRootElement = findTMVWidgetRootElement();
WaitFor.cssValue(widgetRootElement, propertyName, width);
assertEquals(widgetRootElement.getCssValue(propertyName), width);
assertRootElementCssValue("width", width);
}

@Then("^TMV widget should be loaded with next makes:$")
Expand Down Expand Up @@ -97,4 +86,126 @@ public void TMV_widget_should_be_loaded_without_makes() {
assertTrue(widget.getMakeNames().isEmpty());
}

@Then("^TMV widget should be rendered with (.*) color scheme for (.*) theme$")
public void TMV_widget_should_be_rendered_with_color_scheme_for_theme(String colorSchemeName, String themeName) {
switch (themeName) {
case "Theme 1":
checkColorSchemeForTheme1(colorSchemeName);
break;
case "Theme 2":
checkColorSchemeForTheme2(colorSchemeName);
break;
case "Theme 3":
checkColorSchemeForTheme3(colorSchemeName);
break;
default:
assertFalse(true, "unexpected name of the theme");
}
}

public void checkColorSchemeForTheme1(String colorSchemeName) {
switch (colorSchemeName) {
case "Light":
// root
assertRootElementCssValue("background-color", "rgba(242, 242, 242, 1)");
assertRootElementCssValue("border-top-color", "rgba(219, 219, 219, 1)");
assertRootElementCssValue("border-top-width", "1px");
// inner
assertInnerElementCssValue("border-top-width", "0px");
// header
assertHeaderElementCssValue("background-color", "rgba(219, 219, 219, 1)");
assertHeaderElementCssValue("border-bottom-width", "0px");
break;
case "Dark":
// root
assertRootElementCssValue("background-color", "rgba(51, 51, 51, 1)");
assertRootElementCssValue("border-top-color", "rgba(64, 64, 64, 1)");
assertRootElementCssValue("border-top-width", "1px");
// inner
assertInnerElementCssValue("border-top-width", "0px");
// header
assertHeaderElementCssValue("background-color", "rgba(31, 31, 31, 1)");
assertHeaderElementCssValue("border-bottom-width", "0px");
break;
default:
assertFalse(true, "unexpected name of the color scheme");
}
}

public void checkColorSchemeForTheme2(String colorSchemeName) {
switch (colorSchemeName) {
case "Light":
// root
assertRootElementCssValue("background-color", "rgba(242, 242, 242, 1)");
assertRootElementCssValue("border-top-color", "rgba(219, 219, 219, 1)");
assertRootElementCssValue("border-top-width", "1px");
// inner
assertInnerElementCssValue("border-top-color", "rgba(255, 255, 255, 1)");
assertInnerElementCssValue("border-top-width", "1px");
// header
assertHeaderElementCssValue("border-bottom-color", "rgba(255, 255, 255, 1)");
assertHeaderElementCssValue("border-bottom-width", "1px");
break;
case "Dark":
// root
assertRootElementCssValue("background-color", "rgba(51, 51, 51, 1)");
assertRootElementCssValue("border-top-color", "rgba(64, 64, 64, 1)");
assertRootElementCssValue("border-top-width", "1px");
// inner
assertInnerElementCssValue("border-top-width", "0px");
// header
assertHeaderElementCssValue("border-bottom-color", "rgba(77, 77, 77, 1)");
assertHeaderElementCssValue("border-bottom-width", "1px");
break;
default:
assertFalse(false, "unexpected name of the color scheme");
}
}

public void checkColorSchemeForTheme3(String colorSchemeName) {
switch (colorSchemeName) {
case "Light":
// root
assertRootElementCssValue("border-top-width", "0px");
// inner
assertInnerElementCssValue("border-top-color", "rgba(200, 201, 201, 1)");
assertInnerElementCssValue("border-top-width", "1px");
// header
assertHeaderElementCssValue("border-bottom-width", "0px");
break;
case "Dark":
// root
assertRootElementCssValue("border-top-width", "0px");
// inner
assertInnerElementCssValue("border-top-color", "rgba(64, 64, 64, 1)");
assertInnerElementCssValue("border-top-width", "1px");
// header
assertHeaderElementCssValue("border-bottom-width", "0px");
break;
default:
assertFalse(false, "unexpected name of the color scheme");
}
}

public void assertRootElementCssValue(String propertyName, String propertyValue) {
By locator = By.cssSelector("#tmvwidget");
assertElementCssValue(locator, propertyName, propertyValue);
}

public void assertInnerElementCssValue(String propertyName, String propertyValue) {
By locator = By.cssSelector("#tmvwidget .tmvwidget-inner");
assertElementCssValue(locator, propertyName, propertyValue);
}

public void assertHeaderElementCssValue(String propertyName, String propertyValue) {
By locator = By.cssSelector("#tmvwidget .tmvwidget-header");
assertElementCssValue(locator, propertyName, propertyValue);
}

public void assertElementCssValue(By locator, String propertyName, String propertyValue) {
WaitFor.cssValue(locator, propertyName, propertyValue);
WebElement rootElement = getDriver().findElement(locator);
assertEquals(rootElement.getCssValue(propertyName), propertyValue);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ Feature: NVC Widget Configurator
Given I am on '/nvc/configure' page
Then NVC widget should be loaded
When I apply 'axr2rtmnj63qsth3ume3tv5f' Vehicle Api key
Then NVC widget should be loaded
Then I should see 'axr2rtmnj63qsth3ume3tv5f' as applied Vehicle Api key
When I apply 'axr2rtmnj63qsth3ume3tv5f' Dealer Api key
Then NVC widget should be loaded
When I apply '12345' default ZIP code
Then NVC widget should be loaded
Then I should see '12345' as applied default ZIP code
Then list of Included makes should be loaded
Then 'Toggle all' makes checkbox should not be selected
When I select makes in the list of Included makes:
Expand Down Expand Up @@ -69,9 +65,19 @@ Feature: NVC Widget Configurator
Scenario: I want to configure theme of the widget
Given I am on '/nvc/configure' page

@todo
Scenario: I want to configure color scheme of the widget
Scenario Outline: I want to configure color scheme of the widget
Given I am on '/nvc/configure' page
Then NVC widget should be loaded
When I select <Color Scheme> color scheme for <Theme> theme
Then NVC widget should be rendered with <Color Scheme> color scheme for <Theme> theme
Examples:
| Theme | Color Scheme |
| Theme 1 | Light |
| Theme 1 | Dark |
| Theme 2 | Light |
| Theme 2 | Dark |
| Theme 3 | Light |
| Theme 3 | Dark |

Scenario: I want to configure width of the widget
Given I am on '/nvc/configure' page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ Feature: TMV Widget
Scenario: I want to configure price to display
Given I am on '/tmv/configure' page

@todo @deferred
Scenario: I want to configure theme of the widget
Scenario Outline: I want to configure theme and color scheme of the widget
Given I am on '/tmv/configure' page
When I select 'Theme 1' theme
When I select 'Theme 2' theme
When I select 'Theme 3' theme

@todo @deferred
Scenario: I want to configure color scheme of the widget
Given I am on '/tmv/configure' page
When I select 'Light' color scheme
When I select 'Dark' color scheme
When I select <Color Scheme> color scheme for <Theme> theme
Then TMV widget should be rendered with <Color Scheme> color scheme for <Theme> theme
Examples:
| Theme | Color Scheme |
| Theme 1 | Light |
| Theme 1 | Dark |
| Theme 2 | Light |
| Theme 2 | Dark |
| Theme 3 | Light |
| Theme 3 | Dark |

Scenario: I want to configure layout of the widget
Given I am on '/tmv/configure' page
Expand Down

0 comments on commit 85fcdaf

Please sign in to comment.