Now easier to write tests for the app, and most pages are at least touched.
This commit is contained in:
parent
d095bc9ff4
commit
ecc264db8c
14 changed files with 124 additions and 89 deletions
|
|
@ -2,7 +2,7 @@ package tests
|
|||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
browser "github.com/chromedp/chromedp"
|
||||
"zedshaw.games/webapp/data"
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
|
|
@ -14,12 +14,12 @@ func deleteTestUser(username string) {
|
|||
}
|
||||
|
||||
func TestLogin(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
require := require.New(t)
|
||||
deleteTestUser("testerzed")
|
||||
|
||||
ctx, cancel := Setup(5); defer cancel()
|
||||
|
||||
Run(assert, ctx,
|
||||
Run(require, ctx,
|
||||
browser.Navigate(`http://127.0.0.1:5002/register/`),
|
||||
browser.WaitVisible(`body > footer`),
|
||||
browser.WaitVisible(`[data-testid="register-index-page"]`),
|
||||
|
|
@ -30,7 +30,7 @@ func TestLogin(t *testing.T) {
|
|||
browser.WaitVisible(`body > footer`),
|
||||
browser.WaitVisible(`[data-testid="login-index-page"]`))
|
||||
|
||||
Run(assert, ctx,
|
||||
Run(require, ctx,
|
||||
browser.Navigate(`http://127.0.0.1:5002/login/`),
|
||||
browser.WaitVisible(`body > footer`),
|
||||
browser.WaitVisible(`[data-testid="login-index-page"]`),
|
||||
|
|
@ -44,29 +44,41 @@ func TestLogin(t *testing.T) {
|
|||
deleteTestUser("testerzed")
|
||||
}
|
||||
|
||||
func TestStreamPage(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
func TestStreamsPage(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
ctx, cancel := Setup(2);
|
||||
defer cancel();
|
||||
|
||||
var title string
|
||||
GoTo(require, ctx, "/", `#streams`)
|
||||
ClickOn(require, ctx, `#streams`)
|
||||
WaitFor(require, ctx, `[data-testid="stream-index-page"]`)
|
||||
ExpectText(require, ctx, `#page-title`, "Past Streams")
|
||||
}
|
||||
|
||||
err := browser.Run(ctx,
|
||||
browser.Navigate(`http://127.0.0.1:5002`),
|
||||
browser.WaitVisible(`body > footer`),
|
||||
browser.WaitVisible(`#streams`),)
|
||||
assert.NoError(err)
|
||||
func TestLivePage(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
ClickOn(assert, ctx, `#streams`)
|
||||
ctx, cancel := Setup(2);
|
||||
defer cancel();
|
||||
|
||||
err = browser.Run(ctx, browser.WaitVisible(`#streams-title`))
|
||||
assert.NoError(err)
|
||||
GoTo(require, ctx, "/", `#live`)
|
||||
ClickOn(require, ctx, `#live`)
|
||||
WaitFor(require, ctx, `[data-testid="live-index-page"]`)
|
||||
}
|
||||
|
||||
err = browser.Run(ctx, browser.Text(`#streams-title`, &title))
|
||||
assert.NoError(err)
|
||||
func TestGamePage(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
assert.Equal(title, "Past Streams")
|
||||
ctx, cancel := Setup(2);
|
||||
defer cancel();
|
||||
|
||||
GoTo(require, ctx, "/", `#game`)
|
||||
ClickOn(require, ctx, `#game`)
|
||||
WaitFor(require, ctx, `[data-testid="game-index-page"]`)
|
||||
ExpectText(require, ctx, `#page-title`, "Zed's Trash Ass Games")
|
||||
ClickOn(require, ctx, `[data-testid="game-link"]`)
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue