2019-11-02 14:32:58 +00:00
|
|
|
package suites
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2019-11-24 20:27:59 +00:00
|
|
|
"testing"
|
2019-11-02 14:32:58 +00:00
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
"github.com/go-rod/rod"
|
|
|
|
"github.com/go-rod/rod/lib/proto"
|
2019-11-02 14:32:58 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
func (rs *RodSession) doCreateTab(t *testing.T, url string) *rod.Page {
|
|
|
|
p, err := rs.WebDriver.MustIncognito().Page(proto.TargetCreateTarget{URL: url})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rs *RodSession) doVisit(t *testing.T, page *rod.Page, url string) {
|
|
|
|
err := page.Navigate(url)
|
2019-11-24 20:27:59 +00:00
|
|
|
assert.NoError(t, err)
|
2019-11-02 14:32:58 +00:00
|
|
|
}
|
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
func (rs *RodSession) doVisitAndVerifyOneFactorStep(t *testing.T, page *rod.Page, url string) {
|
|
|
|
rs.doVisit(t, page, url)
|
|
|
|
rs.verifyIsFirstFactorPage(t, page)
|
2019-11-02 14:32:58 +00:00
|
|
|
}
|
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
func (rs *RodSession) doVisitLoginPage(t *testing.T, page *rod.Page, targetURL string) {
|
2019-11-02 14:32:58 +00:00
|
|
|
suffix := ""
|
|
|
|
if targetURL != "" {
|
2019-11-24 20:27:59 +00:00
|
|
|
suffix = fmt.Sprintf("?rd=%s", targetURL)
|
2019-11-02 14:32:58 +00:00
|
|
|
}
|
2020-05-05 19:35:32 +00:00
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
rs.doVisitAndVerifyOneFactorStep(t, page, fmt.Sprintf("%s/%s", GetLoginBaseURL(), suffix))
|
2019-11-02 14:32:58 +00:00
|
|
|
}
|