Skip to content

Commit

Permalink
Merge branch 'release/13.1' into task/51538-use-ensure_connection-to-…
Browse files Browse the repository at this point in the history
…open-storage-from-files-tab
  • Loading branch information
ba1ash authored Dec 18, 2023
2 parents b8f1101 + 2223865 commit e6f4381
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 27 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ group :test do
gem 'capybara', '~> 3.39.0'
gem 'capybara-screenshot', '~> 1.0.17'
gem 'cuprite', '~> 0.15.0'
gem 'selenium-webdriver', '~> 4.15.0'
gem 'selenium-devtools'
gem 'selenium-webdriver', '~> 4.15'
gem 'capybara_accessible_selectors', git: 'https://github.com/citizensadvice/capybara_accessible_selectors', branch: 'main'

gem 'fuubar', '~> 2.5.0'
Expand Down
7 changes: 5 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,9 @@ GEM
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
secure_headers (6.5.0)
selenium-webdriver (4.15.0)
selenium-devtools (0.120.0)
selenium-webdriver (~> 4.2)
selenium-webdriver (4.16.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
Expand Down Expand Up @@ -1210,7 +1212,8 @@ DEPENDENCIES
rubytree (~> 2.0.0)
sanitize (~> 6.1.0)
secure_headers (~> 6.5.0)
selenium-webdriver (~> 4.15.0)
selenium-devtools
selenium-webdriver (~> 4.15)
semantic (~> 1.6.1)
shoulda-context (~> 2.0)
shoulda-matchers (~> 5.0)
Expand Down
4 changes: 2 additions & 2 deletions docker/ci/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ setup_tests() {
run_background backend_stuff
run_background frontend_stuff
# pre-cache browsers and their drivers binaries
run_background $(bundle show selenium)/bin/linux/selenium-manager --browser chrome --debug
run_background $(bundle show selenium)/bin/linux/selenium-manager --browser firefox --debug
run_background $(bundle show selenium-webdriver)/bin/linux/selenium-manager --browser chrome --debug
run_background $(bundle show selenium-webdriver)/bin/linux/selenium-manager --browser firefox --debug
wait_for_background
}

Expand Down
6 changes: 6 additions & 0 deletions frontend/src/app/core/setup/globals/global-listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ export function initializeGlobalListeners():void {
return;
}

// Avoid opening new tab when clicking links while editing in ckeditor
if (linkElement.classList.contains('ck-link_selected')) {
evt.preventDefault();
return;
}

const callbacks = [
openExternalLinksInNewTab,
performAnchorHijacking,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
class="button button_no-margin -transparent spot-modal--header-close-button"
[attr.aria-label]="text.button_close"
(click)="closeMe($event)"
data-test-selector="op-share-wp-modal--close-icon"
>
<svg
x-icon
Expand All @@ -34,15 +35,4 @@
</op-content-loader>
</turbo-frame>
</div>
<div class="spot-action-bar">
<div class="spot-action-bar--right">
<button
class="button button_no-margin spot-modal--cancel-button spot-action-bar--action"
data-test-selector="confirmation-modal--cancel"
(click)="closeMe($event)"
[textContent]="text.button_close"
[attr.title]="text.button_close"
></button>
</div>
</div>
</div>
10 changes: 10 additions & 0 deletions modules/bim/spec/features/bcf/api_authorization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,18 @@ def oauth_path(client_id)

logout

# A basic auth alert is displayed asking to enter name and password Register
# some basic auth credentials
# - A non-matching url is used so that capybara will issue a CancelAuth
# instead of trying to authenticate
# - The register method is not recognized by selenium-webdriver with Chrome
# 120 with old headless
if page.driver.browser.respond_to?(:register)
page.driver.browser.register(username: 'foo', password: 'bar', uri: /does_not_match/)
end
# While not being logged in and without a token, the api cannot be accessed
visit("/api/bcf/2.1/projects/#{project.id}")
# Cancel button of basic auth should have been chosen now
expect(page)
.to have_content(JSON.dump({ message: "You need to be authenticated to access this resource." }))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<%=
content_tag("turbo-frame", id: "edit-participants-dialog-frame") do
component_wrapper do
component_wrapper(class: 'Overlay-form') do
primer_form_with(
model: @meeting,
method: :put,
url: update_participants_meeting_path(@meeting)
url: update_participants_meeting_path(@meeting),
class: 'Overlay-form'
) do |f|
component_collection do |collection|
collection.with_component(Primer::Alpha::Dialog::Body.new(style: "max-height: 460px;", my: 3)) do
collection.with_component(Primer::Alpha::Dialog::Body.new(my: 3)) do
flex_layout(mt: 3) do |form_container|
form_container.with_row do
flex_layout(justify_content: :flex_end) do |header|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
id: "#{@id}-frame",
loading: :lazy,
src: @src,
class: 'Overlay-form',
data: { 'op-turbo-op-primer-async-dialog-target': "frameElement" }) do
flex_layout(justify_content: :center) do |flex|
flex.with_column(my: 5) do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<%=
content_tag("turbo-frame", id: "add-work-package-to-meeting-dialog-frame") do
component_wrapper do
component_wrapper(class: 'Overlay-form') do
primer_form_with(
model: @meeting_agenda_item,
method: :post,
url: work_package_meeting_agenda_items_path(@work_package)
url: work_package_meeting_agenda_items_path(@work_package),
class: 'Overlay-form'
) do |f|
component_collection do |collection|
collection.with_component(Primer::Alpha::Dialog::Body.new(test_selector: 'op-add-work-package-to-meeting-dialog-body')) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
require_relative '../../support/pages/my/page'

RSpec.describe 'My spent time widget with a negative time zone', :js,
driver: :chrome_headless_new,
with_settings: { start_of_week: 1 } do
let(:beginning_of_week) { monday }
let(:end_of_week) { sunday }
Expand Down
17 changes: 15 additions & 2 deletions spec/support/browsers/chrome.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# rubocop:disable Metrics/PerceivedComplexity
def register_chrome(language, name: :"chrome_#{language}", override_time_zone: nil)
def register_chrome(language, name: :"chrome_#{language}", headless: 'old', override_time_zone: nil)
Capybara.register_driver name do |app|
options = Selenium::WebDriver::Chrome::Options.new

Expand All @@ -12,7 +12,7 @@ def register_chrome(language, name: :"chrome_#{language}", override_time_zone: n
end
else
options.add_argument('--window-size=1920,1080')
options.add_argument('--headless')
options.add_argument("--headless=#{headless}")
end

options.add_argument('--no-sandbox')
Expand Down Expand Up @@ -96,6 +96,19 @@ def register_chrome(language, name: :"chrome_#{language}", override_time_zone: n
end
end

# Register Chrome with new headless implementation
#
# Our tests are not that stable with the new headless mode, but since
# Chrome 120 the old headless mode has browser name
# "chrome-headless-shell". This name is not recognized by the current
# selenium-webdriver and so some extensions like `execute_cdp` are
# missing. This wil be fixed in next selenium-webdriver version. See
# https://github.com/SeleniumHQ/selenium/pull/13271 for more information.
#
# In the meantime, registering a :chrome_headless_new driver which uses the
# `headless=new` flag for tests that need it.
register_chrome 'en', name: :chrome_headless_new, headless: 'new'

# Register mocking proxy driver
register_chrome 'en', name: :chrome_billy do |options|
options.add_argument("proxy-server=#{Billy.proxy.host}:#{Billy.proxy.port}")
Expand Down
2 changes: 1 addition & 1 deletion spec/support/components/work_packages/share_modal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def filter(filter_name, value)

def close
within_modal do
click_button 'Close'
page.find("[data-test-selector='op-share-wp-modal--close-icon']").click
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared/drag_and_drop_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def drag_n_drop_element(from:, to:, offset_x: nil, offset_y: nil)
end

def drag_by_pixel(element:, by_x:, by_y:)
scroll_to_element(element)
scroll_to_element(element, block: :center)

page
.driver
Expand Down
9 changes: 7 additions & 2 deletions spec/support/shared/scroll_into_view_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@
#++

# Scrolls a native element into view using JS
def scroll_to_element(element)
# @param element [Capybara::Node::Element] the element to scroll into view
# @param block [Symbol] (optional) Defines vertical alignment.
# One of `:start`, `:center`, `:end`, or `:nearest`. Defaults to `:start`.
# @param inline [Symbol] (optional) Defines horizontal alignment.
# One of `:start`, `:center`, `:end`, or `:nearest`. Defaults to `:nearest`..
def scroll_to_element(element, block: :start, inline: :nearest)
script = <<-JS
arguments[0].scrollIntoView(true);
arguments[0].scrollIntoView({block: "#{block}", inline: "#{inline}"});
JS
if using_cuprite?
page.driver.execute_script(script, element.native)
Expand Down

0 comments on commit e6f4381

Please sign in to comment.