Skip to content

Commit bdabe78

Browse files
marker-daomarker dao ®
andauthored
QUnit tests: ensure compatibility with Fluent and drop Generic theme testing (Editors) (#32000) (#32035)
Co-authored-by: marker dao ® <[email protected]>
1 parent 1fe2eb9 commit bdabe78

File tree

6 files changed

+63
-46
lines changed

6 files changed

+63
-46
lines changed

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/autocomplete.tests.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { isRenderer } from 'core/utils/type';
1212
import { normalizeKeyName } from 'common/core/events/utils/index';
1313
import { getHeight, getOuterHeight } from 'core/utils/size';
1414

15-
import 'generic_light.css!';
15+
import 'fluent_blue_light.css!';
1616
import 'ui/select_box';
1717

1818
QUnit.testStart(() => {
@@ -55,6 +55,8 @@ const KEY_ENTER = 'Enter';
5555
const KEY_ESC = 'Escape';
5656
const KEY_TAB = 'Tab';
5757

58+
const BORDER_WIDTH = 1;
59+
5860
QUnit.module('dxAutocomplete', {
5961
beforeEach: function() {
6062
fx.off = true;
@@ -180,9 +182,11 @@ QUnit.module('dxAutocomplete', {
180182
autocomplete.option('height', initialHeight + increment);
181183
autocomplete.option('width', initialWidth + increment);
182184

185+
const overlayContentWidth = $overlayContent.width() - BORDER_WIDTH * 2;
186+
183187
const dHeight = $autocomplete.height() - initialHeight;
184188
const dWidth = $autocomplete.width() - initialWidth;
185-
const dPopupWidth = $overlayContent.width() - initialPopupWidth;
189+
const dPopupWidth = overlayContentWidth - initialPopupWidth;
186190

187191
assert.notEqual(dHeight, 0, 'Height could be changed');
188192
assert.notEqual(dWidth, 0, 'Width could be changed');

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dateRangeBox.tests.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import keyboardMock from '../../helpers/keyboardMock.js';
99
import localization from 'localization';
1010

1111
import 'ui/validator';
12-
import 'generic_light.css!';
12+
import 'fluent_blue_light.css!';
1313

1414
QUnit.testStart(() => {
1515
const markup =
@@ -166,7 +166,7 @@ QUnit.module('DateRangeBox Initialization', moduleConfig, () => {
166166
invalidStartDateMessage: 'Start value must be a date',
167167
invalidEndDateMessage: 'End value must be a date',
168168
isValid: true,
169-
labelMode: 'static',
169+
labelMode: 'outside',
170170
max: undefined,
171171
min: undefined,
172172
onChange: null,
@@ -225,7 +225,7 @@ QUnit.module('DateRangeBox Initialization', moduleConfig, () => {
225225
inputAttr: {},
226226
isValid: true,
227227
label: '',
228-
labelMode: 'static',
228+
labelMode: 'outside',
229229
max: undefined,
230230
min: undefined,
231231
name: '',

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/datebox.tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import '../../helpers/calendarFixtures.js';
2121

2222
import 'ui/date_box';
2323
import 'ui/validator';
24-
import 'generic_light.css!';
24+
import 'fluent_blue_light.css!';
2525

2626
QUnit.testStart(() => {
2727
const markup =
@@ -1553,7 +1553,7 @@ QUnit.module('widget sizing render', {}, () => {
15531553
const { width: actualWidth } = component.$element().get(0).getBoundingClientRect();
15541554
const { width: buttonWidth } = $(`.${BUTTONS_CONTAINER_CLASS}`).get(0).getBoundingClientRect();
15551555

1556-
assert.strictEqual(actualWidth, initialWidth + buttonWidth);
1556+
assert.strictEqual(actualWidth >= initialWidth + buttonWidth, true);
15571557
});
15581558

15591559
QUnit.test('change width', function(assert) {

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dropDownBox.tests.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { normalizeKeyName } from 'common/core/events/utils/index';
1010
import { CustomStore } from 'common/data/custom_store';
1111
import { DataSource } from 'common/data/data_source/data_source';
1212

13-
import 'generic_light.css!';
13+
import 'fluent_blue_light.css!';
1414
import 'ui/validator';
1515
import { implementationsMap } from 'core/utils/size';
1616

@@ -27,11 +27,13 @@ QUnit.testStart(() => {
2727
$('#qunit-fixture').addClass('qunit-fixture-visible');
2828
});
2929

30-
const TEXTEDITOR_INPUT_CLASS = 'dx-texteditor-input';
3130
const TAB_KEY_CODE = 'Tab';
31+
32+
const TEXTEDITOR_INPUT_CLASS = 'dx-texteditor-input';
3233
const DX_STATE_FOCUSED_CLASS = 'dx-state-focused';
3334
const OVERLAY_CONTENT_CLASS = 'dx-overlay-content';
3435
const CLEAR_BUTTON_AREA_CLASS = 'dx-clear-button-area';
36+
const POPUP_CLASS = 'dx-popup';
3537

3638
const moduleConfig = {
3739
beforeEach: function() {
@@ -695,25 +697,36 @@ QUnit.module('popup options', moduleConfig, () => {
695697

696698
QUnit.test('maxHeight should be distance between the popup top bound and the element top bound if the popup has been rendered at the top already and the window was scrolled (T874949, T942217)', function(assert) {
697699
const scrollTopValue = 50;
698-
this.$element.dxDropDownBox({
700+
701+
const instance = this.$element.dxDropDownBox({
699702
width: 300,
700-
contentTemplate: (e) => $('<div id=\'dd-content\'></div>')
701-
});
703+
contentTemplate: () => $('<div id=\'dd-content\'></div>'),
704+
}).dxDropDownBox('instance');
702705

703706
const elementHeight = this.$element.height();
704707
const scrollTop = sinon.stub(renderer.fn, 'scrollTop').returns(scrollTopValue);
705708
const windowHeight = $(window).height();
706-
this.$element.css('margin-top', windowHeight - elementHeight - 1 - scrollTopValue);
707-
const instance = this.$element.dxDropDownBox('instance');
709+
710+
this.$element.css('margin-top', windowHeight + scrollTopValue - elementHeight);
708711

709712
try {
710713
instance.open();
711-
const startPopupHeight = $(instance.content()).parent('.dx-overlay-content').height();
714+
715+
const $overlayContent = $(instance.content()).parent(`.${OVERLAY_CONTENT_CLASS}`);
716+
712717
$('#dd-content').height(300);
713718

714-
const popup = this.$element.find('.dx-popup').dxPopup('instance');
719+
const popup = this.$element
720+
.find(`.${POPUP_CLASS}`)
721+
.dxPopup('instance');
722+
715723
const maxHeight = popup.option('maxHeight');
716-
assert.roughEqual(maxHeight(), startPopupHeight + scrollTopValue, 1.01, 'maxHeight is correct');
724+
725+
const overlayOffset = $overlayContent.offset().top;
726+
const elementOffset = this.$element.offset().top;
727+
const distanceBetweenPopupAndElement = elementOffset - overlayOffset;
728+
729+
assert.roughEqual(maxHeight(), distanceBetweenPopupAndElement, 1.01, 'maxHeight is correct');
717730
} finally {
718731
scrollTop.restore();
719732
}

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/lookup.tests.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import keyboardMock from '../../helpers/keyboardMock.js';
3030
import ariaAccessibilityTestHelper from '../../helpers/ariaAccessibilityTestHelper.js';
3131
import { TextEditorLabel } from '__internal/ui/text_box/m_text_editor.label';
3232

33-
import 'generic_light.css!';
33+
import 'fluent_blue_light.css!';
3434

3535
QUnit.testStart(function() {
3636
const markup =
@@ -3866,7 +3866,7 @@ QUnit.module('default options', {
38663866

38673867
const $popup = $('.dx-popup-wrapper');
38683868

3869-
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -($popup.find('.dx-overlay-content').height() - $('.dx-list-item').height()) / 2, 2, 'offset of the lookup if fourth item is selected');
3869+
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -($popup.find('.dx-overlay-content').height() - $('.dx-list-item').height()) / 2, 4, 'offset of the lookup if fourth item is selected');
38703870

38713871
lookup.close();
38723872

@@ -3892,15 +3892,15 @@ QUnit.module('default options', {
38923892

38933893
const $popup = $('.dx-popup-wrapper');
38943894

3895-
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -3.5, 1, 'offset of the lookup if first item is selected');
3895+
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -5, 1, 'offset of the lookup if first item is selected');
38963896

38973897
getList().scrollTo(100);
38983898

38993899
lookup.close();
39003900

39013901
$(lookup.field()).trigger('dxclick');
39023902

3903-
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -3.5, 1, 'offset of the lookup after scrolling and without item selecting');
3903+
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -5, 1, 'offset of the lookup after scrolling and without item selecting');
39043904

39053905
lookup.close();
39063906

@@ -3912,16 +3912,16 @@ QUnit.module('default options', {
39123912

39133913
$(lookup.field()).trigger('dxclick');
39143914

3915-
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -2.5 - materialLookupPadding, 1, 'offset of the lookup after scrolling and cut-off item selecting');
3916-
assert.roughEqual($('.dx-list-item').eq(1).position().top, getList().scrollTop(), 2, 'position of the selected item after scrolling and cut-off item selecting');
3915+
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -1 - materialLookupPadding, 1, 'offset of the lookup after scrolling and cut-off item selecting');
3916+
assert.roughEqual($('.dx-list-item').eq(1).position().top, 38, 2, 'position of the selected item after scrolling and cut-off item selecting');
39173917

39183918
lookup.close();
39193919

39203920
lookup.option('value', 'purple');
39213921

39223922
$(lookup.field()).trigger('dxclick');
39233923

3924-
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -2.5 - materialLookupPadding, 1, 'offset of the lookup if last item is selected');
3924+
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -1 - materialLookupPadding, 1, 'offset of the lookup if last item is selected');
39253925

39263926
lookup.close();
39273927

@@ -3949,7 +3949,7 @@ QUnit.module('default options', {
39493949

39503950
const $popup = $('.dx-popup-content');
39513951

3952-
assert.roughEqual($popup.height(), 112, 1, 'popup height if DataSource without items and `searchEnabled: true`');
3952+
assert.roughEqual($popup.height(), 80, 1, 'popup height if DataSource without items and `searchEnabled: true`');
39533953
} finally {
39543954
$lookup.remove();
39553955
themes.isMaterial = origIsMaterial;
@@ -3971,7 +3971,7 @@ QUnit.module('default options', {
39713971

39723972
let $popup = $('.dx-popup-wrapper');
39733973

3974-
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -2.5 - materialLookupPadding, 1, 'popup position if second item is selected and there is not top place');
3974+
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -1 - materialLookupPadding, 1, 'popup position if second item is selected and there is not top place');
39753975

39763976
lookup.close();
39773977

@@ -3981,7 +3981,7 @@ QUnit.module('default options', {
39813981

39823982
$popup = $('.dx-popup-wrapper');
39833983

3984-
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -2.5 - $('.dx-list-item').height(), 2, 'popup position if second item is selected and there is top place');
3984+
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -7 - $('.dx-list-item').height(), 2, 'popup position if second item is selected and there is top place');
39853985

39863986
lookup.close();
39873987

@@ -3993,7 +3993,7 @@ QUnit.module('default options', {
39933993

39943994
$popup = $('.dx-popup-wrapper');
39953995

3996-
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -2.5 - $('.dx-list-item').height() * 2, 3, 'third item is centered');
3996+
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -5 - $('.dx-list-item').height() * 2, 3, 'third item is centered');
39973997

39983998
lookup.close();
39993999

@@ -4003,7 +4003,7 @@ QUnit.module('default options', {
40034003

40044004
$popup = $('.dx-popup-wrapper');
40054005

4006-
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -2.5 - $('.dx-list-item').height() * 2 - materialLookupPadding * 2, 3, 'fourth item is centered');
4006+
assert.roughEqual($popup.find('.dx-overlay-content').position().top, 5 - $('.dx-list-item').height() * 2 - materialLookupPadding * 2, 3, 'fourth item is centered');
40074007

40084008
lookup.close();
40094009

@@ -4013,7 +4013,7 @@ QUnit.module('default options', {
40134013

40144014
$popup = $('.dx-popup-wrapper');
40154015

4016-
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -2.5 - $('.dx-list-item').height() * 4 - materialLookupPadding * 2, 2, 'popup position if last item is selected and there is place');
4016+
assert.roughEqual($popup.find('.dx-overlay-content').position().top, 3 - $('.dx-list-item').height() * 4 - materialLookupPadding * 2, 2, 'popup position if last item is selected and there is place');
40174017

40184018
lookup.close();
40194019

@@ -4025,7 +4025,7 @@ QUnit.module('default options', {
40254025

40264026
$popup = $('.dx-popup-wrapper');
40274027

4028-
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -2.5 - $('.dx-list-item').height() - materialLookupPadding * 2, 3, 'popup position if there is not place for two items');
4028+
assert.roughEqual($popup.find('.dx-overlay-content').position().top, 9 - $('.dx-list-item').height() - materialLookupPadding * 2, 3, 'popup position if there is not place for two items');
40294029

40304030
lookup.close();
40314031

@@ -4035,7 +4035,7 @@ QUnit.module('default options', {
40354035

40364036
$popup = $('.dx-popup-wrapper');
40374037

4038-
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -2.5 - materialLookupPadding, 1, 'popup position if last item is selected and there is not place');
4038+
assert.roughEqual($popup.find('.dx-overlay-content').position().top, -1 - materialLookupPadding, 1, 'popup position if last item is selected and there is not place');
40394039

40404040
lookup.close();
40414041

@@ -4134,7 +4134,7 @@ QUnit.module('default options', {
41344134

41354135
const $popover = $('.dx-popover-wrapper');
41364136

4137-
assert.roughEqual($popover.find('.dx-overlay-content').eq(0).position().top, $(lookup._inputWrapper()).outerHeight() + 8 + 10, 2, 'popover position of lookup field with body padding 8px');
4137+
assert.roughEqual($popover.find('.dx-overlay-content').eq(0).position().top, $(lookup._inputWrapper()).outerHeight() + 8 + 12, 2, 'popover position of lookup field with body padding 8px');
41384138

41394139
lookup.close();
41404140

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/rangeSlider.tests.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { normalizeKeyName } from 'common/core/events/utils/index';
88
import 'ui/range_slider';
99
import 'ui/number_box';
1010
import 'ui/validator';
11-
import 'generic_light.css!';
11+
import 'fluent_blue_light.css!';
1212

1313
QUnit.testStart(function() {
1414
const markup =
@@ -32,7 +32,7 @@ const TOOLTIP_CLASS = 'dx-popover';
3232

3333
const FEEDBACK_SHOW_TIMEOUT = 30;
3434
const FEEDBACK_HIDE_TIMEOUT = 400;
35-
const CONTAINER_MARGIN = 7;
35+
const CONTAINER_MARGIN = 10;
3636

3737
const getRight = (el) => $(el).get(0).getBoundingClientRect().right;
3838
const getLeft = (el) => $(el).get(0).getBoundingClientRect().left;
@@ -88,11 +88,11 @@ const isRangeSliderDimensionsMatchOptions = (id, assert) => {
8888
}
8989
}
9090

91-
assert.roughEqual(calculatedRangeWidth, expectedRangeWidth, 0.5, `${SLIDER_RANGE_CLASS} width`);
92-
assert.roughEqual(calculatedRangeLeftOffset, expectedRangeLeftOffset, 0.5, `${SLIDER_RANGE_CLASS} left offset`);
93-
assert.roughEqual(calculatedRangeRightOffset, expectedRangeRightOffset, 0.5, `${SLIDER_RANGE_CLASS} right offset`);
94-
assert.roughEqual(calculatedStartHandleOffset, expectedRangeLeftOffset, 1, `start ${SLIDER_HANDLE_CLASS} offset`);
95-
assert.roughEqual(calculatedEndHandleOffset, expectedRangeRightOffset, 1, `end ${SLIDER_HANDLE_CLASS} offset`);
91+
assert.roughEqual(calculatedRangeWidth, expectedRangeWidth, 2.5, `${SLIDER_RANGE_CLASS} width`);
92+
assert.roughEqual(calculatedRangeLeftOffset, expectedRangeLeftOffset, 2.5, `${SLIDER_RANGE_CLASS} left offset`);
93+
assert.roughEqual(calculatedRangeRightOffset, expectedRangeRightOffset, 2.5, `${SLIDER_RANGE_CLASS} right offset`);
94+
assert.roughEqual(calculatedStartHandleOffset, expectedRangeLeftOffset, 2.5, `start ${SLIDER_HANDLE_CLASS} offset`);
95+
assert.roughEqual(calculatedEndHandleOffset, expectedRangeRightOffset, 2.5, `end ${SLIDER_HANDLE_CLASS} offset`);
9696
};
9797

9898
const moduleOptions = {
@@ -159,7 +159,7 @@ QUnit.module('render', moduleOptions, () => {
159159
pointerMock(el).start().move(450 + el.offset().left).down();
160160

161161
assert.equal(instance.option('start'), 240);
162-
assert.equal(instance.option('end'), 456);
162+
assert.equal(instance.option('end'), 458);
163163
isRangeSliderDimensionsMatchOptions('#slider', assert);
164164

165165
pointerMock(el).start().move(500 + el.offset().left).down();
@@ -225,12 +225,12 @@ QUnit.module('user interaction', () => {
225225

226226
pointer.start().down($wrapper.offset().left + CONTAINER_MARGIN + 40, $wrapper.offset().top).move(46);
227227
assert.equal(instance.option('start'), 60);
228-
assert.equal(instance.option('end'), 80);
228+
assert.equal(instance.option('end'), 78);
229229
isRangeSliderDimensionsMatchOptions('#slider', assert);
230230
pointer.up();
231231

232232
pointer.start().down($wrapper.offset().left + CONTAINER_MARGIN + 80, $wrapper.offset().top).move(-57);
233-
assert.equal(instance.option('start'), 30);
233+
assert.equal(instance.option('start'), 33);
234234
assert.equal(instance.option('end'), 60);
235235
isRangeSliderDimensionsMatchOptions('#slider', assert);
236236
pointer.up();
@@ -252,7 +252,7 @@ QUnit.module('user interaction', () => {
252252
const pointer = pointerMock($wrapper);
253253

254254
pointer.start().down($wrapper.offset().left + CONTAINER_MARGIN + 80, $wrapper.offset().top).move(-46);
255-
assert.equal(instance.option('start'), 100);
255+
assert.equal(instance.option('start'), 102);
256256
assert.equal(instance.option('end'), 120);
257257
isRangeSliderDimensionsMatchOptions('#slider', assert);
258258
pointer.up();
@@ -274,14 +274,14 @@ QUnit.module('user interaction', () => {
274274
const pointer = pointerMock($wrapper);
275275

276276
pointer.start().down($wrapper.offset().left + CONTAINER_MARGIN + 40, $wrapper.offset().top).move(46);
277-
assert.equal(instance.option('start'), 20);
277+
assert.equal(instance.option('start'), 22);
278278
assert.equal(instance.option('end'), 40);
279279
isRangeSliderDimensionsMatchOptions('#slider', assert);
280280
pointer.up();
281281

282282
pointer.start().down($wrapper.offset().left + CONTAINER_MARGIN + 80, $wrapper.offset().top).move(-57);
283283
assert.equal(instance.option('start'), 40);
284-
assert.equal(instance.option('end'), 70);
284+
assert.equal(instance.option('end'), 68);
285285
isRangeSliderDimensionsMatchOptions('#slider', assert);
286286
pointer.up();
287287
});

0 commit comments

Comments
 (0)