You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.8 KiB
76 lines
1.8 KiB
package tests
|
|
|
|
import (
|
|
"testing"
|
|
// "github.com/stretchr/testify/require"
|
|
"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) {
|
|
deleteTestUser("testerzed")
|
|
z, cancel := Setup(t, 5)
|
|
defer cancel()
|
|
|
|
z.GoTo("/register/", `[data-testid="register-index-page"]`)
|
|
z.TypeIn(`#username`, `testerzed`)
|
|
z.TypeIn(`#email`, `zed@test.com`)
|
|
z.TypeIn(`#password`, `iamdumbass`)
|
|
z.ClickOn(`#register-submit`)
|
|
z.WaitFor(`[data-testid="login-index-page"]`)
|
|
|
|
z.GoTo("/login/", `[data-testid="login-index-page"]`)
|
|
z.TypeIn(`#username`, `testerzed`)
|
|
z.TypeIn(`#password`, `iamdumbass`)
|
|
z.ClickOn(`#login-submit`)
|
|
z.WaitFor(`[data-testid="index-page"]`)
|
|
|
|
/// delete the user here
|
|
deleteTestUser("testerzed")
|
|
}
|
|
|
|
func TestStreamsPage(t *testing.T) {
|
|
z, cancel := Setup(t, 2)
|
|
defer cancel()
|
|
|
|
z.GoTo("/", `#streams`)
|
|
z.ClickOn(`#streams`)
|
|
z.WaitFor(`[data-testid="stream-index-page"]`)
|
|
z.ExpectText(`#page-title`, "Past Streams")
|
|
}
|
|
|
|
func TestLivePage(t *testing.T) {
|
|
z, cancel := Setup(t, 2);
|
|
defer cancel();
|
|
|
|
z.GoTo("/", `#live`)
|
|
z.ClickOn(`#live`)
|
|
z.WaitFor(`[data-testid="live-index-page"]`)
|
|
z.TypeIn("#url", "https://test.com/")
|
|
z.TypeIn("#description", "A test URL.")
|
|
z.ClickOn(`#submit`)
|
|
}
|
|
|
|
func TestGamePage(t *testing.T) {
|
|
z, cancel := Setup(t, 2);
|
|
defer cancel();
|
|
|
|
z.GoTo("/", `#game`)
|
|
z.ClickOn(`#game`)
|
|
z.WaitFor(`[data-testid="game-index-page"]`)
|
|
z.ExpectText(`#page-title`, "Zed's Trash Ass Games")
|
|
z.ClickOn(`[data-testid="game-link"]`)
|
|
}
|
|
|
|
func TestMain(m *testing.M) {
|
|
data.Setup("sqlite3", "./db.sqlite3")
|
|
|
|
m.Run()
|
|
|
|
data.Shutdown()
|
|
}
|
|
|