Skip to content

Commit 0d28540

Browse files
committed
test(lazy-sheet): adjust for Firefox
Also: - Improve comment in tobago-sheet.ts. - Intro.test.js was failing in both Firefox and Webkit.
1 parent c98f9c2 commit 0d28540

File tree

6 files changed

+34
-9
lines changed

6 files changed

+34
-9
lines changed

tobago-example/tobago-example-demo/src/main/webapp/content/000-intro/Intro.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {JasmineTestTool} from "/tobago/test/tobago-test-tool.js";
2020

2121
it("First section title is 'Intro'", function (done) {
2222
const titleOfFirstSectionHeader = querySelectorFn("tobago-section h1");
23-
const introLinkFn = elementByIdFn("page:navigator:nav:1:cmd");
23+
const introLinkFn = elementByIdFn("page:navigation:nav:1:cmd");
2424

2525
const test = new JasmineTestTool(done);
2626
test.setup(() => titleOfFirstSectionHeader().textContent.trim() === "Intro", null, "click", introLinkFn);

tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/83-lazy-columnPanel/Lazy_ColumnPanel.test.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import {elementByIdFn, querySelectorFn} from "/script/tobago-test.js";
18+
import {elementByIdFn, isFirefox, querySelectorFn} from "/script/tobago-test.js";
1919
import {JasmineTestTool} from "/tobago/test/tobago-test-tool.js";
2020

2121
it("initial load", function (done) {
@@ -37,7 +37,14 @@ it("focus row index 200 and scroll up", function (done) {
3737
test.wait(() => Date.now() - timestamp > 200);
3838
test.do(() => focusRowIndex(200));
3939
test.wait(() => isLoaded(200));
40-
test.do(() => expect(isLoaded(199)).toBeFalse());
40+
41+
if (isFirefox()) {
42+
test.wait(() => isLoaded(199));
43+
test.do(() => expect(isLoaded(189)).toBeFalse());
44+
test.do(() => expect(isLoaded(190, 199)).toBeTrue());
45+
} else {
46+
test.do(() => expect(isLoaded(199)).toBeFalse());
47+
}
4148
test.do(() => expect(isLoaded(200, 209)).toBeTrue());
4249
test.do(() => expect(isLoaded(210)).toBeFalse());
4350

@@ -59,15 +66,27 @@ it("focus row index 300 and scroll down", function (done) {
5966
test.wait(() => Date.now() - timestamp > 200);
6067
test.do(() => focusRowIndex(300));
6168
test.wait(() => isLoaded(300));
62-
test.do(() => expect(isLoaded(299)).toBeFalse());
69+
70+
if (isFirefox()) {
71+
test.wait(() => isLoaded(299));
72+
test.do(() => expect(isLoaded(289)).toBeFalse());
73+
test.do(() => expect(isLoaded(290, 299)).toBeTrue());
74+
} else {
75+
test.do(() => expect(isLoaded(299)).toBeFalse());
76+
}
6377
test.do(() => expect(isLoaded(300, 309)).toBeTrue());
6478
test.do(() => expect(isLoaded(310)).toBeFalse());
6579

6680
test.do(() => timestamp = Date.now());
6781
test.wait(() => Date.now() - timestamp > 200);
6882
test.do(() => focusRowIndex(301));
6983
test.wait(() => isLoaded(310));
70-
test.do(() => expect(isLoaded(299)).toBeFalse());
84+
if (isFirefox()) {
85+
test.do(() => expect(isLoaded(289)).toBeFalse());
86+
test.do(() => expect(isLoaded(290, 299)).toBeTrue());
87+
} else {
88+
test.do(() => expect(isLoaded(299)).toBeFalse());
89+
}
7190
test.do(() => expect(isLoaded(300, 319)).toBeTrue());
7291
test.do(() => expect(isLoaded(320)).toBeFalse());
7392
test.start();

tobago-example/tobago-example-demo/src/main/webapp/content/900-test/3000-sheet/84-lazy-selectable-use-case/lazy-selectable-use-case.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ it("TOBAGO-2349: Lazy sheet: tobago-behavior not initialized", function (done) {
4040
test.setup(() => name().value === "Sun", null, "click", reset);
4141

4242
test.do(() => focusRowIndex(18));
43+
test.wait(() => isLoaded(18, 67));
4344
test.do(() => expect(isLoaded(18, 67)).toBeTrue());
4445
test.do(() => timestamp = Number(timestampElement().textContent));
4546
test.event("click", ajaxButton, () => Number(timestampElement().textContent) > timestamp);

tobago-example/tobago-example-demo/src/main/webapp/script/tobago-test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ function activeElementFn() {
5656
return document.getElementById("page:testframe").contentWindow.document.activeElement;
5757
}
5858

59-
export {elementByIdFn, querySelectorFn, querySelectorAllFn, activeElementFn};
59+
function isFirefox() {
60+
return navigator.userAgent.toLowerCase().includes('firefox');
61+
}
62+
63+
export {elementByIdFn, querySelectorFn, querySelectorAllFn, activeElementFn, isFirefox};
6064

6165
beforeEach(function (done) {
6266
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5 * 60 * 1000; //5 minutes

tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tobago-theme/tobago-theme-standard/src/main/ts/tobago-sheet.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ export class Sheet extends HTMLElement {
233233
const firstVisibleRow
234234
= this.tableBody.querySelector<HTMLTableRowElement>(`tr[row-index='${lazyScrollPosition[0]}']`);
235235
if (firstVisibleRow) {
236-
this.sheetBody.scrollTop
237-
= firstVisibleRow.offsetTop + lazyScrollPosition[1]; //triggers scroll event -> lazyCheck()
236+
this.sheetBody.scrollTop = firstVisibleRow.offsetTop + lazyScrollPosition[1];
237+
//in Firefox setting "scrollTop" triggers scroll event -> lazyCheck()
238238
}
239239
}
240240

@@ -562,6 +562,7 @@ export class Sheet extends HTMLElement {
562562
= this.tableBody.querySelector<HTMLTableRowElement>(`tr[row-index='${lazyScrollPosition[0]}']`);
563563
if (firstRow) {
564564
this.sheetBody.scrollTop = firstRow.offsetTop + lazyScrollPosition[1];
565+
//in Firefox setting "scrollTop" triggers scroll event -> lazyCheck()
565566
}
566567

567568
this.lazyActive = false;

0 commit comments

Comments
 (0)