github.com/web-platform-tests/wpt.fyi@v0.0.0-20240530210107-70cf978996f1/webdriver/path_test.go (about)

     1  // +build large
     2  
     3  package webdriver
     4  
     5  import (
     6  	"fmt"
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  	"github.com/tebeka/selenium"
    11  )
    12  
    13  func TestPath(t *testing.T) {
    14  	if *staging {
    15  		t.Skip("skipping path tests on staging (#1327)")
    16  	}
    17  	runWebdriverTest(t, func(t *testing.T, app AppServer, wd selenium.WebDriver) {
    18  		t.Run("results", func(t *testing.T) {
    19  			testPath(t, app, wd, "/results/", "wpt-results")
    20  		})
    21  	})
    22  }
    23  
    24  func testPath(t *testing.T, app AppServer, wd selenium.WebDriver, path, elementName string) {
    25  	// Navigate to the wpt.fyi homepage.
    26  	if err := wd.Get(app.GetWebappURL(path + "2dcontext/building-paths")); err != nil {
    27  		assert.FailNow(t, fmt.Sprintf("Error navigating to homepage: %s", err.Error()))
    28  	}
    29  
    30  	// Wait for the results view to load.
    31  	resultsLoadedCondition := func(wd selenium.WebDriver) (bool, error) {
    32  		pathParts, err := getPathPartElements(wd, elementName)
    33  		if err != nil {
    34  			return false, err
    35  		}
    36  		return len(pathParts) > 0, nil
    37  	}
    38  
    39  	paths := []string{
    40  		"canvas_complexshapes_arcto_001.htm",
    41  		"canvas_complexshapes_beziercurveto_001.htm",
    42  	}
    43  	err := wd.WaitWithTimeout(resultsLoadedCondition, LongTimeout)
    44  	assert.Nil(t, err)
    45  	assertListIsFiltered(t, wd, elementName, paths...)
    46  }