Adjust TestFormPostHTML to work on Linux chromedriver.

For some reason our headless Chrome test setup behaves slightly differently on Linux and macOS hosts. On Linux, the emoji characters are not recognized as valid text, so they are URL encoded. This change updates the test to cope with both cases correctly.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer 2021-07-08 20:15:14 -05:00
parent 5029495fdb
commit d0b37a7c90
No known key found for this signature in database
GPG Key ID: EAE88AD172C5AE2D
1 changed files with 8 additions and 1 deletions

View File

@ -185,7 +185,14 @@ func formpostExpectFavicon(t *testing.T, page *agouti.Page, expected string) {
iconURL, err := page.First("#favicon").Attribute("href") iconURL, err := page.First("#favicon").Attribute("href")
require.NoError(t, err) require.NoError(t, err)
require.True(t, strings.HasPrefix(iconURL, "data:image/svg+xml,<svg")) require.True(t, strings.HasPrefix(iconURL, "data:image/svg+xml,<svg"))
require.Contains(t, iconURL, expected)
// For some reason chromedriver on Linux returns this attribute urlencoded, but on macOS it contains the
// original emoji bytes (unescaped). To check correctly in both cases we allow either version here.
expectedEscaped := url.QueryEscape(expected)
require.Truef(t,
strings.Contains(iconURL, expected) || strings.Contains(iconURL, expectedEscaped),
"expected %q to contain %q or %q", iconURL, expected, expectedEscaped,
)
} }
// formpostInitiate navigates to the template server endpoint and expects the // formpostInitiate navigates to the template server endpoint and expects the