Rewrite scenario1 with new macro
This commit is contained in:
parent
cb5923d9f8
commit
1b55aec5d2
1 changed files with 32 additions and 76 deletions
|
|
@ -9,96 +9,52 @@ proc test*(session: Session, baseUrl: string) =
|
||||||
|
|
||||||
# Sanity checks
|
# Sanity checks
|
||||||
test "shows sign up":
|
test "shows sign up":
|
||||||
let signUp = session.findElement("#signup-btn")
|
with session:
|
||||||
check signUp.get().getText() == "Sign up"
|
checkText "#signup-btn", "Sign up"
|
||||||
|
|
||||||
test "shows log in":
|
test "shows log in":
|
||||||
let logIn = session.findElement("#login-btn")
|
with session:
|
||||||
check logIn.get().getText() == "Log in"
|
checkText "#login-btn", "Log in"
|
||||||
|
|
||||||
test "is empty":
|
test "is empty":
|
||||||
let thread = session.findElement("tr > td.thread-title")
|
with session:
|
||||||
check thread.isNone()
|
check "tr > td.thread-title", isNone
|
||||||
|
|
||||||
# Logging in
|
# Logging in
|
||||||
test "can login/logout":
|
test "can login/logout":
|
||||||
let logIn = session.findElement("#login-btn").get()
|
with session:
|
||||||
logIn.click()
|
click "#login-btn"
|
||||||
|
|
||||||
let usernameField = session.findElement(
|
sendKeys "#login-form input[name='username']", "admin"
|
||||||
"#login-form input[name='username']"
|
sendKeys "#login-form input[name='password']", "admin"
|
||||||
)
|
|
||||||
check usernameField.isSome()
|
|
||||||
let passwordField = session.findElement(
|
|
||||||
"#login-form input[name='password']"
|
|
||||||
)
|
|
||||||
check passwordField.isSome()
|
|
||||||
|
|
||||||
usernameField.get().sendKeys("admin")
|
sendKeys "#login-form input[name='password']", Key.Enter
|
||||||
passwordField.get().sendKeys("admin")
|
wait(5000)
|
||||||
passwordField.get().click() # Focus field.
|
|
||||||
session.press(Key.Enter)
|
|
||||||
|
|
||||||
waitForLoad(session, 5000)
|
# Verify that the user menu has been initialised properly.
|
||||||
|
click "#profile-btn"
|
||||||
|
checkText "#profile-btn #profile-name", "admin"
|
||||||
|
|
||||||
# Verify that the user menu has been initialised properly.
|
# Check whether we can log out.
|
||||||
let profileButton = session.findElement(
|
click "#logout-btn"
|
||||||
"#main-navbar figure.avatar"
|
# Verify we have logged out by looking for the log in button.
|
||||||
).get()
|
ensureExists "#login-btn"
|
||||||
profileButton.click()
|
|
||||||
|
|
||||||
let profileName = session.findElement(
|
|
||||||
"#main-navbar .menu-right div.tile-content"
|
|
||||||
).get()
|
|
||||||
|
|
||||||
check profileName.getText() == "admin"
|
|
||||||
|
|
||||||
# Check whether we can log out.
|
|
||||||
let logoutLink = session.findElement(
|
|
||||||
"Logout",
|
|
||||||
LinkTextSelector
|
|
||||||
).get()
|
|
||||||
logoutLink.click()
|
|
||||||
|
|
||||||
# Verify we have logged out by looking for the log in button.
|
|
||||||
check session.findElement("#login-btn").isSome()
|
|
||||||
|
|
||||||
test "can register":
|
test "can register":
|
||||||
let signup = session.findElement("#signup-btn").get()
|
with session:
|
||||||
signup.click()
|
click "#signup-btn"
|
||||||
|
|
||||||
let emailField = session.findElement(
|
sendKeys "#signup-form input[name='email']", "test@test.com"
|
||||||
"#signup-form input[name='email']"
|
sendKeys "#signup-form input[name='username']", "test"
|
||||||
).get()
|
sendKeys "#signup-form input[name='password']", "test"
|
||||||
let usernameField = session.findElement(
|
|
||||||
"#signup-form input[name='username']"
|
|
||||||
).get()
|
|
||||||
let passwordField = session.findElement(
|
|
||||||
"#signup-form input[name='password']"
|
|
||||||
).get()
|
|
||||||
|
|
||||||
emailField.sendKeys("test@test.com")
|
click "#signup-modal .create-account-btn"
|
||||||
usernameField.sendKeys("test")
|
wait(5000)
|
||||||
passwordField.sendKeys("test")
|
|
||||||
|
|
||||||
let createAccount = session.findElement(
|
# Verify that the user menu has been initialised properly.
|
||||||
"#signup-modal .modal-footer .btn-primary"
|
click "#profile-btn"
|
||||||
).get()
|
checkText "#profile-btn #profile-name", "test"
|
||||||
|
# close menu
|
||||||
createAccount.click()
|
click "#profile-btn"
|
||||||
|
|
||||||
waitForLoad(session, 5000)
|
|
||||||
|
|
||||||
# Verify that the user menu has been initialised properly.
|
|
||||||
let profileButton = session.findElement(
|
|
||||||
"#main-navbar figure.avatar"
|
|
||||||
).get()
|
|
||||||
profileButton.click()
|
|
||||||
|
|
||||||
let profileName = session.findElement(
|
|
||||||
"#main-navbar .menu-right div.tile-content"
|
|
||||||
).get()
|
|
||||||
|
|
||||||
check profileName.getText() == "test"
|
|
||||||
|
|
||||||
logout(session)
|
logout(session)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue