Skip to content

chore: release 1.32.0 #187

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

Merged
merged 26 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
997abca
feat: add `foxy-user-invitation-form` element
pheekus Sep 20, 2024
2a0888f
feat: add `foxy-user-invitation-card` element
pheekus Sep 20, 2024
410bff6
feat(foxy-user-card): add gravatar and invitations counter
pheekus Sep 20, 2024
240f0d9
chore: regenerate `custom-elements.json`
pheekus Sep 20, 2024
43ce7ae
feat(foxy-copy-to-clipboard): add support for text layout
pheekus Sep 21, 2024
4d2e9d2
feat(foxy-cart-form): add View and Copy ID buttons to Customer section
pheekus Sep 21, 2024
be16a0b
fix(foxy-transaction): fix unresponsive billing address dialog
pheekus Sep 26, 2024
a4ab89d
chore: regenerate `custom-elements.json`
pheekus Oct 1, 2024
36f28b7
fix(foxy-coupon-form): fix item option restrictions converting spaces…
pheekus Oct 1, 2024
3b2c935
fix(foxy-query-builder): fix parsing and encoding of complex alternat…
pheekus Oct 2, 2024
c1f9fea
fix(foxy-coupon-form): update handling for customer attribute coupon …
pheekus Oct 2, 2024
093b10c
feat(foxy-query-builder): add an option to create queries without `zo…
pheekus Oct 3, 2024
b811e6d
fix(foxy-coupon-form): fix spaces being encoded as `+`
pheekus Oct 3, 2024
e676046
fix(foxy-coupon-form): limit available operators in customer attribut…
pheekus Oct 3, 2024
91ad863
refactor: remove unused code
pheekus Oct 3, 2024
96a6e35
refactor: update more components to match nextgen design guidelines
pheekus Oct 3, 2024
e7a0b7c
fix(foxy-coupon-form): disable `OR` rules in customer attribute restr…
pheekus Oct 3, 2024
35677b1
refactor(foxy-coupon-form): reorganize controls
pheekus Oct 3, 2024
2729923
fix: update user invitation elements to support recent api changes
pheekus Oct 12, 2024
58910bb
feat(foxy-store-form): add support for captcha requirement on store c…
pheekus Oct 14, 2024
b64a43d
fix(foxy-nucleon): remove result hint from the update event if state …
pheekus Oct 15, 2024
4fe11d1
refactor: ongoing ui improvements
pheekus Oct 15, 2024
a1a31f4
refactor(foxy-gift-card-form): ongoing ui improvements
pheekus Oct 16, 2024
b015540
refactor(foxy-item-option-form): ongoing ui improvements
pheekus Oct 16, 2024
b431519
refactor(foxy-transaction): ongoing ui improvements
pheekus Oct 16, 2024
0dbedff
refactor(foxy-coupon-code-form): ongoing ui improvements
pheekus Oct 16, 2024
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
567 changes: 558 additions & 9 deletions custom-elements.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
import './index';

import { InternalArrayMapControl as Control } from './InternalArrayMapControl';
import { expect, fixture, html } from '@open-wc/testing';

describe('InternalArrayMapControl', () => {
it('imports and defines foxy-i18n element', () => {
expect(customElements.get('foxy-i18n')).to.exist;
});

it('imports and defines foxy-internal-editable-control element', () => {
expect(customElements.get('foxy-internal-editable-control')).to.exist;
});

it('defines itself as foxy-internal-array-map-control', () => {
expect(customElements.get('foxy-internal-array-map-control')).to.equal(Control);
});

it('extends foxy-internal-editable-control', () => {
expect(new Control()).to.be.instanceOf(customElements.get('foxy-internal-editable-control'));
});

it('renders a single empty rule by default', async () => {
const element = await fixture<Control>(
html`<foxy-internal-array-map-control></foxy-internal-array-map-control>`
);

const rules = element.renderRoot.querySelectorAll('[aria-label="rule"]');
const keyInput = rules?.[0]?.querySelector('input');

expect(rules).to.have.length(1);
expect(keyInput).to.exist;
expect(keyInput).to.have.value('');
expect(keyInput?.labels?.[0].textContent?.trim()).to.equal('option_name');
});

it('adds a rule once user starts typing into the key field', async () => {
let value: Record<string, string[]> = {};

const element = await fixture<Control>(
html`
<foxy-internal-array-map-control
.getValue=${() => value}
.setValue=${(newValue: Record<string, string[]>) => (value = newValue)}
>
</foxy-internal-array-map-control>
`
);

const root = element.renderRoot;
expect(root.querySelectorAll(`[aria-label="rule"]`)).to.have.length(1);

const path = root.querySelector('[aria-label="rule"] input') as HTMLInputElement;
path.value = 'a';
path.dispatchEvent(new InputEvent('input'));
await element.requestUpdate();

expect(root.querySelectorAll(`[aria-label="rule"]`)).to.have.length(2);
expect(value).to.deep.equal({ a: [] });
});

it('clears path of the last rule after adding a new one', async () => {
let value: Record<string, string[]> = {};

const element = await fixture<Control>(
html`
<foxy-internal-array-map-control
.getValue=${() => value}
.setValue=${(newValue: Record<string, string[]>) => (value = newValue)}
>
</foxy-internal-array-map-control>
`
);

const root = element.renderRoot;
const path = root.querySelector('[aria-label="rule"] input') as HTMLInputElement;

path.value = 'a';
path.dispatchEvent(new InputEvent('input'));
await element.requestUpdate();

expect(root.querySelector('[aria-label="rule"]:last-of-type input')).to.have.value('');
});

it('updates element value once rule field changes', async () => {
let value: Record<string, string[]> = { foo: ['one', 'two'] };

const element = await fixture<Control>(
html`
<foxy-internal-array-map-control
.getValue=${() => value}
.setValue=${(newValue: Record<string, string[]>) => (value = newValue)}
>
</foxy-internal-array-map-control>
`
);

const valueInput = element.renderRoot.querySelector('input') as HTMLInputElement;
valueInput.value = 'bar';
valueInput.dispatchEvent(new InputEvent('input'));
await element.requestUpdate();

expect(value).to.deep.equal({ bar: ['one', 'two'] });
});

it('renders editable list of values for each key', async () => {
let value: Record<string, string[]> = { foo: ['bar', 'baz'] };

const element = await fixture<Control>(
html`
<foxy-internal-array-map-control
.getValue=${() => value}
.setValue=${(newValue: Record<string, string[]>) => (value = newValue)}
>
</foxy-internal-array-map-control>
`
);

const root = element.renderRoot;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [path, first, second, addNew] = [...root.querySelectorAll<HTMLInputElement>('input')];
expect(first).to.have.property('value', 'bar');
expect(second).to.have.property('value', 'baz');

first.value = 'qux';
first.dispatchEvent(new InputEvent('input'));
await element.requestUpdate();
expect(value).to.deep.equal({ foo: ['qux', 'baz'] });

second.value = 'abc';
second.dispatchEvent(new InputEvent('input'));
await element.requestUpdate();
expect(value).to.deep.equal({ foo: ['qux', 'abc'] });

addNew.value = 'def';
addNew.dispatchEvent(new InputEvent('input'));
await element.requestUpdate();
expect(value).to.deep.equal({ foo: ['qux', 'abc', 'def'] });

addNew.value = '';
addNew.dispatchEvent(new InputEvent('input'));
await element.requestUpdate();
expect(value).to.deep.equal({ foo: ['qux', 'abc'] });
});

it('disables all inputs in the render root when disabled', async () => {
let value: Record<string, string[]> = { foo: ['bar', 'baz'] };

const element = await fixture<Control>(
html`
<foxy-internal-array-map-control
.getValue=${() => value}
.setValue=${(newValue: Record<string, string[]>) => (value = newValue)}
>
</foxy-internal-array-map-control>
`
);

const root = element.renderRoot;
const controls = root.querySelectorAll('input');
controls.forEach(control => expect(control).to.not.have.attribute('disabled'));

element.disabled = true;
await element.requestUpdate();
controls.forEach(control => expect(control).to.have.attribute('disabled'));
});

it('disables all inputs in the render root when readonly', async () => {
let value: Record<string, string[]> = { foo: ['bar', 'baz'] };

const element = await fixture<Control>(
html`
<foxy-internal-array-map-control
.getValue=${() => value}
.setValue=${(newValue: Record<string, string[]>) => (value = newValue)}
>
</foxy-internal-array-map-control>
`
);

const root = element.renderRoot;
let controls = root.querySelectorAll('input');
controls.forEach(control => expect(control).to.not.have.attribute('disabled'));

element.readonly = true;
await element.requestUpdate();
controls = root.querySelectorAll('input');
controls.forEach(control => expect(control).to.have.attribute('disabled'));
});

it('deletes a rule when remove button is clicked', async () => {
let value: Record<string, string[]> = { foo: ['bar', 'baz'], qux: ['abc'] };

const element = await fixture<Control>(
html`
<foxy-internal-array-map-control
.getValue=${() => value}
.setValue=${(newValue: Record<string, string[]>) => (value = newValue)}
>
</foxy-internal-array-map-control>
`
);

const root = element.renderRoot;
const removeButton = root.querySelector('button[aria-label="delete"]') as HTMLButtonElement;
removeButton.click();

expect(value).to.deep.equal({ qux: ['abc'] });
});

it('deletes a rule when Backspace is pressed on an empty key field', async () => {
let value: Record<string, string[]> = { foo: ['bar', 'baz'], qux: ['abc'] };

const element = await fixture<Control>(
html`
<foxy-internal-array-map-control
.getValue=${() => value}
.setValue=${(newValue: Record<string, string[]>) => (value = newValue)}
>
</foxy-internal-array-map-control>
`
);

const root = element.renderRoot;
const keyInput = root.querySelector('input') as HTMLInputElement;
keyInput.value = '';
keyInput.dispatchEvent(new KeyboardEvent('keydown', { key: 'Backspace' }));

expect(value).to.deep.equal({ qux: ['abc'] });
});

it('deletes an option when value field is cleared', async () => {
let value: Record<string, string[]> = { foo: ['bar', 'baz'], qux: ['abc'] };

const element = await fixture<Control>(
html`
<foxy-internal-array-map-control
.getValue=${() => value}
.setValue=${(newValue: Record<string, string[]>) => (value = newValue)}
>
</foxy-internal-array-map-control>
`
);

const root = element.renderRoot;
const inputs = root.querySelectorAll('input');
inputs[2].value = '';
inputs[2].dispatchEvent(new InputEvent('input'));

expect(value).to.deep.equal({ foo: ['bar'], qux: ['abc'] });
});
});
Loading
Loading