ydim_html 1.0.0

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