Skip to content

Commit

Permalink
TEMP: Remove Turbolinks to test accessibility on click_link
Browse files Browse the repository at this point in the history
  • Loading branch information
javierm committed Apr 26, 2024
1 parent 362c728 commit 82063bd
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 112 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"annotator": "readonly",
"c3": "readonly",
"CKEDITOR": "readonly",
"L": "readonly",
"Turbolinks": "readonly"
"L": "readonly"
},
"parserOptions": {
"ecmaVersion": 5
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ gem "sitemap_generator", "~> 6.3.0"
gem "social-share-button", "~> 1.2.4"
gem "sprockets", "~> 4.2.1"
gem "sprockets-rails", "~> 3.4.2", require: "sprockets/railtie"
gem "turbolinks", "~> 5.2.1"
gem "turnout", "~> 2.5.0"
gem "uglifier", "~> 4.2.0"
gem "uuidtools", "~> 2.2.0"
Expand Down
4 changes: 0 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,6 @@ GEM
timeout (0.4.1)
tomlrb (2.0.3)
ttfunk (1.7.0)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
turnout (2.5.0)
i18n (>= 0.7, < 2)
rack (>= 1.3, < 3)
Expand Down Expand Up @@ -806,7 +803,6 @@ DEPENDENCIES
spring (~> 4.1.3)
sprockets (~> 4.2.1)
sprockets-rails (~> 3.4.2)
turbolinks (~> 5.2.1)
turnout (~> 2.5.0)
uglifier (~> 4.2.0)
uuidtools (~> 2.2.0)
Expand Down
16 changes: 1 addition & 15 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
//= require blueimp-file-upload/js/jquery.iframe-transport
//= require blueimp-file-upload/js/jquery.fileupload
//= require foundation-sites
//= require turbolinks
//= require turbolinks_anchors
//= require ckeditor/loader
//= require_directory ./ckeditor
//= require social-share-button
Expand Down Expand Up @@ -183,16 +181,4 @@ var initialize_modules = function() {
App.AuthenticityTokenRefresh.initialize();
};

var destroy_non_idempotent_modules = function() {
"use strict";

App.ColumnsSelector.destroy();
App.Datepicker.destroy();
App.HTMLEditor.destroy();
App.LegislationAnnotatable.destroy();
App.Map.destroy();
App.SocialShare.destroy();
};

$(document).on("turbolinks:load", initialize_modules);
$(document).on("turbolinks:before-cache", destroy_non_idempotent_modules);
$(document).ready(initialize_modules);
3 changes: 0 additions & 3 deletions app/assets/javascripts/columns_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@
$(".column-selectable").on("inserted", function() {
App.ColumnsSelector.initColumns();
});
},
destroy: function() {
$("#js-columns-selector-wrapper").children(":not(#column_selector_item_template)").remove();
}
};
}).call(this);
26 changes: 0 additions & 26 deletions app/assets/javascripts/datepicker.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
// Based on code by Javan Makhmali
// https://github.com/turbolinks/turbolinks/issues/253#issuecomment-289101048
// The jQuery UI date picker widget appends a shared element to the
// body which it expects will never leave the page, but Turbolinks
// removes that shared element when it rerenders. We satisfy that
// expectation by removing the shared element from the page before
// Turbolinks caches the page, and appending it again before
// Turbolinks swaps the new body in during rendering.
//
// Additionally, returning to the cached version of a page that
// previously had date picker elements would result in those date
// pickers not being initialized again. We fix this issue by finding
// all initialized date picker inputs on the page and calling the
// date picker's destroy method before Turbolinks caches the page.
(function() {
"use strict";
App.Datepicker = {
Expand Down Expand Up @@ -40,14 +26,6 @@
$.datepicker.setDefaults($.datepicker.regional[locale]);
$.datepicker.setDefaults({ dateFormat: "dd/mm/yy" });
},
destroy: function() {
$.datepicker.dpDiv.remove();

document.querySelectorAll("input.hasDatepicker").forEach(function(input) {
$(input).datepicker("hide");
$(input).datepicker("destroy");
});
},
browser_supports_date_field: function() {
return App.Datepicker.browser_supports_field_with_type("date");
},
Expand All @@ -65,8 +43,4 @@
return value.split("T")[0];
}
};

