ydim_html 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/LICENSE.txt +339 -0
- data/Manifest.txt +47 -0
- data/README.txt +21 -0
- data/Rakefile +28 -0
- data/bin/ydim-htmld +38 -0
- data/lib/ydim/html.rb +10 -0
- data/lib/ydim/html/config.rb +37 -0
- data/lib/ydim/html/state/ajax_values.rb +16 -0
- data/lib/ydim/html/state/autoinvoice.rb +93 -0
- data/lib/ydim/html/state/confirm.rb +15 -0
- data/lib/ydim/html/state/debitor.rb +81 -0
- data/lib/ydim/html/state/debitors.rb +23 -0
- data/lib/ydim/html/state/global.rb +99 -0
- data/lib/ydim/html/state/global_predefine.rb +13 -0
- data/lib/ydim/html/state/init.rb +20 -0
- data/lib/ydim/html/state/invoice.rb +179 -0
- data/lib/ydim/html/state/invoices.rb +69 -0
- data/lib/ydim/html/state/pdf.rb +16 -0
- data/lib/ydim/html/util/lookandfeel.rb +132 -0
- data/lib/ydim/html/util/server.rb +36 -0
- data/lib/ydim/html/util/session.rb +27 -0
- data/lib/ydim/html/util/validator.rb +62 -0
- data/lib/ydim/html/view/ajax_values.rb +22 -0
- data/lib/ydim/html/view/autoinvoice.rb +79 -0
- data/lib/ydim/html/view/autoinvoices.rb +41 -0
- data/lib/ydim/html/view/confirm.rb +27 -0
- data/lib/ydim/html/view/debitor.rb +111 -0
- data/lib/ydim/html/view/debitors.rb +44 -0
- data/lib/ydim/html/view/htmlgrid.rb +103 -0
- data/lib/ydim/html/view/init.rb +29 -0
- data/lib/ydim/html/view/invoice.rb +217 -0
- data/lib/ydim/html/view/invoices.rb +158 -0
- data/lib/ydim/html/view/navigation.rb +28 -0
- data/lib/ydim/html/view/pdf.rb +23 -0
- data/lib/ydim/html/view/template.rb +70 -0
- data/test/selenium.rb +1687 -0
- data/test/selenium/selenium-server.jar +0 -0
- data/test/selenium/test_autoinvoice.rb +318 -0
- data/test/selenium/test_debitor.rb +343 -0
- data/test/selenium/test_debitors.rb +46 -0
- data/test/selenium/test_init.rb +104 -0
- data/test/selenium/test_invoice.rb +295 -0
- data/test/selenium/test_invoices.rb +175 -0
- data/test/selenium/unit.rb +124 -0
- data/test/stub/http_server.rb +139 -0
- data/test/suite.rb +14 -0
- metadata +138 -0
@@ -0,0 +1,46 @@
|
|
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 'selenium/unit'
|
7
|
+
require 'ydim/debitor'
|
8
|
+
|
9
|
+
module YDIM
|
10
|
+
module Html
|
11
|
+
module Selenium
|
12
|
+
class TestDebitors < Test::Unit::TestCase
|
13
|
+
include Selenium::TestCase
|
14
|
+
def test_debitors
|
15
|
+
## new: sorted by debitor-type
|
16
|
+
debitor1 = YDIM::Debitor.new(1)
|
17
|
+
debitor1.name = 'Foo'
|
18
|
+
debitor1.email = 'debitor@ywesee.com'
|
19
|
+
debitor1.phone = '0041435400549'
|
20
|
+
debitor1.debitor_type = 'dt_pharmacy'
|
21
|
+
debitor2 = YDIM::Debitor.new(2)
|
22
|
+
debitor2.name = 'Bar'
|
23
|
+
debitor2.debitor_type = 'dt_consulting'
|
24
|
+
flexstub(debitor2).should_receive(:next_invoice_date).and_return(Date.today)
|
25
|
+
session = login([debitor1, debitor2])
|
26
|
+
assert_equal "YDIM", @selenium.get_title
|
27
|
+
assert_equal "1", @selenium.get_text("//tr[2]/td[1]")
|
28
|
+
assert_equal "Foo", @selenium.get_text("//tr[2]/td[2]")
|
29
|
+
assert_equal "debitor@ywesee.com",
|
30
|
+
@selenium.get_text("//tr[2]/td[3]")
|
31
|
+
assert_equal "0041435400549",
|
32
|
+
@selenium.get_text("//tr[2]/td[4]")
|
33
|
+
assert_equal "Apotheke", @selenium.get_text("//tr[2]/td[6]")
|
34
|
+
assert_equal "2", @selenium.get_text("//tr[3]/td[1]")
|
35
|
+
assert_equal "Bar", @selenium.get_text("//tr[3]/td[2]")
|
36
|
+
assert_equal "Beratung", @selenium.get_text("//tr[3]/td[6]")
|
37
|
+
|
38
|
+
@selenium.click "link=ID"
|
39
|
+
@selenium.wait_for_page_to_load "30000"
|
40
|
+
assert_equal "1", @selenium.get_text("//tr[2]/td[1]")
|
41
|
+
assert_equal "2", @selenium.get_text("//tr[3]/td[1]")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Selenium::TestInit -- ydim -- 14.12.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('..', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require 'selenium/unit'
|
7
|
+
|
8
|
+
module YDIM
|
9
|
+
module Html
|
10
|
+
module Selenium
|
11
|
+
class TestInit < Test::Unit::TestCase
|
12
|
+
include Selenium::TestCase
|
13
|
+
def test_init
|
14
|
+
open "/"
|
15
|
+
assert_equal "YDIM", get_title
|
16
|
+
assert is_element_present("email")
|
17
|
+
assert is_element_present("pass")
|
18
|
+
assert is_element_present("login")
|
19
|
+
assert_equal('Email', get_text("//label[@for='email']"))
|
20
|
+
assert_equal('Passwort', get_text("//label[@for='pass']"))
|
21
|
+
end
|
22
|
+
def test_login__fail__empty
|
23
|
+
open "/"
|
24
|
+
assert_equal "YDIM", get_title
|
25
|
+
#type "email", "unknown@ywesee.com"
|
26
|
+
#type "pass", "wrong"
|
27
|
+
click "login"
|
28
|
+
wait_for_page_to_load "30000"
|
29
|
+
assert_equal "YDIM", get_title
|
30
|
+
assert is_element_present("email")
|
31
|
+
assert is_element_present("pass")
|
32
|
+
assert is_element_present("login")
|
33
|
+
assert_equal('Email', get_text("//label[@for='email']"))
|
34
|
+
assert_equal('Passwort', get_text("//label[@for='pass']"))
|
35
|
+
end
|
36
|
+
def test_login__fail__both
|
37
|
+
open "/"
|
38
|
+
assert_equal "YDIM", get_title
|
39
|
+
type "email", "unknown@ywesee.com"
|
40
|
+
type "pass", "incorrect"
|
41
|
+
click "login"
|
42
|
+
wait_for_page_to_load "30000"
|
43
|
+
assert_equal "YDIM", get_title
|
44
|
+
assert is_element_present("email")
|
45
|
+
assert is_element_present("pass")
|
46
|
+
assert is_element_present("login")
|
47
|
+
assert_equal('Email', get_text("//label[@for='email']"))
|
48
|
+
assert_equal('Passwort', get_text("//label[@for='pass']"))
|
49
|
+
end
|
50
|
+
def test_login__fail__email
|
51
|
+
open "/"
|
52
|
+
assert_equal "YDIM", get_title
|
53
|
+
type "email", "unknown@ywesee.com"
|
54
|
+
type "pass", "secret"
|
55
|
+
click "login"
|
56
|
+
wait_for_page_to_load "30000"
|
57
|
+
assert_equal "YDIM", get_title
|
58
|
+
assert is_element_present("email")
|
59
|
+
assert is_element_present("pass")
|
60
|
+
assert is_element_present("login")
|
61
|
+
assert_equal('Email', get_text("//label[@for='email']"))
|
62
|
+
assert_equal('Passwort', get_text("//label[@for='pass']"))
|
63
|
+
end
|
64
|
+
def test_login__fail__pass
|
65
|
+
open "/"
|
66
|
+
assert_equal "YDIM", get_title
|
67
|
+
type "email", "test@ywesee.com"
|
68
|
+
type "pass", "incorrect"
|
69
|
+
click "login"
|
70
|
+
wait_for_page_to_load "30000"
|
71
|
+
assert_equal "YDIM", get_title
|
72
|
+
assert is_element_present("email")
|
73
|
+
assert is_element_present("pass")
|
74
|
+
assert is_element_present("login")
|
75
|
+
assert_equal('Email', get_text("//label[@for='email']"))
|
76
|
+
assert_equal('Passwort', get_text("//label[@for='pass']"))
|
77
|
+
end
|
78
|
+
def test_login__success
|
79
|
+
login
|
80
|
+
assert_equal "YDIM", get_title
|
81
|
+
assert !is_element_present("email")
|
82
|
+
assert !is_element_present("pass")
|
83
|
+
assert !is_element_present("login")
|
84
|
+
assert is_element_present("logout")
|
85
|
+
end
|
86
|
+
def test_logout
|
87
|
+
login
|
88
|
+
assert_equal "YDIM", get_title
|
89
|
+
assert !is_element_present("email")
|
90
|
+
assert !is_element_present("pass")
|
91
|
+
assert !is_element_present("login")
|
92
|
+
assert is_element_present("logout")
|
93
|
+
|
94
|
+
click "logout"
|
95
|
+
wait_for_page_to_load "30000"
|
96
|
+
assert is_element_present("email")
|
97
|
+
assert is_element_present("pass")
|
98
|
+
assert is_element_present("login")
|
99
|
+
assert !is_element_present("logout")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,295 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Html::Selenium::TestInvoice -- ydim -- 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 TestInvoice < Test::Unit::TestCase
|
15
|
+
include Selenium::TestCase
|
16
|
+
def setup_debitor
|
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
|
+
debitor
|
23
|
+
end
|
24
|
+
def test_create_invoice
|
25
|
+
debitor = setup_debitor
|
26
|
+
session = login([debitor])
|
27
|
+
session.should_receive(:debitor).and_return(debitor)
|
28
|
+
assert_equal "YDIM", get_title
|
29
|
+
click "link=Foo"
|
30
|
+
wait_for_page_to_load "30000"
|
31
|
+
assert_equal "YDIM", get_title
|
32
|
+
|
33
|
+
click "create_invoice"
|
34
|
+
wait_for_page_to_load "30000"
|
35
|
+
assert_equal "YDIM", get_title
|
36
|
+
assert_equal "ID", get_text("//label[@for='unique_id']")
|
37
|
+
|
38
|
+
url = "http://localhost:10080/de/debitor/unique_id/1"
|
39
|
+
assert_equal url, get_attribute("//a[@name='name']@href")
|
40
|
+
assert_equal url, get_attribute("//a[@name='email']@href")
|
41
|
+
assert_equal "Foo", get_text("//a[@name='name']")
|
42
|
+
assert_equal "debitor@ywesee.com", get_text("//a[@name='email']")
|
43
|
+
|
44
|
+
assert is_element_present("//input[@name='description']")
|
45
|
+
assert_equal "text",
|
46
|
+
get_attribute("//input[@name='description']@type")
|
47
|
+
assert_equal "Beschreibung", get_text("//label[@for='description']")
|
48
|
+
|
49
|
+
assert is_element_present("//input[@name='date']")
|
50
|
+
assert_equal "text", get_attribute("//input[@name='date']@type")
|
51
|
+
assert_equal "Rechnungsdatum", get_text("//label[@for='date']")
|
52
|
+
assert_equal Date.today.strftime('%d.%m.%Y'),
|
53
|
+
get_value("//input[@name='date']")
|
54
|
+
|
55
|
+
assert is_element_present("//select[@name='currency']")
|
56
|
+
assert_equal "Währung", get_text("//label[@for='currency']")
|
57
|
+
|
58
|
+
assert is_element_present("//input[@name='precision']")
|
59
|
+
assert_equal "text", get_attribute("//input[@name='precision']@type")
|
60
|
+
assert_equal "Kommastellen", get_text("//label[@for='precision']")
|
61
|
+
assert_equal "2", get_value("//input[@name='precision']")
|
62
|
+
|
63
|
+
assert is_element_present("update")
|
64
|
+
assert !is_element_present("create_item")
|
65
|
+
assert !is_element_present("pdf")
|
66
|
+
assert !is_element_present("send_invoice")
|
67
|
+
end
|
68
|
+
def test_create_invoice__fail
|
69
|
+
debitor = setup_debitor
|
70
|
+
session = login([debitor])
|
71
|
+
session.should_receive(:debitor).and_return(debitor)
|
72
|
+
assert_equal "YDIM", get_title
|
73
|
+
click "link=Foo"
|
74
|
+
wait_for_page_to_load "30000"
|
75
|
+
assert_equal "YDIM", get_title
|
76
|
+
|
77
|
+
click "create_invoice"
|
78
|
+
wait_for_page_to_load "30000"
|
79
|
+
assert_equal "YDIM", get_title
|
80
|
+
|
81
|
+
click "update"
|
82
|
+
wait_for_page_to_load "30000"
|
83
|
+
|
84
|
+
assert is_text_present('Bitte geben Sie das Feld "Beschreibung" an.')
|
85
|
+
assert is_element_present("update")
|
86
|
+
assert !is_element_present("create_item")
|
87
|
+
assert !is_element_present("pdf")
|
88
|
+
assert !is_element_present("send_invoice")
|
89
|
+
end
|
90
|
+
def test_create_invoice__succeed
|
91
|
+
debitor = setup_debitor
|
92
|
+
session = login([debitor])
|
93
|
+
session.should_receive(:debitor).and_return(debitor)
|
94
|
+
assert_equal "YDIM", get_title
|
95
|
+
click "link=Foo"
|
96
|
+
wait_for_page_to_load "30000"
|
97
|
+
assert_equal "YDIM", get_title
|
98
|
+
|
99
|
+
click "create_invoice"
|
100
|
+
wait_for_page_to_load "30000"
|
101
|
+
assert_equal "YDIM", get_title
|
102
|
+
|
103
|
+
type "description", "Newly created Invoice"
|
104
|
+
|
105
|
+
invoice = nil
|
106
|
+
session.should_receive(:create_invoice).and_return {
|
107
|
+
invoice = Invoice.new(10001)
|
108
|
+
invoice.debitor = debitor
|
109
|
+
flexstub(invoice).should_receive(:odba_store)
|
110
|
+
invoice
|
111
|
+
}
|
112
|
+
|
113
|
+
click "update"
|
114
|
+
wait_for_page_to_load "30000"
|
115
|
+
|
116
|
+
assert_equal("Newly created Invoice", invoice.description)
|
117
|
+
assert_equal(Date.today, invoice.date)
|
118
|
+
assert_equal("CHF", invoice.currency)
|
119
|
+
assert_equal(2, invoice.precision)
|
120
|
+
|
121
|
+
assert !is_text_present('Bitte geben Sie das Feld "Beschreibung" an.')
|
122
|
+
assert is_element_present("update")
|
123
|
+
assert is_element_present("create_item")
|
124
|
+
assert !is_element_present("pdf")
|
125
|
+
assert !is_element_present("send_invoice")
|
126
|
+
|
127
|
+
assert_equal "Newly created Invoice",
|
128
|
+
get_value("//input[@name='description']")
|
129
|
+
|
130
|
+
item = nil
|
131
|
+
session.should_receive(:add_items).and_return { |invoice_id, items, invoice_key|
|
132
|
+
assert_equal(10001, invoice_id)
|
133
|
+
assert_equal(:invoice, invoice_key)
|
134
|
+
assert_equal(1, items.size)
|
135
|
+
hash = items.first
|
136
|
+
assert_instance_of(Hash, hash)
|
137
|
+
assert_equal(1, hash.size)
|
138
|
+
assert_instance_of(Time, hash[:time])
|
139
|
+
item = YDIM::Item.new(hash)
|
140
|
+
item.index = 0
|
141
|
+
invoice.items.push(item)
|
142
|
+
item
|
143
|
+
}
|
144
|
+
click "create_item"
|
145
|
+
## waitForElementPresent:
|
146
|
+
assert !60.times {
|
147
|
+
break if (is_element_present("text[0]") rescue false)
|
148
|
+
sleep 1
|
149
|
+
}
|
150
|
+
assert is_element_present("quantity[0]")
|
151
|
+
assert is_element_present("unit[0]")
|
152
|
+
assert is_element_present("price[0]")
|
153
|
+
assert_equal "0.00", get_text("total_netto0")
|
154
|
+
|
155
|
+
assert is_element_present("update")
|
156
|
+
assert is_element_present("create_item")
|
157
|
+
assert !is_element_present("pdf")
|
158
|
+
assert !is_element_present("send_invoice")
|
159
|
+
|
160
|
+
session.should_receive(:update_item).and_return { |invoice_id, item_index, data, invoice_key|
|
161
|
+
assert_equal(10001, invoice_id)
|
162
|
+
assert_equal(0, item_index)
|
163
|
+
assert_equal(:invoice, invoice_key)
|
164
|
+
data.each { |key, val|
|
165
|
+
item.send("#{key}=", val)
|
166
|
+
}
|
167
|
+
item
|
168
|
+
}
|
169
|
+
|
170
|
+
type "text[0]", "Item 1"
|
171
|
+
type "quantity[0]", "2"
|
172
|
+
type "unit[0]", "pieces"
|
173
|
+
type "price[0]", "3.25"
|
174
|
+
sleep 0.1
|
175
|
+
assert_equal "6.50", get_text("total_netto0")
|
176
|
+
|
177
|
+
assert is_element_present("update")
|
178
|
+
assert is_element_present("create_item")
|
179
|
+
assert !is_element_present("pdf")
|
180
|
+
assert !is_element_present("send_invoice")
|
181
|
+
|
182
|
+
click "update"
|
183
|
+
wait_for_page_to_load "30000"
|
184
|
+
|
185
|
+
assert is_text_present("Total Netto")
|
186
|
+
assert is_text_present("MwSt. (7.6%)")
|
187
|
+
assert is_text_present("Total Brutto")
|
188
|
+
|
189
|
+
assert is_element_present("update")
|
190
|
+
assert is_element_present("create_item")
|
191
|
+
assert is_element_present("pdf")
|
192
|
+
assert is_element_present("send_invoice")
|
193
|
+
|
194
|
+
click "link=debitor@ywesee.com"
|
195
|
+
wait_for_page_to_load "30000"
|
196
|
+
assert is_text_present("Newly created Invoice")
|
197
|
+
end
|
198
|
+
def test_delete_item
|
199
|
+
debitor = setup_debitor
|
200
|
+
session = login([debitor])
|
201
|
+
session.should_receive(:debitor).and_return(debitor)
|
202
|
+
invoice = YDIM::Invoice.new(10001)
|
203
|
+
invoice.debitor = debitor
|
204
|
+
item = YDIM::Item.new(:text => 'Item', :price => '100',
|
205
|
+
:quantity => 5)
|
206
|
+
invoice.add_item(item)
|
207
|
+
session.should_receive(:invoice).and_return(invoice)
|
208
|
+
|
209
|
+
assert_equal "YDIM", get_title
|
210
|
+
click "link=Foo"
|
211
|
+
wait_for_page_to_load "30000"
|
212
|
+
assert_equal "YDIM", get_title
|
213
|
+
|
214
|
+
click "link=10001"
|
215
|
+
wait_for_page_to_load "30000"
|
216
|
+
assert_equal "YDIM", get_title
|
217
|
+
assert is_element_present('text[0]')
|
218
|
+
assert_equal "Item", get_value('text[0]')
|
219
|
+
|
220
|
+
session.should_receive(:delete_item).with(10001, 0, :invoice).and_return {
|
221
|
+
invoice.items.delete(item)
|
222
|
+
}
|
223
|
+
|
224
|
+
click "link=Löschen"
|
225
|
+
wait_for_condition "!selenium.isElementPresent('text[0]')", "10000"
|
226
|
+
assert !is_element_present('text[0]')
|
227
|
+
end
|
228
|
+
def test_currency
|
229
|
+
debitor = setup_debitor
|
230
|
+
session = login([debitor])
|
231
|
+
session.should_receive(:debitor).and_return(debitor)
|
232
|
+
invoice = YDIM::Invoice.new(10001)
|
233
|
+
invoice.debitor = debitor
|
234
|
+
invoice.currency = 'CHF'
|
235
|
+
flexstub(invoice).should_receive(:odba_store)
|
236
|
+
item = YDIM::Item.new(:text => 'Item', :price => '100',
|
237
|
+
:quantity => 5)
|
238
|
+
invoice.add_item(item)
|
239
|
+
session.should_receive(:invoice).and_return(invoice)
|
240
|
+
|
241
|
+
assert_equal "YDIM", get_title
|
242
|
+
click "link=Foo"
|
243
|
+
wait_for_page_to_load "30000"
|
244
|
+
assert_equal "YDIM", get_title
|
245
|
+
|
246
|
+
click "link=10001"
|
247
|
+
wait_for_page_to_load "30000"
|
248
|
+
assert_equal "YDIM", get_title
|
249
|
+
assert is_element_present('text[0]')
|
250
|
+
assert_equal "Item", get_value('text[0]')
|
251
|
+
|
252
|
+
session.should_receive(:update_item).and_return {
|
253
|
+
item.price = 66
|
254
|
+
}
|
255
|
+
|
256
|
+
select "currency", "label=EUR"
|
257
|
+
wait_for_condition "!selenium.isTextPresent('500.00')", "10000"
|
258
|
+
assert is_text_present('330.00')
|
259
|
+
end
|
260
|
+
def test_mail
|
261
|
+
debitor = setup_debitor
|
262
|
+
session = login([debitor])
|
263
|
+
session.should_receive(:debitor).and_return(debitor)
|
264
|
+
invoice = YDIM::Invoice.new(10001)
|
265
|
+
invoice.debitor = debitor
|
266
|
+
invoice.currency = 'CHF'
|
267
|
+
flexstub(invoice).should_receive(:odba_store)
|
268
|
+
item = YDIM::Item.new(:text => 'Item', :price => '100',
|
269
|
+
:quantity => 5)
|
270
|
+
invoice.add_item(item)
|
271
|
+
session.should_receive(:invoice).and_return(invoice)
|
272
|
+
|
273
|
+
assert_equal "YDIM", get_title
|
274
|
+
click "link=Foo"
|
275
|
+
wait_for_page_to_load "30000"
|
276
|
+
assert_equal "YDIM", get_title
|
277
|
+
|
278
|
+
click "link=10001"
|
279
|
+
wait_for_page_to_load "30000"
|
280
|
+
assert_equal "YDIM", get_title
|
281
|
+
assert is_element_present('send_invoice')
|
282
|
+
|
283
|
+
session.should_receive(:update_item)
|
284
|
+
session.should_receive(:send_invoice).times(1).and_return {
|
285
|
+
['customer@ywesee.com', 'admin@ywesee.com']
|
286
|
+
}
|
287
|
+
click "send_invoice"
|
288
|
+
wait_for_page_to_load "30000"
|
289
|
+
assert is_text_present("Die Rechnung wurde an folgende Email-Adressen verschickt: customer@ywesee.com, admin@ywesee.com")
|
290
|
+
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Html::Selenium::TestInvoices -- ydim -- 15.12.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('..', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require 'ostruct'
|
7
|
+
require 'selenium/unit'
|
8
|
+
|
9
|
+
module YDIM
|
10
|
+
module Html
|
11
|
+
module Selenium
|
12
|
+
class TestInvoices < Test::Unit::TestCase
|
13
|
+
include Selenium::TestCase
|
14
|
+
def setup_info(id, payment, status, deleted)
|
15
|
+
info = OpenStruct.new
|
16
|
+
info.unique_id = id
|
17
|
+
info.debitor_name = 'Customer, longer than 30 Characters'
|
18
|
+
info.debitor_email = 'test@ywesee.com'
|
19
|
+
info.description = "Invoice #{id}, #{status}"
|
20
|
+
info.date = Date.today
|
21
|
+
info.payment_received = payment
|
22
|
+
info.total_netto = 100
|
23
|
+
info.total_brutto = 107.6
|
24
|
+
info.currency = 'CHF'
|
25
|
+
info.status = status
|
26
|
+
info.deleted = deleted
|
27
|
+
info.odba_store = true
|
28
|
+
info
|
29
|
+
end
|
30
|
+
def test_invoices
|
31
|
+
session = login([])
|
32
|
+
info1 = setup_info(1, false, 'is_open', false)
|
33
|
+
info2 = setup_info(2, false, 'is_due', false)
|
34
|
+
info3 = setup_info(3, true, 'is_paid', false)
|
35
|
+
info4 = setup_info(4, false, 'is_trash', true)
|
36
|
+
infos = [info1, info2, info3, info4]
|
37
|
+
session.should_receive(:invoice_infos).and_return { |status|
|
38
|
+
infos.select { |info| info.status == status }
|
39
|
+
}
|
40
|
+
assert_equal "YDIM", get_title
|
41
|
+
click "link=Rechnungen"
|
42
|
+
wait_for_page_to_load "30000"
|
43
|
+
assert_equal "YDIM", get_title
|
44
|
+
assert_equal "is_open", get_attribute("//tr[2]@class")
|
45
|
+
assert is_text_present("Invoice 1, is_open")
|
46
|
+
assert is_text_present('Customer, longer than 30 Ch...')
|
47
|
+
assert is_text_present("Invoice 2, is_due")
|
48
|
+
assert !is_text_present("Invoice 3, is_paid")
|
49
|
+
assert !is_text_present("Invoice 4, is_trash")
|
50
|
+
|
51
|
+
click "link=Fällige Rechnungen"
|
52
|
+
wait_for_condition "selenium.isTextPresent('Invoice 2')", "10000"
|
53
|
+
assert_equal "is_due", get_attribute("//tr[2]@class")
|
54
|
+
assert !is_text_present("Invoice 1, is_open")
|
55
|
+
assert is_text_present("Invoice 2, is_due")
|
56
|
+
assert !is_text_present("Invoice 3, is_paid")
|
57
|
+
assert !is_text_present("Invoice 4, is_trash")
|
58
|
+
|
59
|
+
click "link=Bezahlte Rechnungen"
|
60
|
+
wait_for_condition "selenium.isTextPresent('Invoice 3')", "10000"
|
61
|
+
assert_equal "is_paid", get_attribute("//tr[2]@class")
|
62
|
+
assert !is_text_present("Invoice 1, is_open")
|
63
|
+
assert !is_text_present("Invoice 2, is_due")
|
64
|
+
assert is_text_present("Invoice 3, is_paid")
|
65
|
+
assert !is_text_present("Invoice 4, is_trash")
|
66
|
+
|
67
|
+
click "link=Papierkorb"
|
68
|
+
wait_for_condition "selenium.isTextPresent('Invoice 4')", "10000"
|
69
|
+
assert_equal "is_trash", get_attribute("//tr[2]@class")
|
70
|
+
assert !is_text_present("Invoice 1, is_open")
|
71
|
+
assert !is_text_present("Invoice 2, is_due")
|
72
|
+
assert !is_text_present("Invoice 3, is_paid")
|
73
|
+
assert is_text_present("Invoice 4, is_trash")
|
74
|
+
|
75
|
+
click "link=Offene Rechnungen"
|
76
|
+
wait_for_condition "selenium.isTextPresent('Invoice 1')", "10000"
|
77
|
+
assert is_text_present("Invoice 1, is_open")
|
78
|
+
end
|
79
|
+
def test_invoices__paid
|
80
|
+
session = login([])
|
81
|
+
info1 = setup_info(1, false, 'is_open', false)
|
82
|
+
session.should_receive(:invoice_infos).and_return { |status|
|
83
|
+
[info1]
|
84
|
+
}
|
85
|
+
assert_equal "YDIM", get_title
|
86
|
+
click "link=Rechnungen"
|
87
|
+
wait_for_page_to_load "30000"
|
88
|
+
assert_equal "YDIM", get_title
|
89
|
+
assert is_text_present("Invoice 1, is_open")
|
90
|
+
|
91
|
+
session.should_receive(:invoice).and_return {
|
92
|
+
info1.status = 'is_paid'
|
93
|
+
info1
|
94
|
+
}
|
95
|
+
click "link=offen"
|
96
|
+
wait_for_condition "!selenium.isTextPresent('Invoice 1')", "10000"
|
97
|
+
assert !is_text_present("Invoice 1, is_open")
|
98
|
+
click "link=Bezahlte Rechnungen"
|
99
|
+
wait_for_condition "selenium.isTextPresent('Invoice 1')", "10000"
|
100
|
+
assert is_text_present("Invoice 1, is_open")
|
101
|
+
end
|
102
|
+
def test_invoices__deleted
|
103
|
+
session = login([])
|
104
|
+
info1 = setup_info(1, false, 'is_open', false)
|
105
|
+
session.should_receive(:invoice_infos).and_return { |status|
|
106
|
+
[info1]
|
107
|
+
}
|
108
|
+
assert_equal "YDIM", get_title
|
109
|
+
click "link=Rechnungen"
|
110
|
+
wait_for_page_to_load "30000"
|
111
|
+
assert_equal "YDIM", get_title
|
112
|
+
assert is_text_present("Invoice 1, is_open")
|
113
|
+
|
114
|
+
session.should_receive(:invoice).and_return {
|
115
|
+
info1.status = 'is_trash'
|
116
|
+
info1
|
117
|
+
}
|
118
|
+
click "link=löschen"
|
119
|
+
wait_for_condition "!selenium.isTextPresent('Invoice 1')", "10000"
|
120
|
+
assert !is_text_present("Invoice 1, is_open")
|
121
|
+
click "link=Papierkorb"
|
122
|
+
wait_for_condition "selenium.isTextPresent('Invoice 1')", "10000"
|
123
|
+
assert is_text_present("Invoice 1, is_open")
|
124
|
+
end
|
125
|
+
def test_invoices__collect_garbage
|
126
|
+
session = login([])
|
127
|
+
info1 = setup_info(1, false, 'is_trash', true)
|
128
|
+
session.should_receive(:invoice_infos).and_return { |status|
|
129
|
+
status == 'is_trash' ? [info1] : []
|
130
|
+
}
|
131
|
+
assert_equal "YDIM", get_title
|
132
|
+
click "link=Rechnungen"
|
133
|
+
wait_for_page_to_load "30000"
|
134
|
+
assert_equal "YDIM", get_title
|
135
|
+
assert !is_text_present("Invoice 1, is_trash")
|
136
|
+
|
137
|
+
click "link=Papierkorb"
|
138
|
+
wait_for_condition "selenium.isTextPresent('Invoice 1')", "10000"
|
139
|
+
assert is_text_present("Invoice 1, is_trash")
|
140
|
+
assert is_element_present("collect_garbage")
|
141
|
+
|
142
|
+
session.should_receive(:collect_garbage).times(1)
|
143
|
+
click "collect_garbage"
|
144
|
+
wait_for_condition "!selenium.isTextPresent('Invoice 1')", "10000"
|
145
|
+
assert !is_text_present("Invoice 1, is_trash")
|
146
|
+
assert !is_element_present("collect_garbage")
|
147
|
+
end
|
148
|
+
def test_invoices__mail
|
149
|
+
session = login([])
|
150
|
+
info1 = setup_info(1, false, 'is_due', false)
|
151
|
+
session.should_receive(:invoice_infos).and_return { |status|
|
152
|
+
status == 'is_due' ? [info1] : []
|
153
|
+
}
|
154
|
+
assert_equal "YDIM", get_title
|
155
|
+
click "link=Rechnungen"
|
156
|
+
wait_for_page_to_load "30000"
|
157
|
+
assert_equal "YDIM", get_title
|
158
|
+
assert is_text_present("Invoice 1, is_due")
|
159
|
+
|
160
|
+
click "link=Fällige Rechnungen"
|
161
|
+
wait_for_condition "selenium.isTextPresent('Invoice 1')", "10000"
|
162
|
+
assert is_text_present("Invoice 1, is_due")
|
163
|
+
assert is_element_present("send_invoice")
|
164
|
+
|
165
|
+
session.should_receive(:send_invoice).times(1).and_return {
|
166
|
+
['customer@ywesee.com', 'admin@ywesee.com']
|
167
|
+
}
|
168
|
+
click "link=Email Senden"
|
169
|
+
wait_for_page_to_load "30000"
|
170
|
+
assert is_text_present("Die Rechnung wurde an folgende Email-Adressen verschickt: customer@ywesee.com, admin@ywesee.com")
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|