Skip to content

Commit eb55e52

Browse files
GulsahKoseeszkadev
authored andcommitted
Add cypress test for clicking image in navigation bar.
This test is written to test 1b878b2 Signed-off-by: Gülşah Köse <gulsah.kose@collabora.com> Change-Id: I0d85a40553f24ac4e586d12a0df421dbe3200a1a
1 parent c7c80cf commit eb55e52

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

cypress_test/integration_tests/desktop/writer/navigator_spec.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,35 @@ describe(['tagdesktop'], 'Scroll through document, modify heading', function() {
9797
desktopHelper.assertScrollbarPosition('vertical', 325, 360);
9898
});
9999

100+
it('Jump to image when cursor not visible', function() {
101+
// Regression test: when the text cursor is hidden, double-clicking
102+
// an image in the navigator must still scroll the viewport to it.
103+
// assertVisiblePage alone is not sufficient as #StatePageNumber
104+
// reflects the selection's page (which core updates regardless of
105+
// whether the viewport scrolls), so check the actual scrollbar.
106+
expandSection('Images');
107+
108+
cy.cGet('#navigator-dock-wrapper').scrollTo(0,0, { ensureScrollable: false });
109+
110+
// Jump to a heading so a cursor exists at a known position.
111+
cy.cGet('#contenttree').contains('.jsdialog.sidebar.ui-treeview-cell-text', 'Feedback').dblclick();
112+
desktopHelper.assertVisiblePage(2, 2, 8);
113+
desktopHelper.assertScrollbarPosition('vertical', 45, 75);
114+
115+
// Scroll document to the top so the text cursor is no longer visible.
116+
desktopHelper.scrollWriterDocumentToTop();
117+
desktopHelper.updateFollowingUsers();
118+
desktopHelper.assertScrollbarPosition('vertical', 0, 10);
119+
120+
// Double-click an image on a different page (graphics10 is on page 5).
121+
// Without the fix, _onUpdateCursor returns early because the text
122+
// cursor is invisible, so the viewport never scrolls and the
123+
// scrollbar stays near 0.
124+
cy.cGet('#contenttree').contains('.jsdialog.sidebar.ui-treeview-cell-text', 'graphics10').dblclick();
125+
desktopHelper.assertVisiblePage(5, 5, 8);
126+
desktopHelper.assertScrollbarPosition('vertical', 100, 400);
127+
});
128+
100129
it.skip('Jump to element. Document -> Navigator', function() {
101130
// Move the cursor into elements in Document, and check
102131
// if navigator contentTree scroll to the element and select that,

0 commit comments

Comments
 (0)