|
|
@ -4,22 +4,45 @@ import ( |
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
"github.com/stretchr/testify/assert" |
|
|
|
"github.com/stretchr/testify/assert" |
|
|
|
browser "github.com/chromedp/chromedp" |
|
|
|
browser "github.com/chromedp/chromedp" |
|
|
|
|
|
|
|
"zedshaw.games/webapp/data" |
|
|
|
|
|
|
|
sq "github.com/Masterminds/squirrel" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func deleteTestUser(username string) { |
|
|
|
|
|
|
|
sql, args, err := sq.Delete("user").Where("username=?", username).ToSql() |
|
|
|
|
|
|
|
data.Exec(err, sql, args...) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestLogin(t *testing.T) { |
|
|
|
func TestLogin(t *testing.T) { |
|
|
|
assert := assert.New(t) |
|
|
|
assert := assert.New(t) |
|
|
|
|
|
|
|
data.Setup("sqlite3", "./db.sqlite3") |
|
|
|
|
|
|
|
deleteTestUser("testerzed") |
|
|
|
|
|
|
|
|
|
|
|
ctx, cancel := Setup(5); defer cancel() |
|
|
|
ctx, cancel := Setup(5); defer cancel() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Run(assert, ctx, |
|
|
|
|
|
|
|
browser.Navigate(`http://127.0.0.1:5002/register/`), |
|
|
|
|
|
|
|
browser.WaitVisible(`body > footer`), |
|
|
|
|
|
|
|
browser.WaitVisible(`[data-testid="register-page"]`), |
|
|
|
|
|
|
|
browser.SendKeys(`#username`, `testerzed`), |
|
|
|
|
|
|
|
browser.SendKeys(`#email`, `zed@test.com`), |
|
|
|
|
|
|
|
browser.SendKeys(`#password`, `iamdumb`), |
|
|
|
|
|
|
|
browser.Click(`#register-submit`, browser.NodeVisible), |
|
|
|
|
|
|
|
browser.WaitVisible(`body > footer`), |
|
|
|
|
|
|
|
browser.WaitVisible(`[data-testid="login-page"]`)) |
|
|
|
|
|
|
|
|
|
|
|
Run(assert, ctx, |
|
|
|
Run(assert, ctx, |
|
|
|
browser.Navigate(`http://127.0.0.1:5002/login/`), |
|
|
|
browser.Navigate(`http://127.0.0.1:5002/login/`), |
|
|
|
browser.WaitVisible(`body > footer`), |
|
|
|
browser.WaitVisible(`body > footer`), |
|
|
|
browser.WaitVisible(`[data-testid="login-page"]`), |
|
|
|
browser.WaitVisible(`[data-testid="login-page"]`), |
|
|
|
browser.SendKeys(`#username`, `zedshaw`), |
|
|
|
browser.SendKeys(`#username`, `testerzed`), |
|
|
|
browser.SendKeys(`#password`, `1234`), |
|
|
|
browser.SendKeys(`#password`, `iamdumb`), |
|
|
|
browser.Click(`#login-submit`, browser.NodeVisible), |
|
|
|
browser.Click(`#login-submit`, browser.NodeVisible), |
|
|
|
browser.WaitVisible(`body > footer`), |
|
|
|
browser.WaitVisible(`body > footer`), |
|
|
|
browser.WaitVisible(`[data-testid="home-page"]`)) |
|
|
|
browser.WaitVisible(`[data-testid="home-page"]`)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// delete the user here
|
|
|
|
|
|
|
|
deleteTestUser("testerzed") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestStreamPage(t *testing.T) { |
|
|
|
func TestStreamPage(t *testing.T) { |
|
|
@ -33,8 +56,7 @@ func TestStreamPage(t *testing.T) { |
|
|
|
err := browser.Run(ctx, |
|
|
|
err := browser.Run(ctx, |
|
|
|
browser.Navigate(`http://127.0.0.1:5002`), |
|
|
|
browser.Navigate(`http://127.0.0.1:5002`), |
|
|
|
browser.WaitVisible(`body > footer`), |
|
|
|
browser.WaitVisible(`body > footer`), |
|
|
|
browser.WaitVisible(`#streams`), |
|
|
|
browser.WaitVisible(`#streams`),) |
|
|
|
) |
|
|
|
|
|
|
|
assert.NoError(err) |
|
|
|
assert.NoError(err) |
|
|
|
|
|
|
|
|
|
|
|
ClickOn(assert, ctx, `#streams`) |
|
|
|
ClickOn(assert, ctx, `#streams`) |
|
|
|