Skip to content

Commit

Permalink
Test the rendered HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
kdp-cloud committed Jun 3, 2024
1 parent 04a82a4 commit b76c1f6
Showing 1 changed file with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions test/functional/single_pages_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,35 @@ def setup
assert_equal updated_samples.size, 2
assert_equal new_samples.size, 2
assert_equal possible_duplicates.size, 1

post :upload_samples, as: :html, params: { file:, project_id: project.id,
sample_type_id: source_sample_type.id }

assert_response :success

assert_select 'table#create-samples-table', count: 1 do
assert_select "tbody tr", count: new_samples.size
end

assert_select 'table#update-samples-table', count: 1 do
update_sample_ids = updated_samples.map { |s| s['id'] }
update_sample_ids.map do |sample_id|
row_id_updated = "update-sample-#{sample_id}-updated"
assert_select "tr##{row_id_updated}", count: 1

row_id_original = "update-sample-#{sample_id}-original"
assert_select "tr##{row_id_original}", count: 1
end
end

assert_select 'table#duplicate-samples-table', count: 1 do
dup_sample_ids = possible_duplicates.map { |s| s['duplicate']['id'] }
dup_sample_ids.map do |sample_id|
row_id = "duplicate-sample-#{sample_id}"
assert_select "tr##{row_id}-1", count: 1
assert_select "tr##{row_id}-2", count: 1
end
end
end
end

Expand All @@ -190,6 +219,35 @@ def setup
assert_equal updated_samples.size, 2
assert_equal new_samples.size, 2
assert_equal possible_duplicates.size, 1

post :upload_samples, as: :html, params: { file:, project_id: project.id,
sample_type_id: sample_collection_sample_type.id }

assert_response :success

assert_select 'table#create-samples-table', count: 1 do
assert_select "tbody tr", count: new_samples.size
end

assert_select 'table#update-samples-table', count: 1 do
update_sample_ids = updated_samples.map { |s| s['id'] }
update_sample_ids.map do |sample_id|
row_id_updated = "update-sample-#{sample_id}-updated"
assert_select "tr##{row_id_updated}", count: 1

row_id_original = "update-sample-#{sample_id}-original"
assert_select "tr##{row_id_original}", count: 1
end
end

assert_select 'table#duplicate-samples-table', count: 1 do
dup_sample_ids = possible_duplicates.map { |s| s['duplicate']['id'] }
dup_sample_ids.map do |sample_id|
row_id = "duplicate-sample-#{sample_id}"
assert_select "tr##{row_id}-1", count: 1
assert_select "tr##{row_id}-2", count: 1
end
end
end
end

Expand All @@ -214,6 +272,35 @@ def setup
assert_equal updated_samples.size, 2
assert_equal new_samples.size, 1
assert_equal possible_duplicates.size, 1

post :upload_samples, as: :html, params: { file:, project_id: project.id,
sample_type_id: assay_sample_type.id }

assert_response :success

assert_select 'table#create-samples-table', count: 1 do
assert_select "tbody tr", count: new_samples.size
end

assert_select 'table#update-samples-table', count: 1 do
update_sample_ids = updated_samples.map { |s| s['id'] }
update_sample_ids.map do |sample_id|
row_id_updated = "update-sample-#{sample_id}-updated"
assert_select "tr##{row_id_updated}", count: 1

row_id_original = "update-sample-#{sample_id}-original"
assert_select "tr##{row_id_original}", count: 1
end
end

assert_select 'table#duplicate-samples-table', count: 1 do
dup_sample_ids = possible_duplicates.map { |s| s['duplicate']['id'] }
dup_sample_ids.map do |sample_id|
row_id = "duplicate-sample-#{sample_id}"
assert_select "tr##{row_id}-1", count: 1
assert_select "tr##{row_id}-2", count: 1
end
end
end
end

Expand Down Expand Up @@ -243,6 +330,25 @@ def setup

possible_duplicates = response_data['possibleDuplicates']
assert(possible_duplicates.size, 1)

post :upload_samples, as: :html, params: { file:, project_id: project.id,
sample_type_id: source_sample_type.id }

assert_response :success

assert_select 'table#create-samples-table', count: 1 do
assert_select "tbody tr", count: new_samples.size
end

assert_select 'table#update-samples-table', count: 0

assert_select 'table#unauthorized-samples-table', count: 1 do
unauthorized_sample_ids = unauthorized_samples.map { |s| s['id'] }
unauthorized_sample_ids.map do |sample_id|
row_id = "unauthorized-sample-#{sample_id}"
assert_select "tr##{row_id}", count: 1
end
end
end
end

Expand Down

0 comments on commit b76c1f6

Please sign in to comment.