Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions app/assets/javascripts/select_all.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,12 @@ window.addEventListener('beforeunload', function () {
selectAllAbortController.abort();
}
});

//adding data-testid to select toggles for testing
$(function () {
$('label.toggle-bookmark input.toggle-bookmark[type=checkbox]').each(function () {
const m = this.id && this.id.match(/^toggle-bookmark_(.+)$/);
$(this).attr('data-testid', m ? `bookmark-toggle-${m[1]}` : 'bookmark-toggle');
});
});

2 changes: 1 addition & 1 deletion app/javascript/components/tables/CheckoutsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const CheckoutsTable = ({ url, isAdmin, returnAll }) => {

displayReturnedItemsHTML: (
<Col span={3} offset={9} className='mb-2 text-end text-nowrap'>
<input type='checkbox' checked={showReturned} id='inactive_checkouts' onChange={refreshData} />
<input type='checkbox' checked={showReturned} id='inactive_checkouts' data-testid='bookmark-display-returned-items-chkbox' onChange={refreshData} />
<label className='fw-bold ms-1' htmlFor='inactive_checkouts'>Display Returned Items</label>
</Col>
)
Expand Down
4 changes: 2 additions & 2 deletions app/views/_user_util_links.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Unless required by applicable law or agreed to in writing, software distributed
<li class="nav-item <%= active_for_controller('checkouts') %>">
<%= link_to main_app.checkouts_path, id:'checkouts_nav', class: 'nav-link' do %>
Checkouts
(<span data-role='checkout-counter'><%= Checkout.active_for_user(current_or_guest_user.id).count %></span>)
(<span data-role='checkout-counter' data-testid='checkout-counter'><%= Checkout.active_for_user(current_or_guest_user.id).count %></span>)
<% end %>
</li>
<% end %>
Expand All @@ -46,7 +46,7 @@ Unless required by applicable law or agreed to in writing, software distributed
<li class="nav-item <%= active_for_controller('bookmarks') %>">
<%= link_to main_app.bookmarks_path, id:'bookmarks_nav', class: 'nav-link' do %>
<%= t('blacklight.header_links.bookmarks') %>
(<span data-role='bookmark-counter'><%= current_or_guest_user.bookmarks.count %></span>)
(<span data-role='bookmark-counter' data-testid='bookmark-counter'><%= current_or_guest_user.bookmarks.count %></span>)
<% end %>
</li>
<% end %>
Expand Down
14 changes: 7 additions & 7 deletions app/views/admin/collections/_cdl_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ Unless required by applicable law or agreed to in writing, software distributed
<% if can?(:update_access_control, object) %>
<%= bootstrap_form_for object, html: { id: 'cdl_form' } do |vid| %>
<% if Avalon::Configuration.controlled_digital_lending_enabled? && object.is_a?(Admin::Collection) %>
<div class="card enable-cdl">
<div class="card enable-cdl" data-testid="collection-enable-cdl-card">
<div class="card-header">
<h3 class="card-title">Controlled Digital Lending </h3>
</div>
<div class="card-body">
<div class="mb-3">
<div class="form-check">
<%= label_tag :cdl do %>
<%= check_box_tag :cdl, '1', (cdl) %>
<%= check_box_tag :cdl, '1', (cdl), data: { testid: 'cdl-enable-checkbox' }%>
Enable controlled digital lending for this collection
<% end %>
</div>
</div>
<%= hidden_field_tag :save_field, "cdl" %>
<%= submit_tag "Save Setting", class: "btn btn-primary", form: 'cdl_form' %>
<%= submit_tag "Save Setting", class: "btn btn-primary", form: 'cdl_form', data:{testid: 'cdl-save-setting'} %>
</div>
</div>
<% end %>
<% end %>

<%= bootstrap_form_for object, html: { id: 'lending_form' } do |vid| %>
<% if lending_enabled?(object) %>
<div class="card item-lending-period">
<div class="card item-lending-period" data-testid="collection-item-lending-period-card">
<div class="card-header">
<h3 class="card-title">Item lending period</h3>
</div>
Expand All @@ -51,7 +51,7 @@ Unless required by applicable law or agreed to in writing, software distributed
<label class="col-form-label" for="add_lending_period_days">
<span data-title="Days">Days</span>
</label>
<%= text_field_tag "add_lending_period_days", d ? d : 0, class: 'form-control' %>
<%= text_field_tag "add_lending_period_days", d ? d : 0, class: 'form-control' , data: { testid: 'add-lending-period-days' }%>
</div>
<div class="col-1">
<label class="col-form-label" for="add_lending_period_hours">
Expand All @@ -63,8 +63,8 @@ Unless required by applicable law or agreed to in writing, software distributed
</div>
<%= hidden_field_tag :save_field, "lending_period" %>
<%= hidden_field_tag :overwrite, false %>
<%= submit_tag "Save Setting", class: "btn btn-primary", form: 'lending_form' %>
<%= submit_tag "Apply to All Existing Items", name: "apply_to_existing", class: "btn btn-outline", data: { confirm: I18n.t('access_control.apply_to_all_warning') % [object.media_objects.count] }, form: 'lending_form' %>
<%= submit_tag "Save Setting", class: "btn btn-primary", form: 'lending_form', data:{testid: 'lending-period-save-setting'}%>
<%= submit_tag "Apply to All Existing Items", name: "apply_to_existing", class: "btn btn-outline", data: { confirm: I18n.t('access_control.apply_to_all_warning') % [object.media_objects.count], testid: 'lending-period-apply-to-all' }, form: 'lending_form' %>
</div>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/collections/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Unless required by applicable law or agreed to in writing, software distributed
</div>
<div class="well-vertical-spacer">
<%= link_to('Create An Item', new_media_object_path(collection_id: @collection.id), class: 'btn btn-primary', data: { testid: 'collection-create-item-btn' }) if can? :create, MediaObject %>
<%= link_to('List All Items', search_catalog_path('f[collection_ssim][]' => @collection.name), class: 'btn btn-outline') %>
<%= link_to('List All Items', search_catalog_path('f[collection_ssim][]' => @collection.name), class: 'btn btn-outline', data: { testid: 'collection-list-all-item-btn' }) %>
<%= button_tag('Edit Collection Info', class: 'btn btn-outline', data: {"bs-toggle": "modal", "bs-target": "#new_collection", testid:"collection-edit-collection-info"}) if can? :update, @collection %>
</div>
<div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/bookmarks/merge.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Unless required by applicable law or agreed to in writing, software distributed
<p><%= t('blacklight.merge.confirm') %></p>
<% @documents.each do |d| %>
<div class="form-check">
<%= radio_button_tag :media_object, d.id, class: 'ms-3' %>
<%= radio_button_tag :media_object, d.id, class: 'ms-3', data: { testid: "merge-media-object-#{d.id}" } %>
<%= label_tag "media_object_#{d.id}", "#{d["title_tesi"] || "No title"} - #{d.id}" , class: 'ms-3' %>
<% t('blacklight.merge.insufficient_rights') if cannot? :destroy, SpeedyAF::Proxy::MediaObject.find(d.id) %>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/bookmarks/move.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ Unless required by applicable law or agreed to in writing, software distributed
<div class="alert">
<fieldset>
<p><%= t('blacklight.move.confirm') %></p>
<%= select_tag :target_collection_id, options_from_collection_for_select(@candidates, "id", "name"), style: 'width:100%;' %>
<%= select_tag :target_collection_id, options_from_collection_for_select(@candidates, "id", "name"), style: 'width:100%;' , data: { testid: "bookmark-collection-dropdown" } %>
</fieldset>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary"><%= t('blacklight.move.button') %></button>
<button type="submit" class="btn btn-primary" data-testid = "bookmark-move"><%= t('blacklight.move.button') %></button>
</div>
<% end %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/bookmarks/update_access_control.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Unless required by applicable law or agreed to in writing, software distributed
<%= text_field_tag "add_user_end", nil, placeholder: 'End Date (yyyy-mm-dd)', class: 'form-control date-input access_date', autocomplete: 'off' %>
</div>
<div class="d-flex justify-content-start">
<%= button_tag "Add", name: 'submit_add_user', class:'btn btn-outline', value: 'Add' %>
<%= button_tag "Add", name: 'submit_add_user', class:'btn btn-outline', value: 'Add', data: { testid: 'bookmark-add-user' } %>
<%= button_tag "Remove", name: 'submit_remove_user', class:'btn btn-outline remove_access', value: 'Remove' %>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/media_objects/_access_control.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Unless required by applicable law or agreed to in writing, software distributed
<label class="col-form-label" for="add_lending_period_days">
<span data-title="Days">Days</span>
</label>
<%= text_field_tag "add_lending_period_days", d ? d : 0, class: 'form-control' %>
<%= text_field_tag "add_lending_period_days", d ? d : 0, class: 'form-control', data:{testid: 'media-object-lending-period-days'} %>
</div>
<div class="col-1">
<label class="col-form-label" for="add_lending_period_hours">
Expand Down
2 changes: 1 addition & 1 deletion app/views/media_objects/_destroy_checkout.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Unless required by applicable law or agreed to in writing, software distributed
</div>
<div class="col-5 col-sm-3 col-md-4">
<%= link_to 'Return now', return_checkout_url(current_checkout), class: 'btn btn-outline', method: :patch,
id: "return-btn", data: { checkout_returntime: current_checkout.return_time } %>
id: "return-btn", data: { checkout_returntime: current_checkout.return_time, testid: 'media-object-return-now-btn' } %>
</div>
<div id="check-out-expired" class="modal fade" role="dialog" data-bs-backdrop="static">
<div class="modal-dialog modal-lg">
Expand Down
3 changes: 2 additions & 1 deletion app/views/modules/_autocomplete_input.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ Unless required by applicable law or agreed to in writing, software distributed
id: field_id,
class: "form-control typeahead-input",
data: data,
data: { testid: "autocomplete-user-input" },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be generic?

Suggested change
data: { testid: "autocomplete-user-input" },
data: { testid: "#{for_field}-user-input" },

disabled: disabled,
placeholder: placeholder %>
<ul class='autocomplete_popup' id=<%= "#{for_field}-popup" %>></ul>
<ul class='autocomplete_popup' data-testid="user-popup" id=<%= "#{for_field}-popup" %>></ul>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be generic?

Suggested change
<ul class='autocomplete_popup' data-testid="user-popup" id=<%= "#{for_field}-popup" %>></ul>
<ul class='autocomplete_popup' data-testid="#{for_field}-popup" id=<%= "#{for_field}-popup" %>></ul>

<div class='visually-hidden autocomplete_feedback'id=<%= "#{for_field}-popup-feedback" %>></div>
</auto-complete>
Loading