123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 |
- require 'browser_test_helper'
- class FormTest < TestCase
- def test_basic
- agent = browser_instance
- login(
- browser: agent,
- username: 'master@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all(
- browser: agent,
- )
- # disable form
- click(
- browser: agent,
- css: 'a[href="#manage"]',
- )
- click(
- browser: agent,
- css: '.content.active a[href="#channels/form"]',
- )
- switch(
- browser: agent,
- css: '.content.active .js-formSetting',
- type: 'off',
- )
- # admin preview test
- sleep 1
- click(
- browser: agent,
- css: '.content.active .js-formBtn',
- )
- sleep 10
- set(
- browser: agent,
- css: 'body div.zammad-form-modal [name="name"]',
- value: 'some sender',
- )
- set(
- browser: agent,
- css: 'body div.zammad-form-modal [name="body"]',
- value: '',
- )
- click(
- browser: agent,
- css: 'body div.zammad-form-modal button[type="submit"]',
- )
- watch_for(
- browser: agent,
- css: 'body div.zammad-form-modal .has-error [name="body"]',
- )
- watch_for_disappear(
- browser: agent,
- css: 'body div.zammad-form-modal button[type="submit"][disabled]',
- )
- set(
- browser: agent,
- css: 'body div.zammad-form-modal [name="body"]',
- value: 'new body',
- )
- set(
- browser: agent,
- css: 'body div.zammad-form-modal [name="email"]',
- value: 'somebody@notexistinginanydomainspacealsonothere.nowhere',
- )
- click(
- browser: agent,
- css: 'body div.zammad-form-modal button[type="submit"]',
- )
- watch_for(
- browser: agent,
- css: 'body div.zammad-form-modal .has-error [name="email"]',
- )
- watch_for_disappear(
- browser: agent,
- css: 'body div.zammad-form-modal button[type="submit"][disabled]',
- )
- set(
- browser: agent,
- css: 'body div.zammad-form-modal [name="email"]',
- value: 'discard@znuny.com',
- )
- click(
- browser: agent,
- css: 'body div.zammad-form-modal button[type="submit"]',
- )
- watch_for(
- browser: agent,
- css: 'body div.zammad-form-modal',
- value: 'Thank you for your inquiry',
- )
- # click on backgroud (not on thank you dialog)
- element = agent.find_elements({ css: 'body div.zammad-form-modal' })[0]
- agent.action.move_to(element, 200, 200).perform
- agent.action.click.perform
- customer = browser_instance
- location(
- browser: customer,
- url: "#{browser_url}/assets/form/form.html",
- )
- watch_for(
- browser: customer,
- css: '.js-logDisplay',
- value: 'Faild to load form config, feature is disabled',
- )
- switch(
- browser: agent,
- css: '.content.active .js-formSetting',
- type: 'on',
- )
- reload(
- browser: customer,
- )
- sleep 4
- match_not(
- browser: customer,
- css: '.js-logDisplay',
- value: 'Faild to load form config, feature is disabled',
- )
- exists_not(
- browser: customer,
- css: 'body div.zammad-form-modal',
- )
- # modal dialog
- click(
- browser: customer,
- css: '#feedback-form-modal',
- )
- watch_for(
- browser: customer,
- css: 'body div.zammad-form-modal',
- )
- # fill form valid data - but too fast
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="name"]',
- value: 'some name',
- )
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="email"]',
- value: 'discard@znuny.com',
- )
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="body"]',
- value: "some text\nnew line",
- )
- click(
- browser: customer,
- css: 'body div.zammad-form-modal button[type="submit"]',
- )
- # check warning
- alert = customer.switch_to.alert
- alert.dismiss()
- sleep 10
- # fill form invalid data - within correct time
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="name"]',
- value: 'some name',
- )
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="email"]',
- value: 'invalid_email',
- )
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="body"]',
- value: "some text\nnew line",
- )
- click(
- browser: customer,
- css: 'body div.zammad-form-modal button[type="submit"]',
- )
- sleep 10
- exists(
- browser: customer,
- css: 'body div.zammad-form-modal',
- )
- # fill form valid data
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="email"]',
- value: 'discard@znuny.com',
- )
- click(
- browser: customer,
- css: 'body div.zammad-form-modal button[type="submit"]',
- )
- watch_for(
- browser: customer,
- css: 'body div.zammad-form-modal',
- value: 'Thank you for your inquiry',
- )
- # click on backgroud (not on thank you dialog)
- element = customer.find_elements({ css: 'body div.zammad-form-modal' })[0]
- customer.action.move_to(element, 200, 200).perform
- customer.action.click.perform
- sleep 1
- exists_not(
- browser: customer,
- css: 'body div.zammad-form-modal',
- )
- # fill form invalid data - within correct time
- click(
- browser: customer,
- css: '#feedback-form-modal',
- )
- sleep 10
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="name"]',
- value: '',
- )
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="email"]',
- value: 'discard@znuny.com',
- )
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="body"]',
- value: "some text\nnew line",
- )
- click(
- browser: customer,
- css: 'body div.zammad-form-modal button[type="submit"]',
- )
- watch_for(
- browser: customer,
- css: 'body div.zammad-form-modal .has-error [name="name"]',
- )
- watch_for_disappear(
- browser: customer,
- css: 'body div.zammad-form-modal button[type="submit"][disabled]',
- )
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="name"]',
- value: 'some sender',
- )
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="body"]',
- value: '',
- )
- click(
- browser: customer,
- css: 'body div.zammad-form-modal button[type="submit"]',
- )
- watch_for(
- browser: customer,
- css: 'body div.zammad-form-modal .has-error [name="body"]',
- )
- watch_for_disappear(
- browser: customer,
- css: 'body div.zammad-form-modal button[type="submit"][disabled]',
- )
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="body"]',
- value: 'new body',
- )
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="email"]',
- value: 'somebody@notexistinginanydomainspacealsonothere.nowhere',
- )
- click(
- browser: customer,
- css: 'body div.zammad-form-modal button[type="submit"]',
- )
- watch_for(
- browser: customer,
- css: 'body div.zammad-form-modal .has-error [name="email"]',
- )
- watch_for_disappear(
- browser: customer,
- css: 'body div.zammad-form-modal button[type="submit"][disabled]',
- )
- set(
- browser: customer,
- css: 'body div.zammad-form-modal [name="email"]',
- value: 'discard@znuny.com',
- )
- click(
- browser: customer,
- css: 'body div.zammad-form-modal button[type="submit"]',
- )
- watch_for(
- browser: customer,
- css: 'body div.zammad-form-modal',
- value: 'Thank you for your inquiry',
- )
- # click on backgroud (not on thank you dialog)
- element = customer.find_elements({ css: 'body div.zammad-form-modal' })[0]
- customer.action.move_to(element, 200, 200).perform
- customer.action.click.perform
- sleep 1
- exists_not(
- browser: customer,
- css: 'body div.zammad-form-modal',
- )
- # inline form
- set(
- browser: customer,
- css: '.zammad-form [name="name"]',
- value: 'Some Name',
- )
- set(
- browser: customer,
- css: '.zammad-form [name="email"]',
- value: 'discard@znuny.com',
- )
- set(
- browser: customer,
- css: '.zammad-form [name="body"]',
- value: 'some text',
- )
- click(
- browser: customer,
- css: '.zammad-form button[type="submit"]',
- )
- watch_for(
- browser: customer,
- css: '.zammad-form',
- value: 'Thank you for your inquiry',
- )
- end
- end
|