Skip to content

Commit

Permalink
refactor(foxy-admin-subscription-form): update self-service links ui
Browse files Browse the repository at this point in the history
  • Loading branch information
pheekus committed Feb 4, 2025
1 parent d630115 commit 474bb03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,48 +67,6 @@ describe('AdminSubscriptionForm', () => {
expect(helperText).to.exist;
});

it('renders sub_token link from parent form by default', async () => {
const data = await getTestData<Data>('./hapi/subscriptions/0?zoom=transaction_template');
data._links['fx:sub_token_url'].href = 'https://example.com/sub_token_url';

const nucleon = await fixture<NucleonElement<Data>>(html`
<foxy-nucleon .data=${data}>
<foxy-internal-admin-subscription-form-link-control infer="">
</foxy-internal-admin-subscription-form-link-control>
</foxy-nucleon>
`);

const control = nucleon.firstElementChild as Control;
control.inferProperties();
await control.requestUpdate();

const link = control.renderRoot.querySelector('a') as HTMLAnchorElement;
expect(link).to.exist;
expect(link.href).to.equal('https://example.com/sub_token_url');
expect(link.target).to.equal('_blank');
});

it('adds search to sub_token link when set', async () => {
const data = await getTestData<Data>('./hapi/subscriptions/0?zoom=transaction_template');
data._links['fx:sub_token_url'].href = 'https://example.com/sub_token_url?foo=bar';

const nucleon = await fixture<NucleonElement<Data>>(html`
<foxy-nucleon .data=${data}>
<foxy-internal-admin-subscription-form-link-control search="cart=checkout" infer="">
</foxy-internal-admin-subscription-form-link-control>
</foxy-nucleon>
`);

const control = nucleon.firstElementChild as Control;
control.inferProperties();
await control.requestUpdate();

const link = control.renderRoot.querySelector('a') as HTMLAnchorElement;
expect(link).to.exist;
expect(link.href).to.equal('https://example.com/sub_token_url?cart=checkout&foo=bar');
expect(link.target).to.equal('_blank');
});

it('renders copy to clipboard button with link url', async () => {
const data = await getTestData<Data>('./hapi/subscriptions/0?zoom=transaction_template');
data._links['fx:sub_token_url'].href = 'https://example.com/sub_token_url';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,12 @@ export class InternalAdminSubscriptionFormLinkControl extends ResponsiveMixin(In
}

return html`
<div class="leading-xs flex items-center gap-s">
<a
target="_blank"
class="truncate min-w-0 font-medium rounded cursor-pointer text-primary hover-underline focus-outline-none focus-ring-2 focus-ring-primary-50"
href=${href}
>
<foxy-i18n infer="" key="label"></foxy-i18n>
</a>
<span> &bull; </span>
<div class="leading-xs flex items-center gap-xs">
<foxy-i18n class="truncate min-w-0" infer="" key="label"></foxy-i18n>
<span class="text-tertiary"> &bull; </span>
<foxy-copy-to-clipboard
layout="text"
theme="tertiary-inline contrast"
layout="complete"
theme="tertiary-inline"
infer="copy-to-clipboard"
text=${href}
>
Expand Down

0 comments on commit 474bb03

Please sign in to comment.