sandoz.bbmb.ch 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.travis.yml +26 -0
- data/Gemfile +12 -0
- data/History.txt +6 -0
- data/LICENSE +339 -0
- data/Rakefile +21 -0
- data/doc/index.rbx +14 -0
- data/doc/resources/activex/BbmbBarcodeReader.CAB +0 -0
- data/doc/resources/activex/BbmbBarcodeReader2.CAB +0 -0
- data/doc/resources/bbmb.css +301 -0
- data/doc/resources/errors/appdown.html +14 -0
- data/doc/resources/javascript/bcreader.js +131 -0
- data/doc/resources/javascript/order.js +65 -0
- data/doc/resources/javascript/widget/ContentToggler.js +60 -0
- data/doc/resources/javascript/widget/__package__.js +2 -0
- data/doc/resources/javascript/widget/templates/ContentToggler.html +4 -0
- data/doc/resources/logo.png +0 -0
- data/lib/bbmb/html/util/lookandfeel.rb +202 -0
- data/lib/bbmb/sandoz.rb +4 -0
- data/lib/bbmb/sandoz/html/state/viral/customer.rb +25 -0
- data/lib/bbmb/sandoz/version.rb +5 -0
- data/lib/bbmb/util/csv_importer.rb +123 -0
- data/readme.md +28 -0
- data/sandoz.bbmb.ch.gemspec +45 -0
- data/test/rcov +2 -0
- data/test/selenium.rb +1687 -0
- data/test/selenium/selenium-server.jar +0 -0
- data/test/selenium/test_current_order.rb +336 -0
- data/test/selenium/test_customer.rb +363 -0
- data/test/selenium/test_customers.rb +92 -0
- data/test/selenium/test_favorites.rb +257 -0
- data/test/selenium/test_favorites_result.rb +81 -0
- data/test/selenium/test_history.rb +112 -0
- data/test/selenium/test_login.rb +112 -0
- data/test/selenium/test_orders.rb +111 -0
- data/test/selenium/test_result.rb +157 -0
- data/test/selenium/unit.rb +146 -0
- data/test/stub/http_server.rb +140 -0
- data/test/stub/persistence.rb +58 -0
- data/test/suite.rb +15 -0
- data/test/util/data/Artikel.TXT +50 -0
- data/test/util/data/Kunden.TXT +14 -0
- data/test/util/test_csv_importer.rb +136 -0
- metadata +414 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Selenium::TestCustomers -- bbmb.ch -- 21.09.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('..', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require "selenium/unit"
|
7
|
+
|
8
|
+
module BBMB
|
9
|
+
module Selenium
|
10
|
+
class TestCustomers < Test::Unit::TestCase
|
11
|
+
include Selenium::TestCase
|
12
|
+
def test_customers
|
13
|
+
customer = BBMB::Model::Customer.new('007')
|
14
|
+
customer.organisation = 'Test-Customer'
|
15
|
+
customer.plz = '7777'
|
16
|
+
@persistence.should_receive(:all).and_return { |klass|
|
17
|
+
assert_equal(BBMB::Model::Customer, klass)
|
18
|
+
[customer]
|
19
|
+
}
|
20
|
+
user = login_admin
|
21
|
+
assert @selenium.is_text_present("1 bis 1 von 1")
|
22
|
+
assert_equal "BBMB | Kunden", @selenium.get_title
|
23
|
+
assert @selenium.is_text_present("Kundennr")
|
24
|
+
assert @selenium.is_text_present("007")
|
25
|
+
assert @selenium.is_text_present("PLZ")
|
26
|
+
assert @selenium.is_text_present("7777")
|
27
|
+
assert @selenium.is_text_present("Aktiviert")
|
28
|
+
end
|
29
|
+
def test_customers__filter
|
30
|
+
customer1 = BBMB::Model::Customer.new('007')
|
31
|
+
customer1.organisation = 'Test-Customer'
|
32
|
+
customer1.plz = '7777'
|
33
|
+
customer2 = BBMB::Model::Customer.new('010')
|
34
|
+
customer2.organisation = 'Filter-Customer'
|
35
|
+
customer2.plz = '7778'
|
36
|
+
@persistence.should_receive(:all).and_return { |klass|
|
37
|
+
assert_equal(BBMB::Model::Customer, klass)
|
38
|
+
[customer1, customer2]
|
39
|
+
}
|
40
|
+
user = login_admin
|
41
|
+
assert @selenium.is_text_present("1 bis 2 von 2")
|
42
|
+
assert_equal "BBMB | Kunden", @selenium.get_title
|
43
|
+
assert @selenium.is_text_present("Test-Customer")
|
44
|
+
assert @selenium.is_text_present("Filter-Customer")
|
45
|
+
@selenium.type "//input[@name='filter']", "filter"
|
46
|
+
@selenium.click "filter_button"
|
47
|
+
@selenium.wait_for_page_to_load "30000"
|
48
|
+
assert_equal "BBMB | Kunden", @selenium.get_title
|
49
|
+
assert !@selenium.is_text_present("Test-Customer")
|
50
|
+
assert @selenium.is_text_present("Filter-Customer")
|
51
|
+
end
|
52
|
+
def test_customers__pager
|
53
|
+
BBMB.config.pagestep = 1
|
54
|
+
customer1 = BBMB::Model::Customer.new('007')
|
55
|
+
customer1.organisation = 'Test-Customer 1'
|
56
|
+
customer1.plz = '7777'
|
57
|
+
customer2 = BBMB::Model::Customer.new('010')
|
58
|
+
customer2.organisation = 'Test-Customer 2'
|
59
|
+
customer2.plz = '7777'
|
60
|
+
customer3 = BBMB::Model::Customer.new('011')
|
61
|
+
customer3.organisation = 'Test-Customer 3'
|
62
|
+
customer3.plz = '7777'
|
63
|
+
@persistence.should_receive(:all).and_return { |klass|
|
64
|
+
assert_equal(BBMB::Model::Customer, klass)
|
65
|
+
[customer1, customer2, customer3]
|
66
|
+
}
|
67
|
+
user = login_admin
|
68
|
+
assert @selenium.is_text_present("1 bis 1 >> von 3")
|
69
|
+
assert_equal "BBMB | Kunden", @selenium.get_title
|
70
|
+
assert @selenium.is_text_present("Test-Customer 1")
|
71
|
+
assert !@selenium.is_element_present("link=<<")
|
72
|
+
assert @selenium.is_element_present("link=>>")
|
73
|
+
|
74
|
+
@selenium.click "link=>>"
|
75
|
+
@selenium.wait_for_page_to_load "30000"
|
76
|
+
assert @selenium.is_text_present("<< 2 bis 2 >> von 3")
|
77
|
+
assert_equal "BBMB | Kunden", @selenium.get_title
|
78
|
+
assert @selenium.is_text_present("Test-Customer 2")
|
79
|
+
assert @selenium.is_element_present("link=<<")
|
80
|
+
assert @selenium.is_element_present("link=>>")
|
81
|
+
|
82
|
+
@selenium.click "link=>>"
|
83
|
+
@selenium.wait_for_page_to_load "30000"
|
84
|
+
assert @selenium.is_text_present("<< 3 bis 3 von 3")
|
85
|
+
assert_equal "BBMB | Kunden", @selenium.get_title
|
86
|
+
assert @selenium.is_text_present("Test-Customer 3")
|
87
|
+
assert @selenium.is_element_present("link=<<")
|
88
|
+
assert !@selenium.is_element_present("link=>>")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,257 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Selenium::TestFavorites -- bbmb.ch -- 05.10.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('..', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require "selenium/unit"
|
7
|
+
|
8
|
+
module BBMB
|
9
|
+
module Selenium
|
10
|
+
class TestFavorites < Test::Unit::TestCase
|
11
|
+
include Selenium::TestCase
|
12
|
+
def test_favorites
|
13
|
+
user = login_customer
|
14
|
+
@selenium.click "link=Schnellbestellung"
|
15
|
+
@selenium.wait_for_page_to_load "30000"
|
16
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
17
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 0 Positionen")
|
18
|
+
assert @selenium.is_element_present("//table[@id='favorites']")
|
19
|
+
assert @selenium.is_element_present("file_chooser")
|
20
|
+
assert @selenium.is_element_present("favorite_transfer")
|
21
|
+
assert_equal "Datei zu Schnellb.", @selenium.get_value("favorite_transfer")
|
22
|
+
assert @selenium.is_element_present("query")
|
23
|
+
assert @selenium.is_element_present("search_favorites")
|
24
|
+
assert_equal "Suchen", @selenium.get_value("search_favorites")
|
25
|
+
assert !@selenium.is_element_present("clear_favorites")
|
26
|
+
assert !@selenium.is_element_present("increment_order")
|
27
|
+
assert !@selenium.is_element_present("nullify")
|
28
|
+
assert !@selenium.is_element_present("default_values")
|
29
|
+
end
|
30
|
+
def test_favorites__with_position
|
31
|
+
BBMB.persistence.should_ignore_missing
|
32
|
+
product = Model::Product.new('12345')
|
33
|
+
product.description.de = 'product - a description'
|
34
|
+
product.price = Util::Money.new(11.50)
|
35
|
+
product.l1_price = Util::Money.new(12.50)
|
36
|
+
product.l1_qty = 2
|
37
|
+
product.l2_price = Util::Money.new(13.50)
|
38
|
+
product.l2_qty = 3
|
39
|
+
email = 'test.customer@bbmb.ch'
|
40
|
+
customer = Model::Customer.new('007')
|
41
|
+
customer.instance_variable_set('@email', email)
|
42
|
+
customer.favorites.add(15, product)
|
43
|
+
user = login_customer(customer)
|
44
|
+
@selenium.click "link=Schnellbestellung"
|
45
|
+
@selenium.wait_for_page_to_load "30000"
|
46
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
47
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 1 Positionen")
|
48
|
+
assert !@selenium.is_text_present("im Rückstand")
|
49
|
+
assert @selenium.is_element_present("file_chooser")
|
50
|
+
assert @selenium.is_element_present("favorite_transfer")
|
51
|
+
assert @selenium.is_element_present("clear_favorites")
|
52
|
+
assert_equal "Schnellb. löschen", @selenium.get_value("clear_favorites")
|
53
|
+
assert @selenium.is_text_present("2 Stk. à 12.50")
|
54
|
+
assert @selenium.is_text_present("3 Stk. à 13.50")
|
55
|
+
assert @selenium.is_element_present("increment_order")
|
56
|
+
assert_equal "Zu Best. hinzufügen", @selenium.get_value("increment_order")
|
57
|
+
assert @selenium.is_element_present("nullify")
|
58
|
+
assert_equal "Alles auf 0 setzen", @selenium.get_value("nullify")
|
59
|
+
assert @selenium.is_element_present("default_values")
|
60
|
+
assert_equal "Voreinstellungen", @selenium.get_value("default_values")
|
61
|
+
assert @selenium.is_element_present("quantity[12345]")
|
62
|
+
assert_equal "15", @selenium.get_value("quantity[12345]")
|
63
|
+
@selenium.click("nullify")
|
64
|
+
assert_equal "0", @selenium.get_value("quantity[12345]")
|
65
|
+
@selenium.click("default_values")
|
66
|
+
assert_equal "15", @selenium.get_value("quantity[12345]")
|
67
|
+
|
68
|
+
=begin # works, but throws an error when run with other tests, reason unclear
|
69
|
+
@selenium.choose_cancel_on_next_confirmation
|
70
|
+
@selenium.click("clear_favorites")
|
71
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
72
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 1 Positionen")
|
73
|
+
assert_equal "Wollen Sie wirklich die gesamte Schnellbestellung löschen?",
|
74
|
+
@selenium.get_confirmation
|
75
|
+
@selenium.click("clear_favorites")
|
76
|
+
=end
|
77
|
+
@selenium.open('/de/clear_favorites') # <- workaround
|
78
|
+
@selenium.wait_for_page_to_load "30000"
|
79
|
+
@selenium.choose_cancel_on_next_confirmation
|
80
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
81
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 0 Positionen")
|
82
|
+
end
|
83
|
+
def test_favorites__transfer_dat
|
84
|
+
datadir = File.expand_path('data', File.dirname(__FILE__))
|
85
|
+
BBMB.persistence.should_ignore_missing
|
86
|
+
user = login_customer
|
87
|
+
@selenium.click "link=Schnellbestellung"
|
88
|
+
@selenium.wait_for_page_to_load "30000"
|
89
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
90
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 0 Positionen")
|
91
|
+
assert @selenium.is_element_present("file_chooser")
|
92
|
+
assert @selenium.is_element_present("favorite_transfer")
|
93
|
+
|
94
|
+
src = <<-EOS
|
95
|
+
030201899 0624427Mycolog creme tube 15 g 000176803710902940
|
96
|
+
EOS
|
97
|
+
path = File.join(datadir, 'Transfer.dat')
|
98
|
+
FileUtils.mkdir_p(datadir)
|
99
|
+
File.open(path, 'w') { |fh| fh.puts src }
|
100
|
+
|
101
|
+
prod1 = Model::Product.new('1')
|
102
|
+
prod1.description.de = 'product - by pcode'
|
103
|
+
prod1.price = Util::Money.new(11.50)
|
104
|
+
prod2 = Model::Product.new('2')
|
105
|
+
prod2.description.de = 'product - by ean13'
|
106
|
+
prod2.price = Util::Money.new(21.50)
|
107
|
+
|
108
|
+
prodclass = flexstub(Model::Product)
|
109
|
+
prodclass.should_receive(:find_by_pcode).and_return { |pcode|
|
110
|
+
if(pcode == '624427')
|
111
|
+
prod1
|
112
|
+
end
|
113
|
+
}
|
114
|
+
prodclass.should_receive(:find_by_ean13).and_return { |ean13|
|
115
|
+
if(ean13 == '7680523160141')
|
116
|
+
prod2
|
117
|
+
end
|
118
|
+
}
|
119
|
+
|
120
|
+
@selenium.type "file_chooser", path
|
121
|
+
@http_server.inject_params = {"file_chooser", [src]}
|
122
|
+
@selenium.click "favorite_transfer"
|
123
|
+
@selenium.wait_for_page_to_load "30000"
|
124
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
125
|
+
|
126
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 2 Positionen"),
|
127
|
+
"Most likely firefox is blocking Javascript-Fileupload."
|
128
|
+
assert @selenium.is_text_present("product - by pcode")
|
129
|
+
assert @selenium.is_text_present("product - by ean13")
|
130
|
+
assert @selenium.is_text_present("Unidentifiziertes Produkt (Tramal gtt 10 ml 100 mg/ml, EAN-Code: 7680437880197, Pharmacode: 933022)")
|
131
|
+
|
132
|
+
@selenium.click "name=delete index=2"
|
133
|
+
@selenium.wait_for_page_to_load "30000"
|
134
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
135
|
+
assert !@selenium.is_text_present("Unidentifiziertes Produkt (Tramal gtt 10 ml 100 mg/ml, EAN-Code: 7680437880197, Pharmacode: 933022)")
|
136
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 2 Positionen")
|
137
|
+
|
138
|
+
@selenium.click "name=delete index=1"
|
139
|
+
@selenium.wait_for_page_to_load "30000"
|
140
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
141
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 1 Positionen")
|
142
|
+
assert @selenium.is_text_present("product - by ean13")
|
143
|
+
assert !@selenium.is_text_present("product - by pcode")
|
144
|
+
ensure
|
145
|
+
FileUtils.rm_r(datadir) if(File.exist?(datadir))
|
146
|
+
end
|
147
|
+
def test_favorites__increment_order
|
148
|
+
BBMB.persistence.should_ignore_missing
|
149
|
+
customer = BBMB::Model::Customer.new('007')
|
150
|
+
customer.instance_variable_set('@email', 'test.customer@bbmb.ch')
|
151
|
+
product1 = BBMB::Model::Product.new('1')
|
152
|
+
product1.description.de = "Product 1"
|
153
|
+
product1.price = Util::Money.new(11.10)
|
154
|
+
product2 = BBMB::Model::Product.new('2')
|
155
|
+
product2.description.de = "Product 2"
|
156
|
+
product2.price = Util::Money.new(12.20)
|
157
|
+
product3 = BBMB::Model::Product.new('3')
|
158
|
+
product3.description.de = "Product 3"
|
159
|
+
product3.price = Util::Money.new(13.30)
|
160
|
+
order = customer.current_order
|
161
|
+
order.add(2, product1)
|
162
|
+
order.add(3, product2)
|
163
|
+
favs = customer.favorites
|
164
|
+
favs.add(5, product2)
|
165
|
+
favs.add(7, product3)
|
166
|
+
user = login_customer customer
|
167
|
+
assert_equal "BBMB | Home", @selenium.get_title
|
168
|
+
assert @selenium.is_text_present("Aktuelle Bestellung: 2 Positionen")
|
169
|
+
|
170
|
+
@selenium.click "link=Schnellbestellung"
|
171
|
+
@selenium.wait_for_page_to_load "30000"
|
172
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
173
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 2 Positionen")
|
174
|
+
@selenium.type "quantity[3]", "trigger an error"
|
175
|
+
@selenium.click "increment_order"
|
176
|
+
@selenium.wait_for_page_to_load "30000"
|
177
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
178
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 2 Positionen")
|
179
|
+
@selenium.type "quantity[3]", "11"
|
180
|
+
@selenium.click "increment_order"
|
181
|
+
@selenium.wait_for_page_to_load "30000"
|
182
|
+
assert @selenium.is_text_present("Aktuelle Bestellung: 3 Positionen")
|
183
|
+
assert @selenium.is_text_present("Total Sfr. 266.10")
|
184
|
+
assert_equal [['1', 2], ['2', 8], ['3', 11]], order.collect { |position|
|
185
|
+
[position.article_number, position.quantity]
|
186
|
+
}
|
187
|
+
assert_equal [['2', 5], ['3', 7]], favs.collect { |position|
|
188
|
+
[position.article_number, position.quantity]
|
189
|
+
}
|
190
|
+
end
|
191
|
+
def test_favorites__scan
|
192
|
+
BBMB.persistence.should_ignore_missing
|
193
|
+
user = login_customer
|
194
|
+
@selenium.click "link=Schnellbestellung"
|
195
|
+
@selenium.wait_for_page_to_load "30000"
|
196
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
197
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 0 Positionen")
|
198
|
+
|
199
|
+
prod1 = Model::Product.new('1')
|
200
|
+
prod1.description.de = 'product 1'
|
201
|
+
prod1.price = Util::Money.new(11.50)
|
202
|
+
prodclass = flexstub(Model::Product)
|
203
|
+
prodclass.should_receive(:find_by_ean13).and_return { |ean13|
|
204
|
+
if(ean13 == '7680523160141')
|
205
|
+
prod1
|
206
|
+
end
|
207
|
+
}
|
208
|
+
|
209
|
+
## simulate barcode-reader
|
210
|
+
@selenium.open('/de/scan/EAN_13[7680523160141]/1/EAN_13[7680123456781]/1')
|
211
|
+
@selenium.wait_for_page_to_load "30000"
|
212
|
+
|
213
|
+
@selenium.open('/de/favorites')
|
214
|
+
@selenium.wait_for_page_to_load "30000"
|
215
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
216
|
+
|
217
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 1 Positionen")
|
218
|
+
assert @selenium.is_text_present("product 1")
|
219
|
+
assert @selenium.is_text_present("Unidentifiziertes Produkt (EAN-Code: 7680123456781)")
|
220
|
+
end
|
221
|
+
def test_favorites__backorder
|
222
|
+
BBMB.persistence.should_ignore_missing
|
223
|
+
product = Model::Product.new('12345')
|
224
|
+
product.description.de = 'product - a description'
|
225
|
+
product.price = Util::Money.new(11.50)
|
226
|
+
product.l1_price = Util::Money.new(12.50)
|
227
|
+
product.l1_qty = 2
|
228
|
+
product.l2_price = Util::Money.new(13.50)
|
229
|
+
product.l2_qty = 3
|
230
|
+
product.backorder = true
|
231
|
+
email = 'test.customer@bbmb.ch'
|
232
|
+
customer = Model::Customer.new('007')
|
233
|
+
customer.instance_variable_set('@email', email)
|
234
|
+
customer.favorites.add(15, product)
|
235
|
+
user = login_customer(customer)
|
236
|
+
@selenium.click "link=Schnellbestellung"
|
237
|
+
@selenium.wait_for_page_to_load "30000"
|
238
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
239
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 1 Positionen")
|
240
|
+
assert @selenium.is_text_present("im Rückstand")
|
241
|
+
end
|
242
|
+
def test_favorites__barcode_controls
|
243
|
+
session = flexstub(@server['test:preset-session-id'])
|
244
|
+
session.should_receive(:client_activex?).and_return(true)
|
245
|
+
BBMB.persistence.should_ignore_missing
|
246
|
+
user = login_customer
|
247
|
+
@selenium.click "link=Schnellbestellung"
|
248
|
+
@selenium.wait_for_page_to_load "30000"
|
249
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
250
|
+
assert @selenium.is_text_present("Aktuelle Schnellbest.: 0 Positionen")
|
251
|
+
assert @selenium.is_element_present("//a[@name='barcode_usb']")
|
252
|
+
assert @selenium.is_element_present("//input[@name='barcode_button']")
|
253
|
+
assert @selenium.is_element_present("//input[@name='barcode_comport']")
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Selenium::TestFavoritesResult -- bbmb.ch -- 05.10.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('..', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require "selenium/unit"
|
7
|
+
|
8
|
+
module BBMB
|
9
|
+
module Selenium
|
10
|
+
class TestFavoritesResult < Test::Unit::TestCase
|
11
|
+
include Selenium::TestCase
|
12
|
+
def test_favorites_result__empty
|
13
|
+
user = login_customer
|
14
|
+
@selenium.click "link=Schnellbestellung"
|
15
|
+
@selenium.wait_for_page_to_load "30000"
|
16
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
17
|
+
flexstub(Model::Product).should_receive(:search_by_description).times(1).and_return {
|
18
|
+
|query|
|
19
|
+
assert_equal 'product', query
|
20
|
+
[]
|
21
|
+
}
|
22
|
+
@selenium.type "query", "product"
|
23
|
+
@selenium.click "document.search.search_favorites"
|
24
|
+
@selenium.wait_for_page_to_load "30000"
|
25
|
+
|
26
|
+
assert @selenium.is_text_present("Suchresultat: 0 Produkte gefunden")
|
27
|
+
assert @selenium.is_element_present("//input[@type='text' and @name='query']")
|
28
|
+
assert !@selenium.is_element_present("//input[@type='submit' and @name='order_product']")
|
29
|
+
end
|
30
|
+
def test_favorites_result__1
|
31
|
+
user = login_customer
|
32
|
+
@selenium.click "link=Schnellbestellung"
|
33
|
+
@selenium.wait_for_page_to_load "30000"
|
34
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
35
|
+
|
36
|
+
product = Model::Product.new('12345')
|
37
|
+
product.description.de = 'product - a description'
|
38
|
+
product.price = Util::Money.new(12.50)
|
39
|
+
flexstub(Model::Product).should_receive(:search_by_description).times(1).and_return {
|
40
|
+
|query|
|
41
|
+
assert_equal 'product', query
|
42
|
+
[product]
|
43
|
+
}
|
44
|
+
@selenium.type "query", "product"
|
45
|
+
@selenium.click "document.search.search_favorites"
|
46
|
+
@selenium.wait_for_page_to_load "30000"
|
47
|
+
|
48
|
+
assert_equal "BBMB | Suchen", @selenium.get_title
|
49
|
+
assert @selenium.is_text_present("Suchresultat: 1 Produkt gefunden")
|
50
|
+
assert @selenium.is_element_present("//input[@type='text' and @name='query']")
|
51
|
+
assert !@selenium.is_element_present("//input[@type='submit' and @name='order_product']")
|
52
|
+
assert @selenium.is_element_present("//input[@name='quantity[12345]']")
|
53
|
+
assert_equal '0', @selenium.get_value("//input[@name='quantity[12345]']")
|
54
|
+
assert !@selenium.is_text_present("im Rückstand")
|
55
|
+
end
|
56
|
+
def test_favorites_result__backorder
|
57
|
+
user = login_customer
|
58
|
+
@selenium.click "link=Schnellbestellung"
|
59
|
+
@selenium.wait_for_page_to_load "30000"
|
60
|
+
assert_equal "BBMB | Schnellbestellung", @selenium.get_title
|
61
|
+
|
62
|
+
product = Model::Product.new('12345')
|
63
|
+
product.description.de = 'product - a description'
|
64
|
+
product.price = Util::Money.new(12.50)
|
65
|
+
product.backorder = true
|
66
|
+
flexstub(Model::Product).should_receive(:search_by_description).times(1).and_return {
|
67
|
+
|query|
|
68
|
+
assert_equal 'product', query
|
69
|
+
[product]
|
70
|
+
}
|
71
|
+
@selenium.type "query", "product"
|
72
|
+
@selenium.click "document.search.search_favorites"
|
73
|
+
@selenium.wait_for_page_to_load "30000"
|
74
|
+
|
75
|
+
assert_equal "BBMB | Suchen", @selenium.get_title
|
76
|
+
assert @selenium.is_text_present("Suchresultat: 1 Produkt gefunden")
|
77
|
+
assert @selenium.is_text_present("im Rückstand")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Selenium::TestHistory -- bbmb.ch -- 05.10.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('..', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require 'selenium/unit'
|
7
|
+
|
8
|
+
module BBMB
|
9
|
+
module Selenium
|
10
|
+
class TestHistory < Test::Unit::TestCase
|
11
|
+
include Selenium::TestCase
|
12
|
+
def test_history
|
13
|
+
BBMB.persistence.should_ignore_missing
|
14
|
+
customer = BBMB::Model::Customer.new('007')
|
15
|
+
customer.organisation = 'Test-Customer'
|
16
|
+
customer.instance_variable_set('@email', 'test.customer@bbmb.ch')
|
17
|
+
customer.plz = '7777'
|
18
|
+
@persistence.should_receive(:all).and_return { |klass|
|
19
|
+
assert_equal(BBMB::Model::Customer, klass)
|
20
|
+
[customer]
|
21
|
+
}
|
22
|
+
product1 = BBMB::Model::Product.new('1')
|
23
|
+
product1.description.de = "Product 1"
|
24
|
+
product1.price = Util::Money.new(11.10)
|
25
|
+
product2 = BBMB::Model::Product.new('2')
|
26
|
+
product2.description.de = "Product 2"
|
27
|
+
product2.price = Util::Money.new(12.20)
|
28
|
+
product3 = BBMB::Model::Product.new('3')
|
29
|
+
product3.description.de = "Product 3"
|
30
|
+
product3.price = Util::Money.new(13.30)
|
31
|
+
product4 = BBMB::Model::Product.new('2')
|
32
|
+
product4.description.de = "Product 2"
|
33
|
+
product4.price = Util::Money.new(10.00)
|
34
|
+
order = customer.current_order
|
35
|
+
order.add(2, product1)
|
36
|
+
order.add(3, product2)
|
37
|
+
customer.commit_order!
|
38
|
+
order = customer.current_order
|
39
|
+
order.add(5, product4)
|
40
|
+
order.add(7, product3)
|
41
|
+
customer.commit_order!
|
42
|
+
user = login_admin
|
43
|
+
@selenium.click "link=Test-Customer"
|
44
|
+
@selenium.wait_for_page_to_load "30000"
|
45
|
+
assert_equal "BBMB | Kunde", @selenium.get_title
|
46
|
+
|
47
|
+
@selenium.click "link=Umsatz"
|
48
|
+
@selenium.wait_for_page_to_load "30000"
|
49
|
+
assert_equal "BBMB | Umsatz", @selenium.get_title
|
50
|
+
assert_equal "1", @selenium.get_text("//tr[2]/td[1]")
|
51
|
+
assert_equal "2", @selenium.get_text("//tr[2]/td[2]")
|
52
|
+
assert_equal "Product 1", @selenium.get_text("//tr[2]/td[3]")
|
53
|
+
assert_equal "11.10", @selenium.get_text("//tr[2]/td[4]")
|
54
|
+
assert_equal "22.20", @selenium.get_text("//tr[2]/td[5]")
|
55
|
+
assert_equal "2", @selenium.get_text("//tr[3]/td[1]")
|
56
|
+
assert_equal "8", @selenium.get_text("//tr[3]/td[2]")
|
57
|
+
assert_equal "Product 2", @selenium.get_text("//tr[3]/td[3]")
|
58
|
+
assert_equal "10.00 bis 12.20", @selenium.get_text("//tr[3]/td[4]")
|
59
|
+
assert_equal "86.60", @selenium.get_text("//tr[3]/td[5]")
|
60
|
+
assert_equal "1", @selenium.get_text("//tr[4]/td[1]")
|
61
|
+
assert_equal "7", @selenium.get_text("//tr[4]/td[2]")
|
62
|
+
assert_equal "Product 3", @selenium.get_text("//tr[4]/td[3]")
|
63
|
+
assert_equal "13.30", @selenium.get_text("//tr[4]/td[4]")
|
64
|
+
assert_equal "93.10", @selenium.get_text("//tr[4]/td[5]")
|
65
|
+
assert @selenium.is_text_present("Totalumsatz: 201.90")
|
66
|
+
|
67
|
+
## sort the result according to quantity
|
68
|
+
@selenium.click "link=Menge"
|
69
|
+
@selenium.wait_for_page_to_load "30000"
|
70
|
+
assert_equal "BBMB | Umsatz", @selenium.get_title
|
71
|
+
assert_equal "1", @selenium.get_text("//tr[2]/td[1]")
|
72
|
+
assert_equal "2", @selenium.get_text("//tr[2]/td[2]")
|
73
|
+
assert_equal "Product 1", @selenium.get_text("//tr[2]/td[3]")
|
74
|
+
assert_equal "11.10", @selenium.get_text("//tr[2]/td[4]")
|
75
|
+
assert_equal "22.20", @selenium.get_text("//tr[2]/td[5]")
|
76
|
+
assert_equal "1", @selenium.get_text("//tr[3]/td[1]")
|
77
|
+
assert_equal "7", @selenium.get_text("//tr[3]/td[2]")
|
78
|
+
assert_equal "Product 3", @selenium.get_text("//tr[3]/td[3]")
|
79
|
+
assert_equal "13.30", @selenium.get_text("//tr[3]/td[4]")
|
80
|
+
assert_equal "93.10", @selenium.get_text("//tr[3]/td[5]")
|
81
|
+
assert_equal "2", @selenium.get_text("//tr[4]/td[1]")
|
82
|
+
assert_equal "8", @selenium.get_text("//tr[4]/td[2]")
|
83
|
+
assert_equal "Product 2", @selenium.get_text("//tr[4]/td[3]")
|
84
|
+
assert_equal "10.00 bis 12.20", @selenium.get_text("//tr[4]/td[4]")
|
85
|
+
assert_equal "86.60", @selenium.get_text("//tr[4]/td[5]")
|
86
|
+
assert @selenium.is_text_present("Totalumsatz: 201.90")
|
87
|
+
|
88
|
+
## sort the result according to quantity - reversed
|
89
|
+
@selenium.click "link=Menge"
|
90
|
+
@selenium.wait_for_page_to_load "30000"
|
91
|
+
assert_equal "BBMB | Umsatz", @selenium.get_title
|
92
|
+
assert_equal "2", @selenium.get_text("//tr[2]/td[1]")
|
93
|
+
assert_equal "8", @selenium.get_text("//tr[2]/td[2]")
|
94
|
+
assert_equal "Product 2", @selenium.get_text("//tr[2]/td[3]")
|
95
|
+
assert_equal "10.00 bis 12.20", @selenium.get_text("//tr[2]/td[4]")
|
96
|
+
assert_equal "86.60", @selenium.get_text("//tr[2]/td[5]")
|
97
|
+
assert_equal "1", @selenium.get_text("//tr[3]/td[1]")
|
98
|
+
assert_equal "7", @selenium.get_text("//tr[3]/td[2]")
|
99
|
+
assert_equal "Product 3", @selenium.get_text("//tr[3]/td[3]")
|
100
|
+
assert_equal "13.30", @selenium.get_text("//tr[3]/td[4]")
|
101
|
+
assert_equal "93.10", @selenium.get_text("//tr[3]/td[5]")
|
102
|
+
assert_equal "1", @selenium.get_text("//tr[4]/td[1]")
|
103
|
+
assert_equal "2", @selenium.get_text("//tr[4]/td[2]")
|
104
|
+
assert_equal "Product 1", @selenium.get_text("//tr[4]/td[3]")
|
105
|
+
assert_equal "11.10", @selenium.get_text("//tr[4]/td[4]")
|
106
|
+
assert_equal "22.20", @selenium.get_text("//tr[4]/td[5]")
|
107
|
+
assert @selenium.is_text_present("Totalumsatz: 201.90")
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|