ydim-html 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.travis.yml +29 -0
  4. data/Gemfile +12 -0
  5. data/History.txt +11 -0
  6. data/LICENSE.txt +339 -0
  7. data/Manifest.txt +47 -0
  8. data/Rakefile +21 -0
  9. data/bin/ydim-htmld +38 -0
  10. data/doc/favicon.ico +0 -0
  11. data/doc/index.rbx +16 -0
  12. data/doc/resources/javascript/dojo.js +5940 -0
  13. data/doc/resources/javascript/iframe_history.html +53 -0
  14. data/doc/resources/javascript/ydim.js +67 -0
  15. data/doc/resources/ydim/ydim.css +113 -0
  16. data/lib/ydim/html.rb +10 -0
  17. data/lib/ydim/html/config.rb +37 -0
  18. data/lib/ydim/html/state/ajax_values.rb +17 -0
  19. data/lib/ydim/html/state/autoinvoice.rb +94 -0
  20. data/lib/ydim/html/state/confirm.rb +16 -0
  21. data/lib/ydim/html/state/debitor.rb +82 -0
  22. data/lib/ydim/html/state/debitors.rb +24 -0
  23. data/lib/ydim/html/state/global.rb +100 -0
  24. data/lib/ydim/html/state/global_predefine.rb +14 -0
  25. data/lib/ydim/html/state/init.rb +21 -0
  26. data/lib/ydim/html/state/invoice.rb +180 -0
  27. data/lib/ydim/html/state/invoices.rb +70 -0
  28. data/lib/ydim/html/state/pdf.rb +17 -0
  29. data/lib/ydim/html/util/lookandfeel.rb +133 -0
  30. data/lib/ydim/html/util/server.rb +37 -0
  31. data/lib/ydim/html/util/session.rb +29 -0
  32. data/lib/ydim/html/util/validator.rb +63 -0
  33. data/lib/ydim/html/version.rb +7 -0
  34. data/lib/ydim/html/view/ajax_values.rb +27 -0
  35. data/lib/ydim/html/view/autoinvoice.rb +80 -0
  36. data/lib/ydim/html/view/autoinvoices.rb +42 -0
  37. data/lib/ydim/html/view/confirm.rb +28 -0
  38. data/lib/ydim/html/view/debitor.rb +118 -0
  39. data/lib/ydim/html/view/debitors.rb +45 -0
  40. data/lib/ydim/html/view/htmlgrid.rb +104 -0
  41. data/lib/ydim/html/view/init.rb +30 -0
  42. data/lib/ydim/html/view/invoice.rb +218 -0
  43. data/lib/ydim/html/view/invoices.rb +159 -0
  44. data/lib/ydim/html/view/navigation.rb +29 -0
  45. data/lib/ydim/html/view/pdf.rb +24 -0
  46. data/lib/ydim/html/view/template.rb +71 -0
  47. data/readme.md +28 -0
  48. data/spec/smoketest_spec.rb +234 -0
  49. data/spec/spec_helper.rb +117 -0
  50. data/spec/stub/http_server.rb +157 -0
  51. data/test/selenium.rb +1690 -0
  52. data/test/selenium/selenium-server.jar +0 -0
  53. data/test/selenium/test_autoinvoice.rb +319 -0
  54. data/test/selenium/test_debitor.rb +344 -0
  55. data/test/selenium/test_debitors.rb +47 -0
  56. data/test/selenium/test_init.rb +105 -0
  57. data/test/selenium/test_invoice.rb +296 -0
  58. data/test/selenium/test_invoices.rb +176 -0
  59. data/test/selenium/unit.rb +125 -0
  60. data/test/stub/http_server.rb +141 -0
  61. data/test/suite.rb +15 -0
  62. data/ydim-html.gemspec +36 -0
  63. metadata +302 -0
