Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANW-1168: strip out quotes from the confimration when deleting a repo #2604

Merged
merged 1 commit into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/app/views/repositories/_toolbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{ :class => "btn btn-sm btn-danger delete-record delete-repository",
:"data-confirm-btn-class" => "btn-danger repo-delete",
:"data-title" => I18n.t("actions.delete_repository_confirm_title", :name => @repository["repository"]["name"]),
:"data-message" => I18n.t("actions.delete_repository_confirm_message", :repository => @repository["repository"]["repo_code"] ) } %>
:"data-message" => I18n.t("actions.delete_repository_confirm_message", :repository => @repository["repository"]["repo_code"].gsub("'", "").gsub('"', '') ) } %>
</div>
</div>
<% end %>
Expand Down
23 changes: 23 additions & 0 deletions frontend/spec/selenium/spec/repositories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,29 @@
assert(5) { expect(@driver.find_element(css: 'div.alert.alert-success').text).to eq('Repository Deleted') }
end

it 'strips out quotes from confirmation when deleting a repository' do
@deletable_repo2 = create(:repo, repo_code: "delete'me_#{Time.now.to_i}")

set_repo(@deletable_repo2)

run_all_indexers

escaped_repo_code = @deletable_repo2.repo_code.gsub("'", "")
escaped_repo_code_xpath = "delete"

@driver.get("#{$frontend}/repositories")

row = @driver.find_paginated_element(xpath: "//tr[.//*[contains(text(), '#{escaped_repo_code_xpath}')]]")
@driver.click_and_wait_until_element_gone(row.find_element(:link, 'Edit'))

@driver.find_element(:css, '.delete-record.btn').click
@driver.clear_and_send_keys([:id, 'deleteRepoConfim'], escaped_repo_code)
@driver.wait_for_ajax

@driver.find_element(:css, '#confirmChangesModal #confirmButton').click
assert(5) { expect(@driver.find_element(css: 'div.alert.alert-success').text).to eq('Repository Deleted') }
end

it 'can create a second repository' do
@driver.get("#{$frontend}/repositories")
@driver.click_and_wait_until_gone(:link, 'Create Repository')
Expand Down