Skip to content

Commit

Permalink
Check aligned in TestLabelParam webdriver test (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebjerring authored Sep 18, 2018
1 parent d71b183 commit 4b8b321
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
8 changes: 4 additions & 4 deletions webdriver/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ then
fi
cd ${INSTALL_DIR}

# Firefox 60
# Firefox 62
FIREFOX="firefox"
case "${UNAME_OUT}" in
Darwin*)
FIREFOX_OS="mac"
FIREFOX_DMG="Firefox 60.0.dmg"
FIREFOX_DMG="Firefox 62.0.dmg"
FIREFOX_SRC="${FIREFOX_DMG}"
;;
Linux*|*)
FIREFOX_OS="linux-x86_64"
FIREFOX_TBZ="${FIREFOX}-60.0.tar.bz2"
FIREFOX_TBZ="${FIREFOX}-62.0.tar.bz2"
FIREFOX_SRC="${FIREFOX_TBZ}"
;;
esac
FIREFOX_URL="https://releases.mozilla.org/pub/firefox/releases/60.0/${FIREFOX_OS}/en-US/${FIREFOX_SRC}"
FIREFOX_URL="https://releases.mozilla.org/pub/firefox/releases/62.0/${FIREFOX_OS}/en-US/${FIREFOX_SRC}"

info "Getting ${FIREFOX} binary..."
if [[ ! -e ${FIREFOX} || "${REINSTALL}" == "true" ]]
Expand Down
51 changes: 41 additions & 10 deletions webdriver/label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import (
"testing"
"time"

"github.com/deckarep/golang-set"

"github.com/stretchr/testify/assert"
"github.com/tebeka/selenium"
"github.com/web-platform-tests/wpt.fyi/shared"
)

func TestLabelParam(t *testing.T) {
Expand All @@ -25,26 +28,34 @@ func TestLabelParam(t *testing.T) {
defer service.Stop()
defer wd.Quit()

// Local static data only have 2 experimental browsers, and neither has aligned
// experimental runs.
if *staging {
// We have all 4 experimental browsers on staging.wpt.fyi.
testLabel(t, wd, app, "/", "experimental", "wpt-results", 4)
testLabel(t, wd, app, "/", "experimental", "wpt-results", 4, false)
} else {
// Local static data only have 2 experimental browsers.
testLabel(t, wd, app, "/", "experimental", "wpt-results", 2)
testLabel(t, wd, app, "/", "experimental", "wpt-results", 2, false)
}

for _, aligned := range []bool{true, false} {
testLabel(t, wd, app, "/interop", "stable", "wpt-interop", 4, aligned)
}
testLabel(t, wd, app, "/interop", "stable", "wpt-interop", 4)
}

func testLabel(
t *testing.T,
wd selenium.WebDriver,
app AppServer,
path, label, elementName string,
runs int) {
runs int,
aligned bool) {
// Navigate to the wpt.fyi homepage.
url := fmt.Sprintf("%s?label=%s", path, label)
filters := shared.TestRunFilter{
Labels: mapset.NewSetWith(label),
Aligned: &aligned,
}
url := fmt.Sprintf("%s?%s", path, filters.ToQuery().Encode())
if err := wd.Get(app.GetWebappURL(url)); err != nil {
panic(err)
panic(fmt.Sprintf("Failed to load %s: %s", url, err.Error()))
}

// Wait for the results view to load.
Expand All @@ -55,14 +66,19 @@ func testLabel(
}
return len(testRuns) > 0, nil
}
wd.WaitWithTimeout(runsLoadedCondition, time.Second*10)
if err := wd.WaitWithTimeout(runsLoadedCondition, time.Second*10); err != nil {
panic(fmt.Sprintf("Error waiting for test runs: %s", err.Error()))
}

// Check loaded test runs
testRuns, err := getTestRunElements(wd, elementName)
if err != nil {
panic(err)
panic(fmt.Sprintf("Failed to get test runs: %s", err.Error()))
}
assert.Lenf(t, testRuns, runs, "Expected exactly %v TestRuns search result.", runs)
if aligned {
assertAligned(t, wd, testRuns)
}

// Check tab URLs propagate label
tabs, err := getTabElements(wd, elementName)
Expand Down Expand Up @@ -102,3 +118,18 @@ func getTabElements(wd selenium.WebDriver, element string) ([]selenium.WebElemen
return FindShadowElements(wd, e, "results-navigation", "paper-tab")
}
}

func assertAligned(t *testing.T, wd selenium.WebDriver, testRuns []selenium.WebElement) {
if len(testRuns) < 2 {
return
}
args := []interface{}{testRuns[0]}
shaProp := "return arguments[0].testRun.revision"
sha, _ := wd.ExecuteScriptRaw(shaProp, args)
assert.NotEqual(t, sha, "")
for i := 1; i < len(testRuns); i++ {
args = []interface{}{testRuns[0]}
otherSHA, _ := wd.ExecuteScriptRaw(shaProp, args)
assert.Equal(t, sha, otherSHA)
}
}

0 comments on commit 4b8b321

Please sign in to comment.