@@ -0,0 +1,319 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # Html::Selenium::TestAutoInvoice -- de.oddb.org -- 15.12.2006 -- hwyss@ywesee.com
4
+
5
+ $: << File.expand_path('..', File.dirname(__FILE__))
6
+
7
+ require 'ostruct'
8
+ require 'selenium/unit'
9
+ require 'ydim/debitor'
10
+ require 'ydim/invoice'
11
+
12
+ module YDIM
13
+ module Html
14
+ module Selenium
15
+ class TestAutoInvoice < Test::Unit::TestCase
16
+ include Selenium::TestCase
17
+ def test_create_autoinvoice
18
+ debitor = YDIM::Debitor.new(1)
19
+ debitor.name = 'Foo'
20
+ debitor.email = 'debitor@ywesee.com'
21
+ debitor.phone = '0041435400549'
22
+ debitor.debitor_type = 'dt_pharmacy'
23
+ session = login([debitor])
24
+ assert_equal "YDIM", get_title
25
+ session.should_receive(:debitor).and_return(debitor)
26
+ click "link=Foo"
27
+ wait_for_page_to_load "30000"
28
+ assert_equal "YDIM", get_title
29
+
30
+ click "create_autoinvoice"
31
+ wait_for_page_to_load "30000"
32
+ assert_equal "YDIM", get_title
33
+ assert_equal "ID", get_text("//label[@for='unique_id']")
34
+
35
+ url = "http://localhost:10080/de/debitor/unique_id/1"
36
+ assert_equal url, get_attribute("//a[@name='name']@href")
37
+ assert_equal url, get_attribute("//a[@name='email']@href")
38
+ assert_equal "Foo", get_text("//a[@name='name']")
39
+ assert_equal "debitor@ywesee.com", get_text("//a[@name='email']")
40
+
41
+ assert is_element_present("//input[@name='description']")
42
+ assert_equal "text",
43
+ get_attribute("//input[@name='description']@type")
44
+ assert_equal "Beschreibung", get_text("//label[@for='description']")
45
+
46
+ assert is_element_present("//input[@name='date']")
47
+ assert_equal "text", get_attribute("//input[@name='date']@type")
48
+ assert_equal "Rechnungsdatum", get_text("//label[@for='date']")
49
+ assert_equal "", get_value("//input[@name='date']")
50
+
51
+ assert is_element_present("//select[@name='currency']")
52
+ assert_equal "Währung", get_text("//label[@for='currency']")
53
+
54
+ assert is_element_present("//input[@name='precision']")
55
+ assert_equal "text", get_attribute("//input[@name='precision']@type")
56
+ assert_equal "Kommastellen", get_text("//label[@for='precision']")
57
+ assert_equal "2", get_value("//input[@name='precision']")
58
+
59
+ assert is_element_present("//select[@name='invoice_interval']")
60
+ assert_equal "inv_12",
61
+ get_value("//select[@name='invoice_interval']")
62
+ assert_equal "Rechnungs-Intervall",
63
+ get_text("//label[@for='invoice_interval']")
64
+
65
+ assert is_element_present("update")
66
+ assert !is_element_present("create_item")
67
+ assert !is_element_present("pdf")
68
+ assert !is_element_present("send_invoice")
69
+ assert !is_element_present("generate_invoice")
70
+ end
71
+ def test_create_autoinvoice__fail
72
+ debitor = YDIM::Debitor.new(1)
73
+ debitor.name = 'Foo'
74
+ debitor.email = 'debitor@ywesee.com'
75
+ debitor.phone = '0041435400549'
76
+ debitor.debitor_type = 'dt_pharmacy'
77
+ session = login([debitor])
78
+ assert_equal "YDIM", get_title
79
+ session.should_receive(:debitor).and_return(debitor)
80
+ click "link=Foo"
81
+ wait_for_page_to_load "30000"
82
+ assert_equal "YDIM", get_title
83
+
84
+ click "create_autoinvoice"
85
+ wait_for_page_to_load "30000"
86
+ assert_equal "YDIM", get_title
87
+
88
+ click "update"
89
+ wait_for_page_to_load "30000"
90
+
91
+ assert is_text_present('Bitte geben Sie das Feld "Beschreibung" an.')
92
+ assert is_element_present("update")
93
+ assert !is_element_present("create_item")
94
+ assert !is_element_present("pdf")
95
+ assert !is_element_present("send_invoice")
96
+ assert !is_element_present("generate_invoice")
97
+ end
98
+ def test_create_autoinvoice__succeed
99
+ debitor = YDIM::Debitor.new(1)
100
+ debitor.name = 'Foo'
101
+ debitor.email = 'debitor@ywesee.com'
102
+ debitor.phone = '0041435400549'
103
+ debitor.debitor_type = 'dt_pharmacy'
104
+ session = login([debitor])
105
+ assert_equal "YDIM", get_title
106
+ session.should_receive(:debitor).and_return(debitor)
107
+ click "link=Foo"
108
+ wait_for_page_to_load "30000"
109
+ assert_equal "YDIM", get_title
110
+
111
+ click "create_autoinvoice"
112
+ wait_for_page_to_load "30000"
113
+ assert_equal "YDIM", get_title
114
+
115
+ type "description", "Newly created AutoInvoice"
116
+
117
+ invoice = nil
118
+ session.should_receive(:create_autoinvoice).and_return {
119
+ invoice = AutoInvoice.new(10001)
120
+ invoice.debitor = debitor
121
+ flexstub(invoice).should_receive(:odba_store)
122
+ invoice
123
+ }
124
+
125
+ click "update"
126
+ wait_for_page_to_load "30000"
127
+
128
+ assert_equal("Newly created AutoInvoice", invoice.description)
129
+ assert_nil(invoice.date)
130
+ assert_equal("CHF", invoice.currency)
131
+ assert_equal(2, invoice.precision)
132
+ assert_equal("inv_12", invoice.invoice_interval)
133
+
134
+ assert !is_text_present('Bitte geben Sie das Feld "Beschreibung" an.')
135
+ assert is_element_present("update")
136
+ assert is_element_present("create_item")
137
+ assert !is_element_present("pdf")
138
+ assert !is_element_present("send_invoice")
139
+ assert !is_element_present("generate_invoice")
140
+ assert !is_element_present("reminder_subject")
141
+ assert !is_element_present("reminder_body")
142
+
143
+ assert_equal "Newly created AutoInvoice",
144
+ get_value("//input[@name='description']")
145
+
146
+ item = nil
147
+ session.should_receive(:add_items).and_return { |invoice_id, items, invoice_key|
148
+ assert_equal(10001, invoice_id)
149
+ assert_equal(:autoinvoice, invoice_key)
150
+ assert_equal(1, items.size)
151
+ hash = items.first
152
+ assert_instance_of(Hash, hash)
153
+ assert_equal(1, hash.size)
154
+ assert_instance_of(Time, hash[:time])
155
+ item = YDIM::Item.new(hash)
156
+ item.index = 0
157
+ invoice.items.push(item)
158
+ item
159
+ }
160
+ click "create_item"
161
+ wait_for_condition "selenium.isElementPresent('text[0]');", "10000"
162
+ assert is_element_present("quantity[0]")
163
+ assert is_element_present("unit[0]")
164
+ assert is_element_present("price[0]")
165
+ assert_equal "0.00", get_text("total_netto0")
166
+
167
+ session.should_receive(:update_item).and_return { |invoice_id, item_index, data, invoice_key|
168
+ assert_equal(10001, invoice_id)
169
+ assert_equal(0, item_index)
170
+ assert_equal(:autoinvoice, invoice_key)
171
+ data.each { |key, val|
172
+ item.send("#{key}=", val)
173
+ }
174
+ item
175
+ }
176
+
177
+ type "text[0]", "Item 1"
178
+ type "quantity[0]", "2"
179
+ type "unit[0]", "pieces"
180
+ type "price[0]", "3.25"
181
+ sleep 0.2
182
+ assert_equal "6.50", get_text("total_netto0")
183
+
184
+ click "update"
185
+ wait_for_page_to_load "30000"
186
+
187
+ assert is_text_present("Total Netto")
188
+ assert is_text_present("MwSt. (7.6%)")
189
+ assert is_text_present("Total Brutto")
190
+
191
+ assert is_element_present("update")
192
+ assert is_element_present("create_item")
193
+ assert !is_element_present("pdf")
194
+ assert !is_element_present("send_invoice")
195
+ assert is_element_present("generate_invoice")
196
+ assert is_element_present("reminder_subject")
197
+ assert is_element_present("reminder_body")
198
+
199
+ assert_equal "<invoice> 2 x Item 1 CHF 6.50 Total Netto CHF 6.50 </invoice>",
200
+ get_text("reminder_body")
201
+
202
+ click "link=debitor@ywesee.com"
203
+ wait_for_page_to_load "30000"
204
+ assert is_text_present("Newly created AutoInvoice")
205
+ end
206
+ def test_generate
207
+ debitor = YDIM::Debitor.new(1)
208
+ debitor.name = 'Foo'
209
+ debitor.email = 'debitor@ywesee.com'
210
+ debitor.phone = '0041435400549'
211
+ debitor.debitor_type = 'dt_pharmacy'
212
+ invoice = YDIM::AutoInvoice.new(10001)
213
+ invoice.debitor = debitor
214
+ invoice.description = 'AutoInvoice'
215
+ flexstub(invoice).should_receive(:odba_store)
216
+ item = YDIM::Item.new(:text => 'Item', :price => '100',
217
+ :quantity => 5)
218
+ invoice.add_item(item)
219
+
220
+ session = login([debitor])
221
+ assert_equal "YDIM", get_title
222
+ session.should_receive(:debitor).and_return(debitor)
223
+ session.should_receive(:autoinvoice).and_return(invoice)
224
+ session.should_receive(:generate_invoice).and_return(invoice)
225
+ session.should_ignore_missing
226
+ click "link=Foo"
227
+ wait_for_page_to_load "30000"
228
+ assert_equal "YDIM", get_title
229
+
230
+ click "link=AutoInvoice"
231
+ wait_for_page_to_load "30000"
232
+ assert_equal "YDIM", get_title
233
+
234
+ click "generate_invoice"
235
+ wait_for_page_to_load "30000"
236
+ assert is_element_present("update")
237
+ assert is_element_present("create_item")
238
+ assert is_element_present("pdf")
239
+ assert is_element_present("send_invoice")
240
+ assert !is_element_present("generate_invoice")
241
+ end
242
+ def test_precision
243
+ debitor = YDIM::Debitor.new(1)
244
+ debitor.name = 'Foo'
245
+ debitor.email = 'debitor@ywesee.com'
246
+ debitor.phone = '0041435400549'
247
+ debitor.debitor_type = 'dt_pharmacy'
248
+ invoice = YDIM::AutoInvoice.new(10001)
249
+ invoice.debitor = debitor
250
+ invoice.description = 'AutoInvoice'
251
+ flexstub(invoice).should_receive(:odba_store)
252
+ item = YDIM::Item.new(:text => 'Item', :price => '3.25',
253
+ :quantity => 2)
254
+ invoice.add_item(item)
255
+
256
+ session = login([debitor])
257
+ assert_equal "YDIM", get_title
258
+ session.should_receive(:debitor).and_return(debitor)
259
+ session.should_receive(:autoinvoice).and_return(invoice)
260
+ session.should_receive(:generate_invoice).and_return(invoice)
261
+ session.should_ignore_missing
262
+ click "link=Foo"
263
+ wait_for_page_to_load "30000"
264
+ assert_equal "YDIM", get_title
265
+
266
+ click "link=AutoInvoice"
267
+ wait_for_page_to_load "30000"
268
+ assert_equal "YDIM", get_title
269
+
270
+ type "precision", "3"
271
+ wait_for_condition "selenium.isTextPresent('6.500')", "10000"
272
+ assert_equal "6.500", get_text("total_netto0")
273
+ end
274
+ def test_reminder
275
+ debitor = YDIM::Debitor.new(1)
276
+ debitor.name = 'Foo'
277
+ debitor.email = 'debitor@ywesee.com'
278
+ debitor.phone = '0041435400549'
279
+ debitor.debitor_type = 'dt_pharmacy'
280
+ invoice = YDIM::AutoInvoice.new(10001)
281
+ invoice.debitor = debitor
282
+ invoice.description = 'AutoInvoice'
283
+ flexstub(invoice).should_receive(:odba_store)
284
+ item = YDIM::Item.new(:text => 'Item', :price => '100',
285
+ :quantity => 5)
286
+ invoice.add_item(item)
287
+
288
+ session = login([debitor])
289
+ assert_equal "YDIM", get_title
290
+ session.should_receive(:debitor).and_return(debitor)
291
+ session.should_receive(:autoinvoice).and_return(invoice)
292
+ session.should_receive(:generate_invoice).and_return(invoice)
293
+ session.should_ignore_missing
294
+ click "link=Foo"
295
+ wait_for_page_to_load "30000"
296
+ assert_equal "YDIM", get_title
297
+
298
+ click "link=AutoInvoice"
299
+ wait_for_page_to_load "30000"
300
+ assert_equal "YDIM", get_title
301
+ assert is_text_present("Es wird kein Erinnerungsmail versendet")
302
+
303
+ type "reminder_subject", "Reminder for Invoice"
304
+ type "reminder_body", "Reminder-Text \n<invoice></invoice>\nThanks."
305
+ click "update"
306
+ wait_for_page_to_load "30000"
307
+ assert_equal "YDIM", get_title
308
+ assert is_text_present("Es wird kein Erinnerungsmail versendet")
309
+
310
+ type "date", "1.12.2006"
311
+ click "update"
312
+ wait_for_page_to_load "30000"
313
+ assert_equal "YDIM", get_title
314
+ assert is_text_present("Wird am 01.11.2006 versendet")
315
+ end
316
+ end
317
+ end
318
+ end
319
+ end
@@ -0,0 +1,344 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # Selenium::TestDebitors -- ydim -- 14.12.2006 -- hwyss@ywesee.com
4
+
5
+ $: << File.expand_path('..', File.dirname(__FILE__))
6
+
7
+ require 'ostruct'
8
+ require 'selenium/unit'
9
+ require 'ydim/invoice'
10
+
11
+ module YDIM
12
+ module Html
13
+ module Selenium
14
+ class TestDebitor < Test::Unit::TestCase
15
+ include Selenium::TestCase
16
+ def test_create_debitor
17
+ login
18
+ assert_equal "YDIM", get_title
19
+ click "create_debitor"
20
+ wait_for_page_to_load "30000"
21
+ assert_equal "YDIM", get_title
22
+ assert_equal "ID", get_text("//label[@for='unique_id']")
23
+
24
+ assert is_element_present("//select[@name='debitor_type']")
25
+ assert_raises(SeleniumCommandError) {
26
+ get_attribute("//select[@name='debitor_type']@onchange")
27
+ }
28
+ assert_equal "Kundenart",
29
+ get_text("//label[@for='debitor_type']")
30
+
31
+ assert is_element_present("//input[@name='name']")
32
+ assert_equal "text",
33
+ get_attribute("//input[@name='name']@type")
34
+ assert_equal "Firma",
35
+ get_text("//label[@for='name']")
36
+
37
+ assert is_element_present("//select[@name='salutation']")
38
+ assert_equal "Anrede",
39
+ get_text("//label[@for='salutation']")
40
+
41
+ assert is_element_present("//input[@name='contact']")
42
+ assert_equal "text",
43
+ get_attribute("//input[@name='contact']@type")
44
+ assert_equal "Name",
45
+ get_text("//label[@for='contact']")
46
+
47
+ assert is_element_present("//input[@name='contact_firstname']")
48
+ assert_equal "text",
49
+ get_attribute("//input[@name='contact_firstname']@type")
50
+ assert_equal "Vorname",
51
+ get_text("//label[@for='contact_firstname']")
52
+
53
+ assert is_element_present("//input[@name='contact_title']")
54
+ assert_equal "text",
55
+ get_attribute("//input[@name='contact_title']@type")
56
+ assert_equal "Titel",
57
+ get_text("//label[@for='contact_title']")
58
+
59
+ assert is_element_present("//input[@name='address_lines']")
60
+ assert_equal "text",
61
+ get_attribute("//input[@name='address_lines']@type")
62
+ assert_equal "Strasse/Nr.",
63
+ get_text("//label[@for='address_lines']")
64
+
65
+ assert is_element_present("//input[@name='location']")
66
+ assert_equal "text",
67
+ get_attribute("//input[@name='location']@type")
68
+ assert_equal "PLZ/Ort",
69
+ get_text("//label[@for='location']")
70
+
71
+ assert is_element_present("//input[@name='emails']")
72
+ assert_equal "text",
73
+ get_attribute("//input[@name='emails']@type")
74
+ assert_equal "Email (max. 3)",
75
+ get_text("//label[@for='emails']")
76
+
77
+ assert is_element_present("//input[@name='phone']")
78
+ assert_equal "text",
79
+ get_attribute("//input[@name='phone']@type")
80
+ assert_equal "Telefon",
81
+ get_text("//label[@for='phone']")
82
+
83
+ assert is_element_present("update")
84
+ assert !is_element_present("create_invoice")
85
+ assert !is_element_present("create_autoinvoice")
86
+ end
87
+ def test_create_debitor__fail
88
+ login
89
+ assert_equal "YDIM", get_title
90
+ click "create_debitor"
91
+ wait_for_page_to_load "30000"
92
+ assert_equal "YDIM", get_title
93
+
94
+ click "update"
95
+ wait_for_page_to_load "30000"
96
+ assert_equal "YDIM", get_title
97
+
98
+ assert is_text_present('Bitte geben Sie das Feld "Kundenart" an.')
99
+ assert is_text_present('Bitte geben Sie das Feld "Firma" an.')
100
+ assert is_text_present('Bitte geben Sie das Feld "Name" an.')
101
+ assert is_text_present('Bitte geben Sie das Feld "PLZ/Ort" an.')
102
+ assert is_text_present('Bitte geben Sie das Feld "Email (max. 3)" an.')
103
+ assert !is_element_present("create_invoice")
104
+ assert !is_element_present("create_autoinvoice")
105
+ end
106
+ def test_create_debitor__fail_validated
107
+ login
108
+ assert_equal "YDIM", get_title
109
+ click "create_debitor"
110
+ wait_for_page_to_load "30000"
111
+ assert_equal "YDIM", get_title
112
+
113
+ select "debitor_type", "Apotheke"
114
+ type "name", "Company"
115
+ select "salutation", "Herr"
116
+ type "contact", "Contact"
117
+ type "contact_firstname", "Firstname"
118
+ type "contact_title", "Dr."
119
+ type "address_lines", "Street 45"
120
+ type "location", "8006 Zuerich"
121
+ type "emails", "testywesee.com"
122
+ type "phone", "043 540 0549"
123
+
124
+ click "update"
125
+ wait_for_page_to_load "30000"
126
+
127
+ assert_equal "YDIM", get_title
128
+ assert is_text_present("Die angegebene Email-Adresse ist ungültig.")
129
+ assert is_text_present("Die angegebene Telefonnummer ist ungültig.")
130
+ assert !is_text_present('Bitte geben Sie das Feld "Kundenart" an.')
131
+ assert !is_text_present('Bitte geben Sie das Feld "Firma" an.')
132
+ assert !is_text_present('Bitte geben Sie das Feld "Name" an.')
133
+ assert !is_text_present('Bitte geben Sie das Feld "PLZ/Ort" an.')
134
+ assert !is_text_present('Bitte geben Sie das Feld "Email (max. 3)" an.')
135
+ assert !is_element_present("create_invoice")
136
+ assert !is_element_present("create_autoinvoice")
137
+
138
+ assert_equal "Apotheke", get_selected_label("debitor_type")
139
+ assert_equal "Company", get_value("name")
140
+ assert_equal "Herr", get_selected_label("salutation")
141
+ assert_equal "Contact", get_value("contact")
142
+ assert_equal "Firstname", get_value("contact_firstname")
143
+ assert_equal "Dr.", get_value("contact_title")
144
+ assert_equal "Street 45", get_value("address_lines")
145
+ assert_equal "8006 Zuerich", get_value("location")
146
+ assert_equal "testywesee.com", get_value("emails")
147
+ assert_equal "043 540 0549", get_value("phone")
148
+ end
149
+ def test_create_debitor__succeed
150
+ session = login
151
+ assert_equal "YDIM", get_title
152
+ click "create_debitor"
153
+ wait_for_page_to_load "30000"
154
+ assert_equal "YDIM", get_title
155
+
156
+ select "debitor_type", "Apotheke"
157
+ type "name", "Company"
158
+ select "salutation", "Herr"
159
+ type "contact", "Contact"
160
+ type "contact_firstname", "Firstname"
161
+ type "contact_title", "Dr."
162
+ type "address_lines", "Street 45"
163
+ type "location", "8006 Zuerich"
164
+ type "emails", "test@ywesee.com, test2@ywesee.com"
165
+ type "phone", "0041 43 540 0549"
166
+
167
+ debitor = OpenStruct.new
168
+ debitor.unique_id = 1
169
+ session.should_receive(:create_debitor).and_return(debitor)
170
+ click "update"
171
+ wait_for_page_to_load "30000"
172
+
173
+ assert_equal('dt_pharmacy', debitor.debitor_type)
174
+ assert_equal('Company', debitor.name)
175
+ assert_equal('Herr', debitor.salutation)
176
+ assert_equal('Contact', debitor.contact)
177
+ assert_equal('Firstname', debitor.contact_firstname)
178
+ assert_equal('Dr.', debitor.contact_title)
179
+ assert_equal(['Street 45'], debitor.address_lines)
180
+ assert_equal('8006 Zuerich', debitor.location)
181
+ ## test-class is an OpenStruct, which is why these values are
182
+ # not separated into @email and @emails_cc
183
+ assert_equal(['test@ywesee.com', 'test2@ywesee.com'], debitor.emails)
184
+ assert_equal('0041 43 540 0549', debitor.phone)
185
+
186
+ assert_equal "YDIM", get_title
187
+ assert !is_text_present('Bitte geben Sie das Feld "Kundenart" an.')
188
+ assert !is_text_present('Bitte geben Sie das Feld "Firma" an.')
189
+ assert !is_text_present('Bitte geben Sie das Feld "Name" an.')
190
+ assert !is_text_present('Bitte geben Sie das Feld "PLZ/Ort" an.')
191
+ assert !is_text_present('Bitte geben Sie das Feld "Email (max. 3)" an.')
192
+ assert is_element_present("create_invoice")
193
+ assert is_element_present("create_autoinvoice")
194
+
195
+ assert_equal "Apotheke", get_selected_label("debitor_type")
196
+ assert_equal "Company", get_value("name")
197
+ assert_equal "Herr", get_selected_label("salutation")
198
+ assert_equal "Contact", get_value("contact")
199
+ assert_equal "Firstname", get_value("contact_firstname")
200
+ assert_equal "Dr.", get_value("contact_title")
201
+ assert_equal "Street 45", get_value("address_lines")
202
+ assert_equal "8006 Zuerich", get_value("location")
203
+ assert_equal "test@ywesee.com, test2@ywesee.com", get_value("emails")
204
+ assert_equal "0041 43 540 0549", get_value("phone")
205
+ end
206
+ def test_generate
207
+ debitor = YDIM::Debitor.new(1)
208
+ debitor.name = 'Foo'
209
+ debitor.email = 'debitor@ywesee.com'
210
+ debitor.phone = '0041435400549'
211
+ debitor.debitor_type = 'dt_pharmacy'
212
+ invoice = YDIM::AutoInvoice.new(10001)
213
+ invoice.debitor = debitor
214
+ invoice.description = 'AutoInvoice'
215
+ flexstub(invoice).should_receive(:odba_store)
216
+ item = YDIM::Item.new(:text => 'Item', :price => '100',
217
+ :quantity => 5)
218
+ invoice.add_item(item)
219
+
220
+ session = login([debitor])
221
+ assert_equal "YDIM", get_title
222
+ session.should_receive(:debitor).and_return(debitor)
223
+ session.should_receive(:autoinvoice).and_return(invoice)
224
+ session.should_receive(:generate_invoice).and_return(invoice)
225
+ session.should_ignore_missing
226
+ click "link=Foo"
227
+ wait_for_page_to_load "30000"
228
+ assert_equal "YDIM", get_title
229
+
230
+ click "link=Generieren"
231
+ wait_for_page_to_load "30000"
232
+ assert_equal "YDIM", get_title
233
+ assert is_element_present("update")
234
+ assert is_element_present("create_item")
235
+ assert is_element_present("pdf")
236
+ assert is_element_present("send_invoice")
237
+ assert !is_element_present("generate_invoice")
238
+ end
239
+ def test_delete_autoinvoice
240
+ debitor = YDIM::Debitor.new(1)
241
+ debitor.name = 'Foo'
242
+ debitor.email = 'debitor@ywesee.com'
243
+ debitor.phone = '0041435400549'
244
+ debitor.debitor_type = 'dt_pharmacy'
245
+ invoice = YDIM::AutoInvoice.new(10001)
246
+ invoice.debitor = debitor
247
+ invoice.description = 'AutoInvoice'
248
+ flexstub(invoice).should_receive(:odba_store)
249
+ item = YDIM::Item.new(:text => 'Item', :price => '100',
250
+ :quantity => 5)
251
+ invoice.add_item(item)
252
+
253
+ session = login([debitor])
254
+ assert_equal "YDIM", get_title
255
+ session.should_receive(:debitor).and_return(debitor)
256
+ session.should_receive(:autoinvoice).and_return(invoice)
257
+ session.should_receive(:generate_invoice).and_return(invoice)
258
+ session.should_ignore_missing
259
+ click "link=Foo"
260
+ wait_for_page_to_load "30000"
261
+ assert_equal "YDIM", get_title
262
+ assert is_text_present("AutoInvoice")
263
+
264
+ session.should_receive(:delete_autoinvoice).with(10001).and_return {
265
+ debitor.delete_autoinvoice(invoice)
266
+ }
267
+ click "link=Löschen"
268
+ wait_for_condition "!selenium.isTextPresent('AutoInvoice')", "10000"
269
+ assert_equal "YDIM", get_title
270
+ assert !is_text_present("AutoInvoice")
271
+ end
272
+ def test_invoices
273
+ debitor = YDIM::Debitor.new(1)
274
+ debitor.name = 'Foo'
275
+ debitor.email = 'debitor@ywesee.com'
276
+ debitor.phone = '0041435400549'
277
+ debitor.debitor_type = 'dt_pharmacy'
278
+ invoice = YDIM::Invoice.new(10001)
279
+ invoice.debitor = debitor
280
+ invoice.description = 'Invoice'
281
+ flexstub(invoice).should_receive(:odba_store)
282
+ item = YDIM::Item.new(:text => 'Item', :price => '100',
283
+ :quantity => 5)
284
+ invoice.add_item(item)
285
+
286
+ session = login([debitor])
287
+ assert_equal "YDIM", get_title
288
+ session.should_receive(:debitor).and_return(debitor)
289
+ session.should_receive(:invoice).and_return(invoice)
290
+ click "link=Foo"
291
+ wait_for_page_to_load "30000"
292
+ assert_equal "YDIM", get_title
293
+ assert is_text_present("Invoice")
294
+
295
+ click "link=offen"
296
+ wait_for_condition "!selenium.isTextPresent('Invoice')", "10000"
297
+ assert_equal "YDIM", get_title
298
+ assert !is_text_present("Invoice")
299
+
300
+ click "link=Bezahlte Rechnungen"
301
+ wait_for_condition "selenium.isTextPresent('Invoice')", "10000"
302
+ assert is_text_present("Invoice")
303
+ end
304
+ def test_invoices__collect_garbage
305
+ debitor = YDIM::Debitor.new(1)
306
+ debitor.name = 'Foo'
307
+ debitor.email = 'debitor@ywesee.com'
308
+ debitor.phone = '0041435400549'
309
+ debitor.debitor_type = 'dt_pharmacy'
310
+ invoice = YDIM::Invoice.new(10001)
311
+ invoice.debitor = debitor
312
+ invoice.description = 'Invoice'
313
+ flexstub(invoice).should_receive(:odba_store)
314
+ item = YDIM::Item.new(:text => 'Item', :price => '100',
315
+ :quantity => 5)
316
+ invoice.add_item(item)
317
+
318
+ session = login([debitor])
319
+ assert_equal "YDIM", get_title
320
+ session.should_receive(:debitor).and_return(debitor)
321
+ session.should_receive(:invoice).and_return(invoice)
322
+ click "link=Foo"
323
+ wait_for_page_to_load "30000"
324
+ assert_equal "YDIM", get_title
325
+ assert is_text_present("Invoice")
326
+
327
+ click "link=löschen"
328
+ wait_for_condition "!selenium.isTextPresent('Invoice')", "10000"
329
+ assert_equal "YDIM", get_title
330
+ assert !is_text_present("Invoice")
331
+
332
+ click "link=Papierkorb"
333
+ wait_for_condition "selenium.isTextPresent('Invoice')", "10000"
334
+ assert is_text_present("Invoice")
335
+
336
+ session.should_receive(:collect_garbage)
337
+ click "collect_garbage"
338
+ wait_for_condition "!selenium.isTextPresent('Invoice')", "10000"
339
+ assert !is_text_present("Invoice")
340
+ end
341
+ end
342
+ end
343
+ end
344
+ end