Skip to content

Commit

Permalink
tests: US152268 - Bump testing library, causing slight changes in rec…
Browse files Browse the repository at this point in the history
…t size (#3967)

* Bump testing library, causing slight changes in rect size

* Updating vdiff goldens (#3968)

Co-authored-by: github-actions <[email protected]>

* Fix broken input-number tests

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions <[email protected]>
  • Loading branch information
3 people authored Sep 5, 2023
1 parent 9138853 commit a0f6b0e
Show file tree
Hide file tree
Showing 56 changed files with 24 additions and 45 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified components/button/test/golden/button/chromium/normal-click.png
Binary file modified components/button/test/golden/button/chromium/normal-focus.png
Binary file modified components/button/test/golden/button/chromium/normal-hover.png
Binary file modified components/button/test/golden/button/chromium/normal-normal.png
Binary file modified components/button/test/golden/button/chromium/primary-click.png
Binary file modified components/button/test/golden/button/chromium/primary-focus.png
Binary file modified components/button/test/golden/button/chromium/primary-hover.png
Binary file modified components/button/test/golden/button/chromium/primary-normal.png
58 changes: 18 additions & 40 deletions components/inputs/test/input-number.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import '../input-number.js';
import { aTimeout, defineCE, expect, fixture, html, oneEvent, waitUntil } from '@brightspace-ui/testing';
import { getDocumentLocaleSettings } from '@brightspace-ui/intl/lib/common.js';
import { aTimeout, defineCE, expect, fixture, html, oneEvent } from '@brightspace-ui/testing';
import { LitElement } from 'lit';
import { runConstructor } from '../../../tools/constructor-test-helper.js';

Expand Down Expand Up @@ -55,18 +54,6 @@ const inputWrapperTag = defineCE(
}
);

async function fixtureInit(f) {
const elem = await fixture(f);
await waitUntil(() => {
const textInput = elem.shadowRoot.querySelector('d2l-input-text');
if (!textInput) return false;
const input = textInput.shadowRoot.querySelector('.d2l-input');
if (!input) return false;
return true;
}, { interval: 10 });
return elem;
}

function getInnerInputValue(elem) {
return elem.shadowRoot.querySelector('d2l-input-text').value;
}
Expand All @@ -91,11 +78,6 @@ function setSelectionRange(elem, start, end) {

describe('d2l-input-number', () => {

const documentLocaleSettings = getDocumentLocaleSettings();
afterEach(() => {
documentLocaleSettings.reset();
});

describe('constructor', () => {
it('should construct', () => {
runConstructor('d2l-input-number');
Expand Down Expand Up @@ -496,116 +478,113 @@ describe('d2l-input-number', () => {

['a', ' ', '+', '(', ')', '?'].forEach((key) => {
it(`should suppress non-numeric character: "${key}"`, async() => {
const elem = await fixtureInit(normalFixture);
const elem = await fixture(normalFixture);
const event = dispatchKeypressEvent(elem, key);
expect(event.defaultPrevented).to.be.true;
});
});

['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'].forEach((key) => {
it(`should not suppress numeric character: "${key}"`, async() => {
const elem = await fixtureInit(normalFixture);
const elem = await fixture(normalFixture);
const event = dispatchKeypressEvent(elem, key);
expect(event.defaultPrevented).to.be.false;
});
});

it('should not suppress negative symbol at the beginning for "en"', async() => {
const elem = await fixtureInit(normalFixture);
const elem = await fixture(normalFixture);
setCursorPosition(elem, 0);
const event = dispatchKeypressEvent(elem, '-');
expect(event.defaultPrevented).to.be.false;
});

it('should not suppress negative symbol at the end for "ar"', async() => {
documentLocaleSettings.language = 'ar';
const elem = await fixtureInit(defaultValueFixture);
const elem = await fixture(defaultValueFixture, { lang: 'ar' });
await setCursorPosition(elem, 3);
const event = dispatchKeypressEvent(elem, '-');
expect(event.defaultPrevented).to.be.false;
});

it('should not suppress ENTER key so that input\'s change event can fire', async() => {
const elem = await fixtureInit(normalFixture);
const elem = await fixture(normalFixture);
const event = dispatchKeypressEvent(elem, 'Enter');
expect(event.defaultPrevented).to.be.false;
});

it('should suppress negative symbol when cursor is not at beginning', async() => {
const elem = await fixtureInit(defaultValueFixture);
const elem = await fixture(defaultValueFixture);
setCursorPosition(elem, 1);
const event = dispatchKeypressEvent(elem, '-');
expect(event.defaultPrevented).to.be.true;
});

it('should suppress decimal symbol if one already exists', async() => {
const elem = await fixtureInit(html`<d2l-input-number label="label" value="1.2"></d2l-input-number>`);
const elem = await fixture(html`<d2l-input-number label="label" value="1.2"></d2l-input-number>`);
const event = dispatchKeypressEvent(elem, '.');
expect(event.defaultPrevented).to.be.true;
expect(elem._hintType).to.equal(1);
});

it('should suppress decimal symbol if selection range does not cover it', async() => {
const elem = await fixtureInit(html`<d2l-input-number label="label" value="10.25"></d2l-input-number>`);
const elem = await fixture(html`<d2l-input-number label="label" value="10.25"></d2l-input-number>`);
setSelectionRange(elem, 0, 2);
const event = dispatchKeypressEvent(elem, '.');
expect(event.defaultPrevented).to.be.true;
expect(elem._hintType).to.equal(1);
});

it('should not suppress decimal symbol if selection range covers it from the left', async() => {
const elem = await fixtureInit(html`<d2l-input-number label="label" value="10.25"></d2l-input-number>`);
const elem = await fixture(html`<d2l-input-number label="label" value="10.25"></d2l-input-number>`);
setSelectionRange(elem, 0, 3);
const event = dispatchKeypressEvent(elem, '.');
expect(event.defaultPrevented).to.be.false;
});

it('should not suppress decimal symbol if selection range covers it from the right', async() => {
const elem = await fixtureInit(html`<d2l-input-number label="label" value="10.25"></d2l-input-number>`);
const elem = await fixture(html`<d2l-input-number label="label" value="10.25"></d2l-input-number>`);
setSelectionRange(elem, 2, 5);
const event = dispatchKeypressEvent(elem, '.');
expect(event.defaultPrevented).to.be.false;
});

it('should suppress decimal symbol only integers are allowed', async() => {
const elem = await fixtureInit(html`<d2l-input-number label="label" value="1" max-fraction-digits="0"></d2l-input-number>`);
const elem = await fixture(html`<d2l-input-number label="label" value="1" max-fraction-digits="0"></d2l-input-number>`);
const event = dispatchKeypressEvent(elem, '.');
expect(event.defaultPrevented).to.be.true;
expect(elem._hintType).to.equal(4);
});

it('should suppress incorrect decimal symbol ","', async() => {
const elem = await fixtureInit(html`<d2l-input-number label="label" value="1"></d2l-input-number>`);
const elem = await fixture(html`<d2l-input-number label="label" value="1"></d2l-input-number>`);
const event = dispatchKeypressEvent(elem, ',');
expect(event.defaultPrevented).to.be.true;
expect(elem._hintType).to.equal(3);
});

it('should not suppress correct decimal symbol "."', async() => {
const elem = await fixtureInit(html`<d2l-input-number label="label" value="1"></d2l-input-number>`);
const elem = await fixture(html`<d2l-input-number label="label" value="1"></d2l-input-number>`);
const event = dispatchKeypressEvent(elem, '.');
expect(event.defaultPrevented).to.be.false;
expect(elem._hintType).to.equal(0);
});

it('should suppress incorrect decimal symbol "."', async() => {
documentLocaleSettings.language = 'fr';
const elem = await fixtureInit(html`<d2l-input-number label="label" value="1"></d2l-input-number>`);
const elem = await fixture(html`<d2l-input-number label="label" value="1"></d2l-input-number>`, { lang: 'fr' });
const event = dispatchKeypressEvent(elem, '.');
expect(event.defaultPrevented).to.be.true;
expect(elem._hintType).to.equal(2);
});

it('should not suppress correct decimal symbol ","', async() => {
documentLocaleSettings.language = 'fr';
const elem = await fixtureInit(html`<d2l-input-number label="label" value="1"></d2l-input-number>`);
const elem = await fixture(html`<d2l-input-number label="label" value="1"></d2l-input-number>`, { lang: 'fr' });
const event = dispatchKeypressEvent(elem, ',');
expect(event.defaultPrevented).to.be.false;
expect(elem._hintType).to.equal(0);
});

it('should reset hint after next keypress', async() => {
const elem = await fixtureInit(html`<d2l-input-number label="label" value="1"></d2l-input-number>`);
const elem = await fixture(html`<d2l-input-number label="label" value="1"></d2l-input-number>`);
dispatchKeypressEvent(elem, ',');
dispatchKeypressEvent(elem, '5');
expect(elem._hintType).to.equal(0);
Expand Down Expand Up @@ -739,8 +718,7 @@ describe('d2l-input-number', () => {
});

it('should handle different locales', async() => {
documentLocaleSettings.language = 'fr';
const elem = await fixture(trailingZeroesFixture);
const elem = await fixture(trailingZeroesFixture, { lang: 'fr' });
expect(elem.value).to.equal(2001);
expect(elem.valueTrailingZeroes).to.equal('2001.00');
expect(elem._formattedValue).to.equal('2001,00');
Expand Down
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"devDependencies": {
"@babel/eslint-parser": "^7",
"@brightspace-ui/stylelint-config": "^0.8",
"@brightspace-ui/testing": "^0.30",
"@brightspace-ui/testing": "^0.32",
"@open-wc/semantic-dom-diff": "^0.20",
"@rollup/plugin-dynamic-import-vars": "^2",
"@rollup/plugin-node-resolve": "^15",
Expand Down

0 comments on commit a0f6b0e

Please sign in to comment.