document.addEventListener("turbolinks:before-render", function(event) {
$.datepicker.dpDiv.appendTo(event.data.newBody);
});
}).call(this);
7 changes: 0 additions & 7 deletions app/assets/javascripts/foundation_extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
App.FoundationExtras = {
initialize: function() {
$(document).foundation();
},
destroy: function() {
if ($(".sticky").length > 0) {
$(".sticky").foundation("_destroy");
}
}
};

$(document).on("turbolinks:before-visit", App.FoundationExtras.destroy);
}).call(this);
5 changes: 0 additions & 5 deletions app/assets/javascripts/html_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
CKEDITOR.replace(this.name, { language: $("html").attr("lang") });
}
});
},
destroy: function() {
for (var name in CKEDITOR.instances) {
CKEDITOR.instances[name].destroy();
}
}
};
}).call(this);
5 changes: 0 additions & 5 deletions app/assets/javascripts/legislation_annotatable.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/assets/javascripts/legislation_draft_versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
},
};

$(document).on("turbolinks:before-visit", App.LegislationDraftVersions.checkChanges);
// $(document).on("turbolinks:before-visit", App.LegislationDraftVersions.checkChanges);
}).call(this);
3 changes: 0 additions & 3 deletions app/assets/javascripts/social_share.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
$(".social-share-button a").each(function() {
$(this).append("<span class='show-for-sr'>" + ($(this).data("site").replace(/_app$/, "")) + "</span>");
});
},
destroy: function() {
$(".social-share-button a .show-for-sr").remove();
}
};
}).call(this);
3 changes: 1 addition & 2 deletions app/assets/javascripts/stat_graphs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ var initialize_stats_modules = function() {
App.Stats.initialize();
};

$(document).on("turbolinks:load", initialize_stats_modules);
$(document).on("ajax:complete", initialize_stats_modules);
$(document).ready(initialize_stats_modules);
15 changes: 0 additions & 15 deletions app/assets/javascripts/turbolinks_anchors.js

This file was deleted.

10 changes: 10 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ def visit(url, ...)
expect(page).to have_css "main#main"
end
end

alias_method :original_click_link, :click_link

def click_link(url, ...)
original_click_link(url, ...)

unless driver.name == :rack_test
expect(page).to be_axe_clean.checking_only :label
end
end
end
end

Expand Down
46 changes: 23 additions & 23 deletions spec/system/admin/legislation/draft_versions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,39 +93,39 @@
edit_admin_legislation_process_draft_version_path(version.process, version)
end

scenario "asks for confimation when the content is modified" do
visit path
fill_in_markdown_editor "Text", with: "Version 1b"
# scenario "asks for confimation when the content is modified" do
# visit path
# fill_in_markdown_editor "Text", with: "Version 1b"

expect(page).to have_content "You've edited the text"
# expect(page).to have_content "You've edited the text"

dismiss_confirm(prompt) do
click_link "Proposals", match: :first
end
# dismiss_confirm(prompt) do
# click_link "Proposals", match: :first
# end

expect(page).to have_current_path(path)
end
# expect(page).to have_current_path(path)
# end

scenario "asks for confimation after the page is restored from browser history" do
visit path
fill_in_markdown_editor "Text", with: "Version 1b"
# scenario "asks for confimation after the page is restored from browser history" do
# visit path
# fill_in_markdown_editor "Text", with: "Version 1b"

accept_confirm(prompt) do
click_link "Proposals", match: :first
end
# accept_confirm(prompt) do
# click_link "Proposals", match: :first
# end

expect(page).to have_css("h2", text: "Proposals")
# expect(page).to have_css("h2", text: "Proposals")

go_back
# go_back

expect(page).to have_content version.process.title
# expect(page).to have_content version.process.title

accept_confirm(prompt) do
click_link "Proposals", match: :first
end
# accept_confirm(prompt) do
# click_link "Proposals", match: :first
# end

expect(page).to have_css("h2", text: "Proposals")
end
# expect(page).to have_css("h2", text: "Proposals")
# end

scenario "does not ask for confirmation when restoring the original content" do
visit path
Expand Down

0 comments on commit 82063bd

Please sign in to comment.