Created
July 24, 2017 08:19
-
-
Save VasilyStrelyaev/7f690d62cc97b9bacefcf116c062b982 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Selector } from 'testcafe'; | |
const rows = Selector('.row'); | |
const removeButton = Selector('.remove-row'); | |
const signInButton = Selector('#sign-in'); | |
const signOutButton = Selector('#sign-out'); | |
const loginInput = Selector('#login'); | |
const passwordInput = Selector('#password'); | |
fixture `My Fixture` | |
.page `http://example.com`; | |
test('Test that involves two users', async t => { | |
await t | |
// Log in a regular user. | |
.typeText(loginInput, 'TestUser') | |
.typeText(passwordInput, 'testpass') | |
.click(signInButton) | |
// Check that the user can see the data table | |
// but cannot see the Remove button. | |
.expect(rows.count).eql(10) | |
.expect(removeButton.visible).notOk() | |
// Log in an administrator. | |
.click(signOutButton) | |
.typeText(loginInput, 'Admin') | |
.typeText(passwordInput, 'adminpass') | |
.click(signInButton) | |
// Remove the first row. | |
.expect(removeButton.visible).ok() | |
.click(removeButton) | |
// Switch back to a regular user account. | |
.click(signOutButton) | |
.typeText(loginInput, 'TestUser') | |
.typeText(passwordInput, 'testpass') | |
.click(signInButton) | |
// Check that the row was removed. | |
.expect(rows.count).eql(9); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment