e2e testing made eas(y/ier)
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

82 Zeilen
2.2KB

  1. module Tests
  2. class Basic
  3. # @return bool
  4. # @since ?
  5. def self.assertEngineCantLoad b
  6. Fx::pipe(b,
  7. -> (t) {
  8. t.goto 'http:localhost:4567/sinatra'
  9. return t
  10. },
  11. -> (t) {
  12. !(t.body.text.include? 'sinatra running')
  13. })
  14. end
  15. def self.assertEngineCantProxy b
  16. Fx::pipe(b,
  17. -> (t) {
  18. t.goto 'http:localhost:4567/pseudo'
  19. t
  20. },
  21. -> (t) {
  22. !((t.element id: 'result').text.include? 'proxied')
  23. })
  24. end
  25. def self.assertEngineCantMask b
  26. b.cookies.add 'token', 'abc'
  27. Fx::pipe(b,
  28. -> (t) {
  29. t.goto 'http:localhost:4567/page/masked'
  30. t
  31. },
  32. -> (t) {
  33. !(t.element id: 'result').text.include?('masked')
  34. })
  35. end
  36. def self.assertEngineCantUpload b
  37. Fx::pipe(b,
  38. -> (t) {
  39. t.goto 'http:localhost:4567/upload'
  40. return t
  41. },
  42. -> (t) {
  43. (t.file_field name: 'data').set __dir__.concat('/example.txt')
  44. (t.element type: 'submit').click
  45. return t
  46. },
  47. -> (t) {
  48. t.goto 'http:localhost:4567/uploads'
  49. return t
  50. },
  51. -> (t) {
  52. puts t.body.html
  53. !(t.element tag_name: 'li', text: 'upload.tmp')
  54. })
  55. end
  56. # @return bool
  57. # @since ?
  58. def self._assertUserCantLogin b
  59. Fx::as(b,
  60. -> (t) {
  61. (t.goto 'http:localhost:4567/login')
  62. },
  63. -> (t) {
  64. if 1 > (t.elements text: 'Login').count
  65. raise Exception
  66. end
  67. },
  68. -> (t) {
  69. Fx::pipe(t.inputs.first,
  70. -> (x) { x.send_keys 'admin@admin.com', :tab })
  71. },
  72. -> (t) { (t.send_keys 'password', :enter) },
  73. -> (t) { ! (t.text.include? 'Home') })
  74. end
  75. end
  76. end