Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v4.13.0 (Month 2024)
- Prevent selecting multiple Issue ID columns

v4.12.0 (May 2024)
- Update Dradis links in README

Expand Down
15 changes: 14 additions & 1 deletion app/assets/javascripts/dradis/plugins/csv/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ window.addEventListener('job-done', function () {
document.addEventListener('turbolinks:load', function () {
if ($('body.upload.new').length) {
$('[data-behavior=type-select]').on('change', function () {
var $nodeSelect = $('select option[value="node"]:selected').parent();
var $nodeSelect = $('select option[value="node"]:selected').parent(),
Comment thread
MattBudz marked this conversation as resolved.
Outdated
$idSelect = $('select option[value="identifier"]:selected').parent();

// Disable Node Label option
if ($nodeSelect.length) {
Expand All @@ -31,6 +32,18 @@ document.addEventListener('turbolinks:load', function () {
.removeAttr('disabled');
}

// Disable Issue ID Label option
if ($idSelect.length) {
$('[data-behavior=type-select]')
.not($idSelect)
.find('option[value="identifier"]')
.attr('disabled', 'disabled');
} else {
$('[data-behavior=type-select]')
.find('option[value="identifier"]')
.removeAttr('disabled');
}

$(this)
.parents('tr')
.toggleClass('issue-type', $(this).val() == 'issue');
Expand Down
24 changes: 16 additions & 8 deletions spec/features/upload_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'

# To run, execute from Dradis main app folder:
# bin/rspec [dradis-plugins path]/spec/features/upload_spec.rb
# bin/rspec [dradis-csv path]/spec/features/upload_spec.rb

describe 'upload feature', js: true do
before do
Expand All @@ -16,9 +16,7 @@

select 'Dradis::Plugins::CSV', from: 'uploader'

within('.custom-file') do
page.find('#file', visible: false).attach_file(file_path)
end
page.find('#file', visible: false).attach_file(file_path)

find('body.upload.new', wait: 30)
end
Expand All @@ -36,7 +34,7 @@
end

context 'mapping CSV columns' do
context 'when identifier not selected' do
context 'when the identifier not selected' do
it 'shows a validation message on the page' do
within all('tbody tr')[3] do
select 'Evidence Field'
Expand All @@ -47,6 +45,18 @@
end
end

context 'when the identifier is selected' do
it 'disables all the other identifier option' do
within all('tbody tr')[0] do
select 'Issue ID'
end

within all('tbody tr')[1] do
expect(find('option', text: 'Issue ID')[:disabled]).to eq('true')
end
end
end

context 'when there are evidence type but no node type selected' do
it 'shows a validation message on the page' do
within all('tbody tr')[2] do
Expand Down Expand Up @@ -241,9 +251,7 @@
before do
select 'Dradis::Plugins::CSV', from: 'uploader'

within('.custom-file') do
page.find('#file', visible: false).attach_file(file_path)
end
page.find('#file', visible: false).attach_file(file_path)
end

context 'uploading a malformed CSV file' do
Expand Down