Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: adds browser tests for registration example #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions test/browser/components/sys-form-button/colors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Selector } from 'testcafe'

import { assertScreenshot } from '../../../utility/browser'

fixture`SysFormButton Colors`
.page`http://localhost:7684/iframe.html?id=high-level-components-button--colors&viewMode=story`

const button = (i) => Selector(`#root button:nth-child(${i})`)

test('screenshots', async (t) => {
await assertScreenshot(button(1), 'components/sys-form-button/colors-normal')
await assertScreenshot(button(2), 'components/sys-form-button/colors-primary')
await assertScreenshot(button(3), 'components/sys-form-button/colors-secondary')
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Selector } from 'testcafe'

import { assertScreenshot } from '../../utility/browser'
import { assertScreenshot } from '../../../utility/browser'

fixture`SysForm CustomSubmit`
.page`http://localhost:7684/iframe.html?id=high-level-components-form--custom-submit&viewMode=story`
Expand All @@ -20,10 +20,10 @@ test('login button is reactive to form errors', async (t) => {
await t.typeText(password, 'validpassword')
await t.pressKey('tab')
await t.expect(button.getAttribute('disabled')).eql(undefined)
await assertScreenshot(form, 'sys-form/reactive-enabled')
await assertScreenshot(form, 'components/sys-form/reactive-enabled')
await t.typeText(email, 'nope', { replace: true })
await t.typeText(password, 'nope', { replace: true })
await t.pressKey('tab')
await t.expect(button.getAttribute('disabled')).eql('disabled')
await assertScreenshot(form, 'sys-form/reactive-disabled')
await assertScreenshot(form, 'components/sys-form/reactive-disabled')
})
38 changes: 38 additions & 0 deletions test/browser/examples/registration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Selector, t } from 'testcafe'

fixture`SysForm CustomSubmit`
.page`http://localhost:7684/iframe.html?id=examples-register--normal&viewMode=story`

const firstName = Selector('input#given_name')
const lastName = Selector('input#family_name')
const email = Selector('input#email')
const phone = Selector('input#phone_number')
const password = Selector('input#new_password')
const confirmed = Selector('input#password_confirm')
const button = Selector('button')

async function fill (values) {
await t.typeText(firstName, values.firstName || 'first')
await t.typeText(lastName, values.lastName || 'last')
await t.typeText(email, values.email || '[email protected]')
await t.typeText(phone, values.phone || '1 234 567 8901')
await t.typeText(password, values.password || 'example')
await t.typeText(confirmed, values.confirmed || values.password || 'example')
await t.pressKey('tab')
}

test('allows spaces in first name', async (t) => {
await fill({ firstName: 'john joe bob son' })
await t.expect(button.getAttribute('disabled')).eql(undefined)
})

test('password confirmation', async (t) => {
await fill({
password: 'thisisapassword',
confirmed: 'incorrect password'
})

await t.expect(button.getAttribute('disabled')).eql('disabled')
await t.typeText(confirmed, 'thisisapassword', { replace: true })
await t.expect(button.getAttribute('disabled')).eql(undefined)
})
14 changes: 0 additions & 14 deletions test/browser/sys-form-button/colors.js

This file was deleted.