Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

US152268 - Bump testing library, causing slight changes in rect size #3967

Merged
merged 3 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! 💥


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';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bearfriend @dlockhart Changes to the testing library made these tests start failing. I've updated them to set the language through fixture instead (and removed the extra waiting that shouldn't be needed anymore). But let me know if this was testing this method of setting the language specifically, and there's actually an issue in testing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope this is the perfect change!

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