From b50dc558318ebd9697dfc0d1fa7c5454d64e8027 Mon Sep 17 00:00:00 2001 From: Fabien Petit Date: Wed, 19 Jun 2024 14:29:30 +0200 Subject: [PATCH] TEST : Delete a picture from a document (see #187) Co-Authored-By: Martin GANDOM --- features/step_definitions/context.rb | 4 ++++ features/step_definitions/event.rb | 11 ++++++++--- features/step_definitions/outcome.rb | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/features/step_definitions/context.rb b/features/step_definitions/context.rb index 2ab48061..ed91923e 100644 --- a/features/step_definitions/context.rb +++ b/features/step_definitions/context.rb @@ -131,3 +131,7 @@ Soit("un document que l'on consulte") do visit '/146e6e8442f0405b721b79357d00d0a1' end + +Soit ("une image {string} dans une glose") do |image_name| + attach_file("image-input", File.expand_path("./docs/#{image_name}"), make_visible: true) +end diff --git a/features/step_definitions/event.rb b/features/step_definitions/event.rb index d398cacd..c3a9e64c 100644 --- a/features/step_definitions/event.rb +++ b/features/step_definitions/event.rb @@ -60,6 +60,11 @@ attach_file("image-input", File.expand_path("./docs/#{image_name}"), make_visible: true) end -Quand("j'essaye de supprimer une image d'une glose") do - pending # Write code here that turns the phrase above into concrete actions -end \ No newline at end of file +Quand("j'essaye de supprimer l'image {string} d'une glose") do |image_name| + image = find('img[alt="' + image_name + '"]') + delete_button = image.find(:xpath, 'following-sibling::button[contains(@class, "delete-image")]') + delete_button.click + popup = find('#confirmation-popup', visible: true) + yes_button = popup.find('button.confirm-yes') + yes_button.click +end diff --git a/features/step_definitions/outcome.rb b/features/step_definitions/outcome.rb index c41eca8e..5f221073 100644 --- a/features/step_definitions/outcome.rb +++ b/features/step_definitions/outcome.rb @@ -87,6 +87,6 @@ expect(page).not_to have_content(title) end -Alors("l'image disparait dans la glose") do - pending +Alors("je ne vois pas l'image {string}") do |image_name| + expect(page) end \ No newline at end of file