2019-11-02 21:32:58 +07:00
|
|
|
package suites
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2019-11-25 03:27:59 +07:00
|
|
|
"testing"
|
2019-11-02 21:32:58 +07:00
|
|
|
|
2021-11-05 20:14:42 +07:00
|
|
|
"github.com/go-rod/rod"
|
|
|
|
"github.com/go-rod/rod/lib/proto"
|
2019-11-02 21:32:58 +07:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2021-11-05 20:14:42 +07: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-25 03:27:59 +07:00
|
|
|
assert.NoError(t, err)
|
2019-11-02 21:32:58 +07:00
|
|
|
}
|
|
|
|
|
2021-11-05 20:14:42 +07: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 21:32:58 +07:00
|
|
|
}
|
|
|
|
|
2021-11-05 20:14:42 +07:00
|
|
|
func (rs *RodSession) doVisitLoginPage(t *testing.T, page *rod.Page, targetURL string) {
|
2019-11-02 21:32:58 +07:00
|
|
|
suffix := ""
|
|
|
|
if targetURL != "" {
|
2019-11-25 03:27:59 +07:00
|
|
|
suffix = fmt.Sprintf("?rd=%s", targetURL)
|
2019-11-02 21:32:58 +07:00
|
|
|
}
|
2020-05-06 02:35:32 +07:00
|
|
|
|
2021-11-05 20:14:42 +07:00
|
|
|
rs.doVisitAndVerifyOneFactorStep(t, page, fmt.Sprintf("%s/%s", GetLoginBaseURL(), suffix))
|
2019-11-02 21:32:58 +07:00
|
|
|
}
|