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