Skip to content

Commit

Permalink
Cypress: Status bar scrolling: Allow multiple clicks, wait for anim
Browse files Browse the repository at this point in the history
Better to keep clicking until the indicator is visible to make sure we
have arrived to the edge and better to wait for animation to end
before further checks or clicks. With this we don't need to check
twice the zoomin visibility.

Before this commit I have noticed that
- we were not waiting for the animation to end -> so sometimes the
test would fail
- and that the test was stopping the clicking even if there was more
to click until the indicator disappears

This is easy to test if we update the px step from 300 to 30 in Util.ScrollableBar.ts, for example:

modified   browser/src/control/jsdialog/Util.ScrollableBar.ts
@@ -24,16 +24,16 @@ function createScrollButtons(parent: Element, scrollable: Element) {
 	const right = L.DomUtil.create('div', 'ui-scroll-right', parent);

 	JSDialog.AddOnClick(left, () => {
-		const scroll = $(scrollable).scrollLeft() - 300;
-		$(scrollable).animate({ scrollLeft: scroll }, 300);
+		const scroll = $(scrollable).scrollLeft() - 30;
+		$(scrollable).animate({ scrollLeft: scroll }, 30);
 		setTimeout(function () {
 			JSDialog.RefreshScrollables();
 		}, 350);
 	});

 	JSDialog.AddOnClick(right, () => {
-		const scroll = $(scrollable).scrollLeft() + 300;
-		$(scrollable).animate({ scrollLeft: scroll }, 300);
+		const scroll = $(scrollable).scrollLeft() + 30;
+		$(scrollable).animate({ scrollLeft: scroll }, 30);

Signed-off-by: Pedro Pinto Silva <pedro.silva@collabora.com>
Change-Id: I10b0486d58753d6b8ed714629fa171caafa557af
  • Loading branch information
pedropintosilva authored and Minion3665 committed Dec 2, 2024
1 parent addf119 commit 0f1bae6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cypress_test/integration_tests/common/desktop_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,20 @@ function shouldHaveZoomLevel(zoomLevel) {
function makeZoomItemsVisible() {
cy.log('>> makeZoomItemsVisible - start');

cy.cGet('#toolbar-down #zoomin')
.then(function(zoomInItem) {
if (!Cypress.dom.isVisible(zoomInItem)) {
cy.cGet('#toolbar-down .ui-scroll-right').click();
const scrollRight = () => {
cy.cGet('#toolbar-down .ui-scroll-right').then($scrollRightButton => {
if ($scrollRightButton.is(':visible')) {
// Wrap .ui-scroll-right so we can continue executing commands
cy.wrap($scrollRightButton).click();
// Wait the same ms as in Util.ScrollableBar.ts timeout
cy.wait(350);
// Scroll again if $scrollRightButton is visible
scrollRight();
}
});
};

scrollRight();
cy.cGet('#toolbar-down #zoomin').should('be.visible');

cy.log('<< makeZoomItemsVisible - end');
Expand Down

0 comments on commit 0f1bae6

Please sign in to comment.