Skip to content

Commit 094d135

Browse files
authored
Tabs, TabPanel: fix non-stable TestCafe tests (#30183) (#30207)
1 parent 5513560 commit 094d135

File tree

102 files changed

+56
-53
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+56
-53
lines changed

e2e/testcafe-devextreme/tests/navigation/tabPanel/common.ts

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
22
import {
3-
// Selector,
3+
Selector,
44
ClientFunction,
55
} from 'testcafe';
66
import TabPanel from 'devextreme-testcafe-models/tabPanel';
@@ -10,8 +10,8 @@ import url from '../../../helpers/getPageUrl';
1010
import { createWidget } from '../../../helpers/createWidget';
1111
import { setAttribute, appendElementTo, insertStylesheetRulesToPage } from '../../../helpers/domUtils';
1212

13-
// const TABS_RIGHT_NAV_BUTTON_CLASS = 'dx-tabs-nav-button-right';
14-
// const TABS_LEFT_NAV_BUTTON_CLASS = 'dx-tabs-nav-button-left';
13+
const TABS_RIGHT_NAV_BUTTON_CLASS = 'dx-tabs-nav-button-right';
14+
const TABS_LEFT_NAV_BUTTON_CLASS = 'dx-tabs-nav-button-left';
1515

1616
fixture.disablePageReloads`TabPanel_common`
1717
.page(url(__dirname, '../../container.html'));
@@ -46,8 +46,8 @@ test('TabPanel borders with scrolling', async (t) => {
4646

4747
const tabPanelOptions = {
4848
dataSource,
49-
itemTemplate: (itemData, itemIndex, itemElement) => {
50-
($('<div>').css('marginTop', 10) as any)
49+
itemTemplate: (_, __, itemElement) => {
50+
($('<div>').css('marginTop', '10px') as any)
5151
.dxTabs({
5252
items: [
5353
{
@@ -214,8 +214,8 @@ test('TabPanel borders without scrolling', async (t) => {
214214

215215
const tabPanelOptions = {
216216
dataSource,
217-
itemTemplate: (itemData, itemIndex, itemElement) => {
218-
($('<div>').css('marginTop', 10) as any)
217+
itemTemplate: (_, __, itemElement) => {
218+
($('<div>').css('marginTop', '10px') as any)
219219
.dxTabs({
220220
items: [
221221
{
@@ -254,6 +254,11 @@ test('TabPanel borders without scrolling', async (t) => {
254254
const tabPanel = new TabPanel('#container');
255255
const direction = rtlEnabled ? 'left' : 'right';
256256

257+
await t.click('body', {
258+
offsetX: -10,
259+
offsetY: -10,
260+
});
261+
257262
await testScreenshot(t, takeScreenshot, `TabPanel without focus,rtl=${rtlEnabled}.png`, { element: '#container' });
258263

259264
await t.pressKey('tab');
@@ -264,29 +269,25 @@ test('TabPanel borders without scrolling', async (t) => {
264269

265270
await t.pressKey(direction);
266271

267-
// const thirdItem = tabPanel.getItem(2);
268272
const firstItem = tabPanel.getItem(0);
269273

270274
await t.dispatchEvent(firstItem.element, 'mousedown');
271275
await testScreenshot(t, takeScreenshot, `TabPanel 1 item active,rtl=${rtlEnabled}.png`, { element: '#container' });
276+
await t.dispatchEvent(firstItem.element, 'mouseup');
272277

273-
// TODO: this test is unstable
274-
// await t
275-
// .dispatchEvent(thirdItem.element, 'mouseup')
276-
// .click(Selector('body'), { offsetY: -50 })
277-
// .hover(firstItem.element);
278+
await t.click('body', {
279+
offsetX: -10,
280+
offsetY: -10,
281+
});
278282

279-
// eslint-disable-next-line max-len
280-
// await testScreenshot(t, takeScreenshot, `TabPanel 1 item hovered,rtl=${rtlEnabled}.png`, { element: '#container' });
283+
await t.hover(firstItem.element);
284+
await testScreenshot(t, takeScreenshot, `TabPanel 1 item hovered,rtl=${rtlEnabled}.png`, { element: '#container' });
281285

282-
// TODO: this test is unstable
283-
// await t
284-
// .click(Selector('body'), { offsetY: -50 })
285-
// eslint-disable-next-line max-len
286-
// .hover(Selector(`.${rtlEnabled ? TABS_LEFT_NAV_BUTTON_CLASS : TABS_RIGHT_NAV_BUTTON_CLASS}`));
286+
await tabPanel.option('showNavButtons', true);
287287

288-
// eslint-disable-next-line max-len
289-
// await testScreenshot(t, takeScreenshot, `TabPanel right navigation button hovered, rtl=${rtlEnabled}.png`, { element: '#container' });
288+
const navigationButton = Selector(`.${rtlEnabled ? TABS_LEFT_NAV_BUTTON_CLASS : TABS_RIGHT_NAV_BUTTON_CLASS}`);
289+
await t.hover(navigationButton);
290+
await testScreenshot(t, takeScreenshot, `TabPanel ${direction} navigation button hovered, rtl=${rtlEnabled}.png`, { element: '#container' });
290291

291292
await t
292293
.expect(compareResults.isValid())
@@ -324,7 +325,6 @@ test('TabPanel borders without scrolling', async (t) => {
324325
dataSource,
325326
height: 120,
326327
width: 450,
327-
showNavButtons: true,
328328
rtlEnabled,
329329
// prevent firing dxinactive event for to avoid failing test
330330
itemHoldTimeout: 5000,
@@ -465,6 +465,11 @@ test('TabPanel borders without scrolling', async (t) => {
465465

466466
const tabPanel = new TabPanel('#container');
467467

468+
await t.click('body', {
469+
offsetX: -10,
470+
offsetY: -10,
471+
});
472+
468473
await testScreenshot(t, takeScreenshot, `TabPanel without focus,tabsPosition=${tabsPosition}.png`, { element: '#container' });
469474

470475
await t.pressKey('tab');
@@ -475,19 +480,19 @@ test('TabPanel borders without scrolling', async (t) => {
475480

476481
await t.pressKey('right');
477482

478-
// const thirdItem = tabPanel.getItem(2);
479483
const firstItem = tabPanel.getItem(0);
480484

481485
await t.dispatchEvent(firstItem.element, 'mousedown');
482486
await testScreenshot(t, takeScreenshot, `TabPanel 1 item active,tabsPosition=${tabsPosition}.png`, { element: '#container' });
483-
// TODO: this test is unstable
484-
// await t
485-
// .dispatchEvent(thirdItem.element, 'mouseup')
486-
// .click(Selector('body'), { offsetY: -50 })
487-
// .hover(firstItem.element);
488-
489-
// eslint-disable-next-line max-len
490-
// await testScreenshot(t, takeScreenshot, `TabPanel 1 item hovered,tabsPosition=${tabsPosition}.png`, { element: '#container' });
487+
await t.dispatchEvent(firstItem.element, 'mouseup');
488+
489+
await t.click('body', {
490+
offsetX: -10,
491+
offsetY: -10,
492+
});
493+
494+
await t.hover(firstItem.element);
495+
await testScreenshot(t, takeScreenshot, `TabPanel 1 item hovered,tabsPosition=${tabsPosition}.png`, { element: '#container' });
491496

492497
await t
493498
.expect(compareResults.isValid())
581 Bytes
1.88 KB
365 Bytes
665 Bytes
1.92 KB
581 Bytes
580 Bytes
1.63 KB
846 Bytes

0 commit comments

Comments
 (0)