-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathportfolio.rb
More file actions
210 lines (168 loc) · 5.6 KB
/
portfolio.rb
File metadata and controls
210 lines (168 loc) · 5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
require 'capybara/cucumber'
require 'capybara/cuprite'
Capybara.run_server = false
Capybara.default_driver = :cuprite
Capybara.javascript_driver = :cuprite
Capybara.app_host = "http://localhost:3000"
Capybara.default_max_wait_time = 10
def getUUID(itemName)
uuid = nil
case itemName
when "Ateliers du Carmel du Mans"
uuid = "0edea8e39068ed49a8f555a660d7cc68"
when "David Tremlett"
uuid = "7123a482ef397d4cb464ea3ec37655e0"
when "1868"
uuid = "29e7a2c6a601c040985ade144901cb1f"
when "Figuration du donateur"
uuid = "fe94b684b6a42c4889c1e0d7458b9526"
end
return uuid
end
# Conditions
Soit("le point de vue {string} rattaché au portfolio {string}") do |viewpoint, portfolio|
# On the remote servers
end
Soit("le corpus {string} rattaché au portfolio {string}") do |viewpoint, portfolio|
# On the remote servers
end
Soit("la rubrique {string} contenue dans la rubrique {string}") do |topic1, topic2|
# On the remote servers
end
Soit("{int} items décrits par {string} et {string}") do |itemsNb, topic1, topic2|
# On the remote servers
end
Soit("la rubrique {string} rattachée au point de vue {string}") do |topic, viewpoint|
# On the remote servers
end
Soit("l'item {string} rattaché à la rubrique {string}") do |item, topic|
# On the remote servers
end
Soit("{string} le portfolio spécifié dans la configuration") do |portfolio|
case portfolio
when "vitraux"
true #current configuration
when "indéfini"
pending "alternate configuration"
else
false
end
end
Soit("{string} le portfolio ouvert") do |portfolio|
visit "/" + portfolio
end
Soit("{string} une des rubriques développées") do |topic|
find_link(topic).sibling('.oi').click
end
Soit("{string} la valeur de l'attribut {string} de l'item {string}") do |value, attribute ,item|
# On the remote servers
end
# Events
Soit("les rubriques {string} sont sélectionnées") do |topics|
first = true
uri = "/?"
topics.split("|").each do |topic|
uuid = getUUID(topic)
if (first)
uri += "t=" + uuid
first = false
else
uri += "&t=" + uuid
end
end
visit uri
end
Soit("la liste des rubriques sélectionnées est vide") do
visit "/"
end
Soit("la rubrique {string} sélectionnée") do |topic|
find_link(topic).click
end
Soit("l'utilisateur est connecté") do
find_link(href: '#login').click
fill_in("nom d'utilisateur", with: "alice")
fill_in("mot de passe", with: "whiterabbit")
click_on('Se connecter')
end
# For scenatio with multiple selection
Soit("le mode sélection activé") do
click_on('Attribuer Topic')
end
# Events
Quand("un visiteur ouvre la page d'accueil du site") do
visit "/"
end
Quand("un visiteur ouvre la page d‘accueil d‘un site dont l‘adresse commence par {string}") do |portfolio|
visit "/"
end
Quand("on sélectionne la rubrique {string}") do |topic|
click_on topic
end
Quand("on choisit l'item {string}") do |item|
click_on item
end
Quand("on ajoute un attribut de recherche {string} avec pour valeur {string}") do |attribut, valeur|
fill_in('Attribut1', with: attribut)
fill_in('Valeur1', with: valeur)
click_button('Rechercher')
end
Quand("on ajoute un attribut de recherche {string} avec pour valeur {string} et un attribut de recherche {string} avec pour valeur {string}") do |attribut1, attribut2, valeur1, valeur2|
fill_in('Attribut1', with: attribut1)
fill_in('Valeur1', with: valeur1)
find_button(class: ['btn', 'btn-light', 'creationButton']).click
fill_in('Attribut2', with: attribut2)
fill_in('Valeur2', with: valeur2)
click_button('Rechercher')
end
Quand("on attribue la rubrique {string} aux items {string}, {string}, {string}, {string}, et {string}") do |topic, item1, item2, item3, item4, item5|
click_on(item1)
click_on(item2)
click_on(item3)
click_on(item4)
click_on(item5)
find('.TopicGroupAddInput').send_keys [topic, :down, :enter]
find('.TopicGroupAddButton').click
click_button('Confirmer')
click_button('Fermer')
click_button('Annuler')
end
Quand("on met {string} dans la barre de recherche") do |value|
fill_in('Rechercher...', with: value).native.send_keys(:return)
end
# Outcomes
Alors("le titre affiché est {string}") do |portfolio|
expect(page).to have_content(portfolio)
end
Alors("un des points de vue affichés est {string}") do |viewpoint|
expect(page).to have_content viewpoint
end
Alors("un des corpus affichés est {string}") do |corpus|
expect(page).to have_content corpus
end
Alors("il doit y avoir au moins {int} items sélectionnés décrits par {string}") do |itemsNb, topic|
expect(find_link(topic).sibling('.badge').text.scan(/\d+/)[0].to_i).to be >= itemsNb
end
Alors("les rubriques surlignées sont au nombre de {int}") do |topicNb|
expect(page).to have_selector('.Selected', :count => topicNb)
end
Alors ("l'item {string} est affiché") do |item|
expect(page).to have_content item
end
Alors ("l'item {string} n'est pas affiché") do |item|
expect(page).not_to have_content item
end
Alors("les dessins {string} et {string} sont parmi les dessins affichés") do |valeur1, valeur2|
expect(page).to have_content(valeur1)
expect(page).to have_content(valeur2)
end
Alors("les items {string}, {string}, {string}, {string} et {string} ont la rubrique {string}") do |item1, item2, item3, item4, item5, topic|
click_on(topic)
expect(page).to have_content item1
expect(page).to have_content item2
expect(page).to have_content item3
expect(page).to have_content item4
expect(page).to have_content item5
end
Alors("il doit y avoir au moins {int} items dans la rubrique {string}") do |int, string|
pending # Write code here that turns the phrase above into concrete actions
end