@block-auth.io/angular 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/block-auth.io-angular.mjs +9976 -0
- package/fesm2022/block-auth.io-angular.mjs.map +1 -0
- package/index.d.ts +1155 -0
- package/package.json +16 -37
- package/.turbo/turbo-build.log +0 -37
- package/.turbo/turbo-lint.log +0 -4
- package/.turbo/turbo-test.log +0 -1400
- package/.turbo/turbo-typecheck.log +0 -19
- package/CHANGELOG.md +0 -273
- package/ng-package.json +0 -6
- package/scripts/css-to-ts.mjs +0 -14
- package/src/lib/__tests__/integration.test.ts +0 -45
- package/src/lib/block-auth.service.test.ts +0 -69
- package/src/lib/block-auth.service.ts +0 -81
- package/src/lib/components/btns/btn-base-provider.component.test.ts +0 -36
- package/src/lib/components/btns/btn-base-provider.component.ts +0 -61
- package/src/lib/components/btns/btn-block-auth.component.test.ts +0 -105
- package/src/lib/components/btns/btn-block-auth.component.ts +0 -117
- package/src/lib/components/btns/btn-gmail.component.test.ts +0 -16
- package/src/lib/components/btns/btn-gmail.component.ts +0 -41
- package/src/lib/components/btns/btn-google-base.component.test.ts +0 -16
- package/src/lib/components/btns/btn-google-base.component.ts +0 -73
- package/src/lib/components/btns/btn-metamask.component.test.ts +0 -20
- package/src/lib/components/btns/btn-metamask.component.ts +0 -98
- package/src/lib/components/btns/btn-microsoft.component.test.ts +0 -16
- package/src/lib/components/btns/btn-microsoft.component.ts +0 -77
- package/src/lib/components/btns/btn-phantom.component.test.ts +0 -20
- package/src/lib/components/btns/btn-phantom.component.ts +0 -93
- package/src/lib/components/btns/btn-signin.component.test.ts +0 -55
- package/src/lib/components/btns/btn-signin.component.ts +0 -108
- package/src/lib/components/btns/btn-wallet-connect.component.test.ts +0 -20
- package/src/lib/components/btns/btn-wallet-connect.component.ts +0 -109
- package/src/lib/components/btns/index.ts +0 -11
- package/src/lib/components/contents/content-signin.component.test.ts +0 -33
- package/src/lib/components/contents/content-signin.component.ts +0 -68
- package/src/lib/components/contents/content-signup.component.test.ts +0 -86
- package/src/lib/components/contents/content-signup.component.ts +0 -222
- package/src/lib/components/dds/change-account.component.test.ts +0 -66
- package/src/lib/components/dds/change-account.component.ts +0 -112
- package/src/lib/components/dds/dropdown-profile-btn.component.test.ts +0 -66
- package/src/lib/components/dds/dropdown-profile-btn.component.ts +0 -172
- package/src/lib/components/dds/dropdown-profile-item.component.test.ts +0 -75
- package/src/lib/components/dds/dropdown-profile-item.component.ts +0 -74
- package/src/lib/components/dds/dropdown-profile.component.test.ts +0 -110
- package/src/lib/components/dds/dropdown-profile.component.ts +0 -264
- package/src/lib/components/flow-block-auth.component.test.ts +0 -95
- package/src/lib/components/flow-block-auth.component.ts +0 -228
- package/src/lib/components/modals/modal-overlay.component.test.ts +0 -81
- package/src/lib/components/modals/modal-overlay.component.ts +0 -43
- package/src/lib/components/modals/modal-restoration-expired.component.test.ts +0 -71
- package/src/lib/components/modals/modal-restoration-expired.component.ts +0 -83
- package/src/lib/components/modals/modal-restore.component.test.ts +0 -74
- package/src/lib/components/modals/modal-restore.component.ts +0 -104
- package/src/lib/components/modals/modal-signin.component.test.ts +0 -66
- package/src/lib/components/modals/modal-signin.component.ts +0 -44
- package/src/lib/components/modals/modal-signup.component.test.ts +0 -56
- package/src/lib/components/modals/modal-signup.component.ts +0 -40
- package/src/lib/components/sections/footer-section.component.test.ts +0 -19
- package/src/lib/components/sections/footer-section.component.ts +0 -49
- package/src/lib/components/sections/internals/providers-buttons.component.test.ts +0 -27
- package/src/lib/components/sections/internals/providers-buttons.component.ts +0 -280
- package/src/lib/components/sections/internals/providers-filters.component.test.ts +0 -25
- package/src/lib/components/sections/internals/providers-filters.component.ts +0 -139
- package/src/lib/components/sections/internals/selected-button.component.test.ts +0 -36
- package/src/lib/components/sections/internals/selected-button.component.ts +0 -92
- package/src/lib/components/sections/login-section.component.test.ts +0 -49
- package/src/lib/components/sections/login-section.component.ts +0 -119
- package/src/lib/components/sections/providers-section.component.test.ts +0 -22
- package/src/lib/components/sections/providers-section.component.ts +0 -187
- package/src/lib/components/txns/internals/permissions-required-modal.component.test.ts +0 -36
- package/src/lib/components/txns/internals/permissions-required-modal.component.ts +0 -43
- package/src/lib/components/txns/internals/phone-input.component.test.ts +0 -119
- package/src/lib/components/txns/internals/phone-input.component.ts +0 -301
- package/src/lib/components/txns/internals/solicited-data-modal.component.test.ts +0 -700
- package/src/lib/components/txns/internals/solicited-data-modal.component.ts +0 -430
- package/src/lib/components/txns/internals/txn-error.component.test.ts +0 -127
- package/src/lib/components/txns/internals/txn-error.component.ts +0 -144
- package/src/lib/components/txns/internals/txn-type.component.test.ts +0 -52
- package/src/lib/components/txns/internals/txn-type.component.ts +0 -51
- package/src/lib/components/txns/internals/txn.component.test.ts +0 -593
- package/src/lib/components/txns/internals/txn.component.ts +0 -453
- package/src/lib/components/txns/txns-overview.component.test.ts +0 -421
- package/src/lib/components/txns/txns-overview.component.ts +0 -461
- package/src/lib/icons/ai-outline-disconnect.component.ts +0 -21
- package/src/lib/icons/bi-logo-gmail.component.ts +0 -21
- package/src/lib/icons/cg-profile.component.ts +0 -31
- package/src/lib/icons/check-icon.component.ts +0 -27
- package/src/lib/icons/ci-clock2.component.ts +0 -31
- package/src/lib/icons/fa-arrow-right.component.ts +0 -21
- package/src/lib/icons/fa-times.component.ts +0 -21
- package/src/lib/icons/fa-undo.component.ts +0 -21
- package/src/lib/icons/icons.test.ts +0 -25
- package/src/lib/icons/index.ts +0 -22
- package/src/lib/icons/io-ios-arrow-back.component.ts +0 -21
- package/src/lib/icons/io-ios-arrow-forward.component.ts +0 -21
- package/src/lib/icons/io-md-arrow-back.component.ts +0 -19
- package/src/lib/icons/io-md-arrow-forward.component.ts +0 -19
- package/src/lib/icons/pi-warning-fill.component.ts +0 -21
- package/src/lib/icons/tb-arrows-exchange2.component.ts +0 -30
- package/src/lib/icons/tb-copy-check-filled.component.ts +0 -21
- package/src/lib/icons/tb-copy.component.ts +0 -34
- package/src/lib/icons/ti-vendor-microsoft.component.ts +0 -21
- package/src/lib/inject-store.test.ts +0 -26
- package/src/lib/inject-store.ts +0 -16
- package/src/lib/primitives/arrow-icon.component.test.ts +0 -25
- package/src/lib/primitives/arrow-icon.component.ts +0 -45
- package/src/lib/primitives/btn-arrow-dir.component.test.ts +0 -22
- package/src/lib/primitives/btn-arrow-dir.component.ts +0 -65
- package/src/lib/primitives/btn-base.component.test.ts +0 -38
- package/src/lib/primitives/btn-base.component.ts +0 -140
- package/src/lib/primitives/divider-base.component.test.ts +0 -12
- package/src/lib/primitives/divider-base.component.ts +0 -74
- package/src/lib/primitives/dropdown-arrow.component.test.ts +0 -12
- package/src/lib/primitives/dropdown-arrow.component.ts +0 -46
- package/src/lib/primitives/dropdown-base.component.test.ts +0 -49
- package/src/lib/primitives/dropdown-base.component.ts +0 -329
- package/src/lib/primitives/helpers.ts +0 -151
- package/src/lib/primitives/horizontal-loader.component.test.ts +0 -20
- package/src/lib/primitives/horizontal-loader.component.ts +0 -46
- package/src/lib/primitives/icon-base.component.test.ts +0 -19
- package/src/lib/primitives/icon-base.component.ts +0 -58
- package/src/lib/primitives/img-loader.component.test.ts +0 -22
- package/src/lib/primitives/img-loader.component.ts +0 -121
- package/src/lib/primitives/index.ts +0 -29
- package/src/lib/primitives/input-base.component.test.ts +0 -20
- package/src/lib/primitives/input-base.component.ts +0 -210
- package/src/lib/primitives/lifetime-slider-base.component.test.ts +0 -88
- package/src/lib/primitives/lifetime-slider-base.component.ts +0 -75
- package/src/lib/primitives/oval-spinner.component.test.ts +0 -17
- package/src/lib/primitives/oval-spinner.component.ts +0 -136
- package/src/lib/primitives/pickers/dropdown-picker-animated-base.component.ts +0 -220
- package/src/lib/primitives/pickers/picker-button.component.ts +0 -74
- package/src/lib/primitives/pickers/time-picker-dropdown-selector.component.ts +0 -188
- package/src/lib/primitives/pickers/time-picker.component.ts +0 -124
- package/src/lib/primitives/pickers/time-unit-selector.component.ts +0 -82
- package/src/lib/primitives/progressbar.component.test.ts +0 -34
- package/src/lib/primitives/progressbar.component.ts +0 -36
- package/src/lib/primitives/providersStyles.ts +0 -218
- package/src/lib/primitives/slider-base.component.ts +0 -56
- package/src/lib/provide-block-auth.test.ts +0 -43
- package/src/lib/provide-block-auth.ts +0 -43
- package/src/lib/runtime/block-auth-runtime.directive.test.ts +0 -89
- package/src/lib/runtime/block-auth-runtime.directive.ts +0 -68
- package/src/lib/teleport-body.directive.test.ts +0 -29
- package/src/lib/teleport-body.directive.ts +0 -21
- package/src/lib/testing.ts +0 -15
- package/src/lib/transitions.css +0 -19
- package/src/public-api.ts +0 -86
- package/src/vitest.setup.ts +0 -8
- package/tailwind.config.cjs +0 -6
- package/tsconfig.json +0 -15
- package/tsconfig.lib.json +0 -9
- package/vite.config.mts +0 -44
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { Component } from '@angular/core';
|
|
3
|
-
import { render, screen, fireEvent } from '@testing-library/angular';
|
|
4
|
-
import { TxnTypeComponent } from './txn-type.component';
|
|
5
|
-
|
|
6
|
-
// Port de packages/react/src/components/txns/internals/TxnType.test.tsx (mapa:
|
|
7
|
-
// packages/vue/.../TxnType.test.ts). Componente presentacional, sin client.
|
|
8
|
-
describe('TxnType', () => {
|
|
9
|
-
it('renderiza el tipo de txn con navegacion', async () => {
|
|
10
|
-
@Component({
|
|
11
|
-
standalone: true,
|
|
12
|
-
imports: [TxnTypeComponent],
|
|
13
|
-
template: `<ba-txn-type txnType="Log In" [txnsLength]="2" />`,
|
|
14
|
-
})
|
|
15
|
-
class Host {}
|
|
16
|
-
await render(Host);
|
|
17
|
-
expect(screen.getByText('Log In')).toBeDefined();
|
|
18
|
-
expect(screen.getByLabelText('next transaction')).toBeDefined();
|
|
19
|
-
expect(screen.getByLabelText('previous transaction')).toBeDefined();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('no muestra flechas de navegacion cuando solo hay una txn', async () => {
|
|
23
|
-
@Component({
|
|
24
|
-
standalone: true,
|
|
25
|
-
imports: [TxnTypeComponent],
|
|
26
|
-
template: `<ba-txn-type txnType="Log In" [txnsLength]="1" />`,
|
|
27
|
-
})
|
|
28
|
-
class Host {}
|
|
29
|
-
await render(Host);
|
|
30
|
-
expect(screen.queryByLabelText('next transaction')).toBeNull();
|
|
31
|
-
expect(screen.queryByLabelText('previous transaction')).toBeNull();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('emite prevTxnClicked/nextTxnClicked al hacer click en las flechas', async () => {
|
|
35
|
-
const onPrev = vi.fn();
|
|
36
|
-
const onNext = vi.fn();
|
|
37
|
-
@Component({
|
|
38
|
-
standalone: true,
|
|
39
|
-
imports: [TxnTypeComponent],
|
|
40
|
-
template: `<ba-txn-type txnType="Log In" [txnsLength]="2" (prevTxnClicked)="p()" (nextTxnClicked)="n()" />`,
|
|
41
|
-
})
|
|
42
|
-
class Host {
|
|
43
|
-
p = onPrev;
|
|
44
|
-
n = onNext;
|
|
45
|
-
}
|
|
46
|
-
await render(Host);
|
|
47
|
-
await fireEvent.click(screen.getByLabelText('previous transaction'));
|
|
48
|
-
await fireEvent.click(screen.getByLabelText('next transaction'));
|
|
49
|
-
expect(onPrev).toHaveBeenCalledOnce();
|
|
50
|
-
expect(onNext).toHaveBeenCalledOnce();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
// Puramente presentacional: sin
|
|
4
|
-
// lógica de core. `onPrevTxnClicked`/`onNextTxnClicked` (callback props en
|
|
5
|
-
// react) -> outputs `prevTxnClicked`/`nextTxnClicked` (eventos de click, no
|
|
6
|
-
// funciones invocadas imperativamente por el padre), igual que el port Vue.
|
|
7
|
-
// Las flechas `‹`/`›` (‹ ›) se escriben como caracteres literales.
|
|
8
|
-
@Component({
|
|
9
|
-
selector: 'ba-txn-type',
|
|
10
|
-
standalone: true,
|
|
11
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
12
|
-
template: `
|
|
13
|
-
<div
|
|
14
|
-
[class]="
|
|
15
|
-
(txnsLength() > 1 ? 'bas-grid bas-grid-cols-[28px_1fr_28px]' : 'bas-flex') +
|
|
16
|
-
' bas-group bas-z-0 bas-w-full bas-items-center bas-justify-between bas-gap-1'
|
|
17
|
-
"
|
|
18
|
-
>
|
|
19
|
-
@if (txnsLength() > 1) {
|
|
20
|
-
<span
|
|
21
|
-
aria-label="previous transaction"
|
|
22
|
-
class="bal-ba-transition-2 bas-flex bas-h-7 bas-w-7 bas-cursor-pointer bas-items-center bas-justify-center bas-rounded-full hover:bas-bg-[#e7ecef] bas-text-[var(--bal-primary-500)] group-hover:bas-text-[var(--bal-primary-700)]"
|
|
23
|
-
(click)="prevTxnClicked.emit()"
|
|
24
|
-
>‹</span
|
|
25
|
-
>
|
|
26
|
-
}
|
|
27
|
-
<div class="bas-flex bas-w-full bas-items-center bas-justify-center bas-gap-3">
|
|
28
|
-
<span class="bal-ba-glass-divider bas-h-px bas-flex-1"></span>
|
|
29
|
-
<p class="bal-ba-transition-2 bas-m-0 bas-cursor-default bas-text-center bas-text-lg bas-text-[var(--bal-primary-700)] group-hover:bas-text-[var(--bal-primary-900)]">
|
|
30
|
-
{{ txnType() }}
|
|
31
|
-
</p>
|
|
32
|
-
<span class="bal-ba-glass-divider bal-ba-glass-divider-end bas-h-px bas-flex-1"></span>
|
|
33
|
-
</div>
|
|
34
|
-
@if (txnsLength() > 1) {
|
|
35
|
-
<span
|
|
36
|
-
aria-label="next transaction"
|
|
37
|
-
class="bal-ba-transition-2 bas-flex bas-h-7 bas-w-7 bas-cursor-pointer bas-items-center bas-justify-center bas-rounded-full hover:bas-bg-[#e7ecef] bas-text-[var(--bal-primary-500)] group-hover:bas-text-[var(--bal-primary-700)]"
|
|
38
|
-
(click)="nextTxnClicked.emit()"
|
|
39
|
-
>›</span
|
|
40
|
-
>
|
|
41
|
-
}
|
|
42
|
-
</div>
|
|
43
|
-
`,
|
|
44
|
-
})
|
|
45
|
-
export class TxnTypeComponent {
|
|
46
|
-
txnType = input('');
|
|
47
|
-
txnsLength = input(1);
|
|
48
|
-
|
|
49
|
-
prevTxnClicked = output<void>();
|
|
50
|
-
nextTxnClicked = output<void>();
|
|
51
|
-
}
|
|
@@ -1,593 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
2
|
-
import { Component } from '@angular/core';
|
|
3
|
-
import { render, screen, fireEvent } from '@testing-library/angular';
|
|
4
|
-
import { map } from 'nanostores';
|
|
5
|
-
import { setLocale } from '@block-auth.io/core';
|
|
6
|
-
import { TxnComponent } from './txn.component';
|
|
7
|
-
import { provideBlockAuthClientForTest } from '../../../testing';
|
|
8
|
-
|
|
9
|
-
vi.mock('@wagmi/core', () => ({
|
|
10
|
-
createConfig: vi.fn(() => ({ connectors: [] })),
|
|
11
|
-
connect: vi.fn(),
|
|
12
|
-
disconnect: vi.fn(),
|
|
13
|
-
getAccount: vi.fn(() => ({})),
|
|
14
|
-
signMessage: vi.fn(),
|
|
15
|
-
watchAccount: vi.fn(() => () => undefined),
|
|
16
|
-
http: vi.fn(),
|
|
17
|
-
}));
|
|
18
|
-
vi.mock('@wagmi/connectors', () => ({
|
|
19
|
-
injected: vi.fn(() => ({ id: 'injected' })),
|
|
20
|
-
walletConnect: vi.fn(() => ({ id: 'walletConnect' })),
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
// Port de packages/react/src/components/txns/internals/Txn.test.tsx +
|
|
24
|
-
// TxnActions.behavior.test.tsx (mapa: packages/vue/.../Txn.test.ts).
|
|
25
|
-
//
|
|
26
|
-
// El toggle PPTC se ejerce vía `data-testid="txn-pptc-toggle"` (el div exterior,
|
|
27
|
-
// único dueño del handler que alterna `pptcAccepted`), no vía click directo en
|
|
28
|
-
// `checkbox-animated` (que es `bas-hidden`).
|
|
29
|
-
describe('Txn', () => {
|
|
30
|
-
function makeClient(overrides: Record<string, any> = {}) {
|
|
31
|
-
return {
|
|
32
|
-
txns: { reject: vi.fn(), accept: vi.fn(), report: vi.fn() },
|
|
33
|
-
closeModal: vi.fn(),
|
|
34
|
-
state: { $ui: map({}), $ws: map({ requests: [] }) },
|
|
35
|
-
...overrides,
|
|
36
|
-
} as any;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
afterEach(() => setLocale('en'));
|
|
40
|
-
|
|
41
|
-
it('renderiza el cuerpo de la txn con aceptar/rechazar', async () => {
|
|
42
|
-
await render(TxnComponent, {
|
|
43
|
-
inputs: { hasSolicitedData: true },
|
|
44
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
45
|
-
});
|
|
46
|
-
expect(screen.getByText('Permissions required')).toBeDefined();
|
|
47
|
-
expect(screen.getByText('ACCEPT')).toBeDefined();
|
|
48
|
-
expect(screen.getByText('REJECT')).toBeDefined();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('lee el consentimiento como una sola frase que fluye', async () => {
|
|
52
|
-
setLocale('es');
|
|
53
|
-
await render(TxnComponent, {
|
|
54
|
-
inputs: { hasSolicitedData: true },
|
|
55
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
56
|
-
});
|
|
57
|
-
const sentence = screen.getByTestId('btn-privacy-policy').parentElement;
|
|
58
|
-
expect(sentence?.tagName).toBe('P');
|
|
59
|
-
expect(sentence?.textContent?.replace(/\s+/g, ' ').trim()).toBe(
|
|
60
|
-
'Autorizo la Política de Privacidad y los Términos y Condiciones',
|
|
61
|
-
);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('respeta el locale activo cuando no se pasan textos custom', async () => {
|
|
65
|
-
setLocale('es');
|
|
66
|
-
await render(TxnComponent, {
|
|
67
|
-
inputs: { hasSolicitedData: true },
|
|
68
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
69
|
-
});
|
|
70
|
-
expect(screen.getByText('Permisos requeridos')).toBeDefined();
|
|
71
|
-
expect(screen.getByText('ACEPTAR')).toBeDefined();
|
|
72
|
-
expect(screen.getByText('RECHAZAR')).toBeDefined();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('ACCEPT esta deshabilitado hasta aceptar PPTC (y allRequiredFilled)', async () => {
|
|
76
|
-
await render(TxnComponent, {
|
|
77
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
78
|
-
});
|
|
79
|
-
const acceptBtn = screen
|
|
80
|
-
.getByText('ACCEPT')
|
|
81
|
-
.closest('button') as HTMLButtonElement;
|
|
82
|
-
const checkbox = screen.getByTestId(
|
|
83
|
-
'checkbox-animated',
|
|
84
|
-
) as HTMLInputElement;
|
|
85
|
-
expect(acceptBtn.disabled).toBe(true);
|
|
86
|
-
expect(checkbox.checked).toBe(false);
|
|
87
|
-
|
|
88
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
89
|
-
expect(checkbox.checked).toBe(true);
|
|
90
|
-
expect(acceptBtn.disabled).toBe(false);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('ACCEPT sigue deshabilitado si allRequiredFilled=false aunque PPTC este aceptado', async () => {
|
|
94
|
-
await render(TxnComponent, {
|
|
95
|
-
inputs: { allRequiredFilled: false },
|
|
96
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
97
|
-
});
|
|
98
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
99
|
-
const acceptBtn = screen
|
|
100
|
-
.getByText('ACCEPT')
|
|
101
|
-
.closest('button') as HTMLButtonElement;
|
|
102
|
-
expect(acceptBtn.disabled).toBe(true);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('REJECT llama client.txns.reject() y luego closeModal() (no closeTxns)', async () => {
|
|
106
|
-
const client = makeClient();
|
|
107
|
-
const closeTxns = vi.fn();
|
|
108
|
-
@Component({
|
|
109
|
-
standalone: true,
|
|
110
|
-
imports: [TxnComponent],
|
|
111
|
-
template: `<ba-txn [closeTxns]="c" />`,
|
|
112
|
-
})
|
|
113
|
-
class Host {
|
|
114
|
-
c = closeTxns;
|
|
115
|
-
}
|
|
116
|
-
await render(Host, { providers: [provideBlockAuthClientForTest(client)] });
|
|
117
|
-
await fireEvent.click(screen.getByText('REJECT'));
|
|
118
|
-
|
|
119
|
-
expect(client.txns.reject).toHaveBeenCalledOnce();
|
|
120
|
-
expect(client.closeModal).toHaveBeenCalledOnce();
|
|
121
|
-
expect(closeTxns).not.toHaveBeenCalled();
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('ACCEPT llama a addError("no_app_key_found") cuando falta appKey', async () => {
|
|
125
|
-
const client = makeClient();
|
|
126
|
-
const addError = vi.fn();
|
|
127
|
-
@Component({
|
|
128
|
-
standalone: true,
|
|
129
|
-
imports: [TxnComponent],
|
|
130
|
-
template: `<ba-txn [selectedTxnPreParams]="{}" [addError]="e" />`,
|
|
131
|
-
})
|
|
132
|
-
class Host {
|
|
133
|
-
e = addError;
|
|
134
|
-
}
|
|
135
|
-
await render(Host, { providers: [provideBlockAuthClientForTest(client)] });
|
|
136
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
137
|
-
await fireEvent.click(screen.getByText('ACCEPT'));
|
|
138
|
-
expect(addError).toHaveBeenCalledWith('no_app_key_found');
|
|
139
|
-
expect(client.txns.accept).not.toHaveBeenCalled();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('ACCEPT llama a addError("no_contract_address_found") cuando falta to', async () => {
|
|
143
|
-
const client = makeClient();
|
|
144
|
-
const addError = vi.fn();
|
|
145
|
-
@Component({
|
|
146
|
-
standalone: true,
|
|
147
|
-
imports: [TxnComponent],
|
|
148
|
-
template: `<ba-txn
|
|
149
|
-
[selectedTxnPreParams]="{ appKey: 'k' }"
|
|
150
|
-
[addError]="e"
|
|
151
|
-
/>`,
|
|
152
|
-
})
|
|
153
|
-
class Host {
|
|
154
|
-
e = addError;
|
|
155
|
-
}
|
|
156
|
-
await render(Host, { providers: [provideBlockAuthClientForTest(client)] });
|
|
157
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
158
|
-
await fireEvent.click(screen.getByText('ACCEPT'));
|
|
159
|
-
expect(addError).toHaveBeenCalledWith('no_contract_address_found');
|
|
160
|
-
expect(client.txns.accept).not.toHaveBeenCalled();
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('ACCEPT llama a client.txns.accept con lifetime/userParams cuando los preParams son validos', async () => {
|
|
164
|
-
const client = makeClient();
|
|
165
|
-
@Component({
|
|
166
|
-
standalone: true,
|
|
167
|
-
imports: [TxnComponent],
|
|
168
|
-
template: `<ba-txn
|
|
169
|
-
[selectedTxnPreParams]="{ appKey: 'k', to: '0xabc' }"
|
|
170
|
-
[userParamValues]="{ 'users-email': 'a@b.com' }"
|
|
171
|
-
/>`,
|
|
172
|
-
})
|
|
173
|
-
class Host {}
|
|
174
|
-
await render(Host, { providers: [provideBlockAuthClientForTest(client)] });
|
|
175
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
176
|
-
await fireEvent.click(screen.getByText('ACCEPT'));
|
|
177
|
-
|
|
178
|
-
expect(client.txns.accept).toHaveBeenCalledWith({
|
|
179
|
-
lifetime: 3600,
|
|
180
|
-
userParams: { 'users-email': 'a@b.com' },
|
|
181
|
-
grantedParams: [],
|
|
182
|
-
revokedParams: [],
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('ACCEPT envía grantedParams/revokedParams y limpia el error previo de aceptación', async () => {
|
|
187
|
-
const client = makeClient();
|
|
188
|
-
client.state.$ui.setKey('acceptTxnError', 'Required data not authorized');
|
|
189
|
-
@Component({
|
|
190
|
-
standalone: true,
|
|
191
|
-
imports: [TxnComponent],
|
|
192
|
-
template: `<ba-txn
|
|
193
|
-
[selectedTxnPreParams]="{ appKey: 'k', to: '0xabc' }"
|
|
194
|
-
[grantedParams]="['users-email']"
|
|
195
|
-
[revokedParams]="['users-lastname']"
|
|
196
|
-
/>`,
|
|
197
|
-
})
|
|
198
|
-
class Host {}
|
|
199
|
-
await render(Host, { providers: [provideBlockAuthClientForTest(client)] });
|
|
200
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
201
|
-
await fireEvent.click(screen.getByText('ACCEPT'));
|
|
202
|
-
|
|
203
|
-
expect(client.txns.accept).toHaveBeenCalledWith({
|
|
204
|
-
lifetime: 3600,
|
|
205
|
-
userParams: {},
|
|
206
|
-
grantedParams: ['users-email'],
|
|
207
|
-
revokedParams: ['users-lastname'],
|
|
208
|
-
});
|
|
209
|
-
expect(client.state.$ui.get().acceptTxnError).toBeNull();
|
|
210
|
-
expect(client.state.$ui.get().isAcceptingTxn).toBe(true);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('emite permissionsRequiredClicked/solicitedDataClicked (solo si hasSolicitedData)', async () => {
|
|
214
|
-
const onPerm = vi.fn();
|
|
215
|
-
const onSol = vi.fn();
|
|
216
|
-
@Component({
|
|
217
|
-
standalone: true,
|
|
218
|
-
imports: [TxnComponent],
|
|
219
|
-
template: `<ba-txn
|
|
220
|
-
[hasSolicitedData]="true"
|
|
221
|
-
(permissionsRequiredClicked)="p()"
|
|
222
|
-
(solicitedDataClicked)="s()"
|
|
223
|
-
/>`,
|
|
224
|
-
})
|
|
225
|
-
class Host {
|
|
226
|
-
p = onPerm;
|
|
227
|
-
s = onSol;
|
|
228
|
-
}
|
|
229
|
-
await render(Host, {
|
|
230
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
231
|
-
});
|
|
232
|
-
await fireEvent.click(screen.getByText('Permissions required'));
|
|
233
|
-
await fireEvent.click(screen.getByText('Solicited data'));
|
|
234
|
-
expect(onPerm).toHaveBeenCalledOnce();
|
|
235
|
-
expect(onSol).toHaveBeenCalledOnce();
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it('el boton de configurar sesion revela el LifetimeSliderBase (slider + TimePicker)', async () => {
|
|
239
|
-
const { container } = await render(TxnComponent, {
|
|
240
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
241
|
-
});
|
|
242
|
-
// Antes del click no hay ni slider ni TimePicker.
|
|
243
|
-
expect(container.querySelector('#txn-lifetime-slider-slider')).toBeNull();
|
|
244
|
-
await fireEvent.click(
|
|
245
|
-
screen.getByText('I want to configure my session time'),
|
|
246
|
-
);
|
|
247
|
-
// El slider estilado (SliderBase) y el input del TimePicker aparecen.
|
|
248
|
-
const slider = container.querySelector(
|
|
249
|
-
'#txn-lifetime-slider-slider',
|
|
250
|
-
) as HTMLInputElement;
|
|
251
|
-
expect(slider).not.toBeNull();
|
|
252
|
-
expect(slider.type).toBe('range');
|
|
253
|
-
const timeInput = container.querySelector(
|
|
254
|
-
'#txn-lifetime-slider-time-picker-time-input',
|
|
255
|
-
) as HTMLInputElement;
|
|
256
|
-
expect(timeInput).not.toBeNull();
|
|
257
|
-
// Refleja el lifetime por defecto (3600s → 01:00:00) como HH:MM:SS.
|
|
258
|
-
expect(timeInput.value).toBe('01:00:00');
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
it('mover el slider actualiza el valor HH:MM:SS del TimePicker', async () => {
|
|
262
|
-
const { container } = await render(TxnComponent, {
|
|
263
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
264
|
-
});
|
|
265
|
-
await fireEvent.click(
|
|
266
|
-
screen.getByText('I want to configure my session time'),
|
|
267
|
-
);
|
|
268
|
-
const slider = container.querySelector(
|
|
269
|
-
'#txn-lifetime-slider-slider',
|
|
270
|
-
) as HTMLInputElement;
|
|
271
|
-
await fireEvent.input(slider, { target: { value: '7200' } }); // 02:00:00
|
|
272
|
-
const timeInput = container.querySelector(
|
|
273
|
-
'#txn-lifetime-slider-time-picker-time-input',
|
|
274
|
-
) as HTMLInputElement;
|
|
275
|
-
expect(timeInput.value).toBe('02:00:00');
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
const lifetimeSlider = () =>
|
|
279
|
-
document.getElementById('txn-lifetime-slider-slider') as HTMLInputElement;
|
|
280
|
-
|
|
281
|
-
it('"Quiero configurar el tiempo de mi sesión" abre el selector en un popup', async () => {
|
|
282
|
-
await render(TxnComponent, {
|
|
283
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
284
|
-
});
|
|
285
|
-
expect(screen.queryByRole('dialog')).toBeNull();
|
|
286
|
-
expect(lifetimeSlider()).toBeNull();
|
|
287
|
-
await fireEvent.click(
|
|
288
|
-
screen.getByRole('button', {
|
|
289
|
-
name: 'I want to configure my session time',
|
|
290
|
-
}),
|
|
291
|
-
);
|
|
292
|
-
const dialog = screen.getByRole('dialog', {
|
|
293
|
-
name: 'I want to configure my session time',
|
|
294
|
-
});
|
|
295
|
-
expect(dialog.classList.contains('bal-ba-glass-panel')).toBe(true);
|
|
296
|
-
expect(dialog.contains(lifetimeSlider())).toBe(true);
|
|
297
|
-
expect(lifetimeSlider().value).toBe('3600');
|
|
298
|
-
expect(
|
|
299
|
-
document.getElementById('btn-configure-session-time'),
|
|
300
|
-
).not.toBeNull();
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
it('Aceptar cierra el popup y conserva el tiempo elegido junto al enlace', async () => {
|
|
304
|
-
await render(TxnComponent, {
|
|
305
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
306
|
-
});
|
|
307
|
-
expect(document.getElementById('txn-lifetime-value')).toBeNull();
|
|
308
|
-
await fireEvent.click(
|
|
309
|
-
document.getElementById('btn-configure-session-time')!,
|
|
310
|
-
);
|
|
311
|
-
await fireEvent.input(lifetimeSlider(), { target: { value: '7200' } });
|
|
312
|
-
await fireEvent.click(document.getElementById('txn-lifetime-accept')!);
|
|
313
|
-
expect(screen.queryByRole('dialog')).toBeNull();
|
|
314
|
-
expect(document.getElementById('txn-lifetime-value')?.textContent).toBe(
|
|
315
|
-
'02:00:00',
|
|
316
|
-
);
|
|
317
|
-
expect(
|
|
318
|
-
document
|
|
319
|
-
.querySelector('#btn-configure-session-time p')
|
|
320
|
-
?.contains(document.getElementById('txn-lifetime-value')),
|
|
321
|
-
).toBe(true);
|
|
322
|
-
await fireEvent.click(
|
|
323
|
-
document.getElementById('btn-configure-session-time')!,
|
|
324
|
-
);
|
|
325
|
-
expect(lifetimeSlider().value).toBe('7200');
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
it('cerrar con la x o fuera del popup conserva el tiempo elegido', async () => {
|
|
329
|
-
const { container } = await render(TxnComponent, {
|
|
330
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
331
|
-
});
|
|
332
|
-
await fireEvent.click(
|
|
333
|
-
document.getElementById('btn-configure-session-time')!,
|
|
334
|
-
);
|
|
335
|
-
await fireEvent.input(lifetimeSlider(), { target: { value: '120' } });
|
|
336
|
-
await fireEvent.click(screen.getByRole('button', { name: 'Close' }));
|
|
337
|
-
expect(screen.queryByRole('dialog')).toBeNull();
|
|
338
|
-
expect(document.getElementById('txn-lifetime-value')?.textContent).toBe(
|
|
339
|
-
'00:02:00',
|
|
340
|
-
);
|
|
341
|
-
await fireEvent.click(
|
|
342
|
-
document.getElementById('btn-configure-session-time')!,
|
|
343
|
-
);
|
|
344
|
-
await fireEvent.input(lifetimeSlider(), { target: { value: '60' } });
|
|
345
|
-
await fireEvent.click(container.querySelector('.bal-ba-glass-backdrop')!);
|
|
346
|
-
expect(screen.queryByRole('dialog')).toBeNull();
|
|
347
|
-
expect(document.getElementById('txn-lifetime-value')?.textContent).toBe(
|
|
348
|
-
'00:01:00',
|
|
349
|
-
);
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
it('traduce el popup del tiempo de sesión', async () => {
|
|
353
|
-
setLocale('es');
|
|
354
|
-
await render(TxnComponent, {
|
|
355
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
356
|
-
});
|
|
357
|
-
await fireEvent.click(
|
|
358
|
-
document.getElementById('btn-configure-session-time')!,
|
|
359
|
-
);
|
|
360
|
-
expect(
|
|
361
|
-
screen.getByRole('dialog', {
|
|
362
|
-
name: 'Quiero configurar el tiempo de mi sesión',
|
|
363
|
-
}),
|
|
364
|
-
).toBeDefined();
|
|
365
|
-
expect(screen.getByRole('button', { name: 'Cerrar' })).toBeDefined();
|
|
366
|
-
expect(
|
|
367
|
-
document.getElementById('txn-lifetime-accept')?.textContent?.trim(),
|
|
368
|
-
).toBe('ACEPTAR');
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
it('ACCEPT envía el lifetime elegido en el popup del tiempo de sesión', async () => {
|
|
372
|
-
const client = makeClient();
|
|
373
|
-
await render(TxnComponent, {
|
|
374
|
-
inputs: { selectedTxnPreParams: { appKey: 'app', to: '0xabc' } },
|
|
375
|
-
providers: [provideBlockAuthClientForTest(client)],
|
|
376
|
-
});
|
|
377
|
-
await fireEvent.click(
|
|
378
|
-
document.getElementById('btn-configure-session-time')!,
|
|
379
|
-
);
|
|
380
|
-
await fireEvent.input(lifetimeSlider(), { target: { value: '5400' } });
|
|
381
|
-
await fireEvent.click(document.getElementById('txn-lifetime-accept')!);
|
|
382
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
383
|
-
await fireEvent.click(document.getElementById('btn-txn-accept')!);
|
|
384
|
-
expect(client.txns.accept).toHaveBeenCalledWith(
|
|
385
|
-
expect.objectContaining({ lifetime: 5400 }),
|
|
386
|
-
);
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
const visibleArrows = (container: Element) =>
|
|
390
|
-
Array.from(container.querySelectorAll('[aria-hidden="true"]')).filter(
|
|
391
|
-
(el) =>
|
|
392
|
-
el.querySelector('.bal-ba-arrow') &&
|
|
393
|
-
!el.className.includes('bas-invisible'),
|
|
394
|
-
);
|
|
395
|
-
|
|
396
|
-
it('"Datos solicitados" queda desactivado cuando no hay datos', async () => {
|
|
397
|
-
const onSol = vi.fn();
|
|
398
|
-
@Component({
|
|
399
|
-
standalone: true,
|
|
400
|
-
imports: [TxnComponent],
|
|
401
|
-
template: `<ba-txn (solicitedDataClicked)="s()" />`,
|
|
402
|
-
})
|
|
403
|
-
class Host {
|
|
404
|
-
s = onSol;
|
|
405
|
-
}
|
|
406
|
-
await render(Host, {
|
|
407
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
408
|
-
});
|
|
409
|
-
const btn = screen
|
|
410
|
-
.getByText('Solicited data')
|
|
411
|
-
.closest('button') as HTMLButtonElement;
|
|
412
|
-
expect(btn.disabled).toBe(true);
|
|
413
|
-
await fireEvent.click(btn);
|
|
414
|
-
expect(onSol).not.toHaveBeenCalled();
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
it('"Permisos requeridos" y "Datos solicitados" comparten el estilo glass de ancho completo y una línea', async () => {
|
|
418
|
-
const { container } = await render(TxnComponent, {
|
|
419
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
420
|
-
});
|
|
421
|
-
const permissionsBtn = container.querySelector(
|
|
422
|
-
'#btn-txn-permissions-required',
|
|
423
|
-
) as HTMLButtonElement;
|
|
424
|
-
const solicitedDataBtn = container.querySelector(
|
|
425
|
-
'#btn-txn-solicited-data',
|
|
426
|
-
) as HTMLButtonElement;
|
|
427
|
-
for (const btn of [permissionsBtn, solicitedDataBtn]) {
|
|
428
|
-
expect(btn.classList.contains('bal-ba-glass-btn')).toBe(true);
|
|
429
|
-
expect(
|
|
430
|
-
btn.querySelector('.bal-ba-glass-btn-label')?.textContent?.trim(),
|
|
431
|
-
).toBeTruthy();
|
|
432
|
-
expect(btn.querySelector('.bal-ba-arrow')).toBeNull();
|
|
433
|
-
}
|
|
434
|
-
expect(solicitedDataBtn.disabled).toBe(true);
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
it('las flechas de "Datos solicitados" van superpuestas a los lados, fuera del botón', async () => {
|
|
438
|
-
const { container } = await render(TxnComponent, {
|
|
439
|
-
inputs: { hasSolicitedData: true },
|
|
440
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
441
|
-
});
|
|
442
|
-
const row = container.querySelector('#btn-txn-solicited-data')
|
|
443
|
-
?.parentElement as HTMLElement;
|
|
444
|
-
expect(
|
|
445
|
-
row.querySelector('.bal-ba-glass-btn-arrow-left .bal-ba-arrow-right'),
|
|
446
|
-
).toBeTruthy();
|
|
447
|
-
expect(
|
|
448
|
-
row.querySelector('.bal-ba-glass-btn-arrow-right .bal-ba-arrow-left'),
|
|
449
|
-
).toBeTruthy();
|
|
450
|
-
expect(container.querySelectorAll('.bal-ba-arrow')).toHaveLength(2);
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
it('muestra siempre las flechas de "Datos solicitados" mientras falten datos', async () => {
|
|
454
|
-
const { container } = await render(TxnComponent, {
|
|
455
|
-
inputs: { hasSolicitedData: true, allRequiredFilled: false },
|
|
456
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
457
|
-
});
|
|
458
|
-
expect(visibleArrows(container)).toHaveLength(2);
|
|
459
|
-
expect(
|
|
460
|
-
screen.getByText('Solicited data').closest('button')?.className,
|
|
461
|
-
).toContain('bal-ba-glass-btn-pending');
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
it('oculta las flechas cuando no hay nada pendiente', async () => {
|
|
465
|
-
const { container } = await render(TxnComponent, {
|
|
466
|
-
inputs: { hasSolicitedData: true },
|
|
467
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
468
|
-
});
|
|
469
|
-
expect(visibleArrows(container)).toHaveLength(0);
|
|
470
|
-
expect(
|
|
471
|
-
screen.getByText('Solicited data').closest('button')?.className,
|
|
472
|
-
).not.toContain('bal-ba-glass-btn-pending');
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
it('solicitedDataPending manda sobre el cálculo por defecto', async () => {
|
|
476
|
-
const { container } = await render(TxnComponent, {
|
|
477
|
-
inputs: {
|
|
478
|
-
hasSolicitedData: true,
|
|
479
|
-
allRequiredFilled: false,
|
|
480
|
-
solicitedDataPending: false,
|
|
481
|
-
},
|
|
482
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
483
|
-
});
|
|
484
|
-
expect(visibleArrows(container)).toHaveLength(0);
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
it('aplica el estilo glass a la casilla de política y a RECHAZAR/ACEPTAR', async () => {
|
|
488
|
-
const { container } = await render(TxnComponent, {
|
|
489
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
490
|
-
});
|
|
491
|
-
const consent = screen.getByTestId('txn-pptc-toggle');
|
|
492
|
-
expect(consent.className).toContain('bal-ba-glass-consent');
|
|
493
|
-
expect(consent.className).not.toContain('bal-ba-glass-consent-checked');
|
|
494
|
-
await fireEvent.click(consent);
|
|
495
|
-
expect(consent.className).toContain('bal-ba-glass-consent-checked');
|
|
496
|
-
expect(container.querySelector('#btn-txn-reject')?.className).toContain(
|
|
497
|
-
'bal-ba-glass-action-reject',
|
|
498
|
-
);
|
|
499
|
-
expect(container.querySelector('#btn-txn-accept')?.className).toContain(
|
|
500
|
-
'bal-ba-glass-action-accept',
|
|
501
|
-
);
|
|
502
|
-
await fireEvent.click(
|
|
503
|
-
screen.getByText('I want to configure my session time'),
|
|
504
|
-
);
|
|
505
|
-
expect(container.querySelector('.bal-ba-glass-time')).not.toBeNull();
|
|
506
|
-
expect(container.querySelector('.bal-ba-glass-slider')).not.toBeNull();
|
|
507
|
-
});
|
|
508
|
-
|
|
509
|
-
it('al pasar por ACEPTAR deshabilitado sin política aceptada vibra la casilla', async () => {
|
|
510
|
-
const { container } = await render(TxnComponent, {
|
|
511
|
-
inputs: { hasSolicitedData: true, allRequiredFilled: false },
|
|
512
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
513
|
-
});
|
|
514
|
-
await fireEvent.mouseEnter(screen.getByTestId('txn-accept-wrapper'));
|
|
515
|
-
expect(screen.getByTestId('txn-pptc-toggle').className).toContain(
|
|
516
|
-
'bal-ba-head-shake',
|
|
517
|
-
);
|
|
518
|
-
expect(
|
|
519
|
-
screen.getByText('Solicited data').closest('button')?.className,
|
|
520
|
-
).not.toContain('bal-ba-head-shake');
|
|
521
|
-
expect(visibleArrows(container)).toHaveLength(2);
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
it('al pasar por ACEPTAR deshabilitado con datos pendientes vibra "Datos solicitados" y mantiene sus flechas', async () => {
|
|
525
|
-
const { container } = await render(TxnComponent, {
|
|
526
|
-
inputs: { hasSolicitedData: true, allRequiredFilled: false },
|
|
527
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
528
|
-
});
|
|
529
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
530
|
-
const wrapper = screen.getByTestId('txn-accept-wrapper');
|
|
531
|
-
await fireEvent.mouseEnter(wrapper);
|
|
532
|
-
const solicitedDataBtn = screen
|
|
533
|
-
.getByText('Solicited data')
|
|
534
|
-
.closest('button');
|
|
535
|
-
expect(solicitedDataBtn?.className).toContain('bal-ba-head-shake');
|
|
536
|
-
expect(
|
|
537
|
-
screen.getByText('Permissions required').closest('button')?.className,
|
|
538
|
-
).not.toContain('bal-ba-head-shake');
|
|
539
|
-
expect(screen.getByTestId('txn-pptc-toggle').className).not.toContain(
|
|
540
|
-
'bal-ba-head-shake',
|
|
541
|
-
);
|
|
542
|
-
expect(visibleArrows(container)).toHaveLength(2);
|
|
543
|
-
await fireEvent.mouseLeave(wrapper);
|
|
544
|
-
expect(solicitedDataBtn?.className).not.toContain('bal-ba-head-shake');
|
|
545
|
-
expect(visibleArrows(container)).toHaveLength(2);
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
it('el foco en el contenedor de ACEPTAR deshabilitado también muestra la pista', async () => {
|
|
549
|
-
await render(TxnComponent, {
|
|
550
|
-
inputs: { hasSolicitedData: true, allRequiredFilled: false },
|
|
551
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
552
|
-
});
|
|
553
|
-
const wrapper = screen.getByTestId('txn-accept-wrapper');
|
|
554
|
-
await fireEvent.focusIn(wrapper);
|
|
555
|
-
expect(screen.getByTestId('txn-pptc-toggle').className).toContain(
|
|
556
|
-
'bal-ba-head-shake',
|
|
557
|
-
);
|
|
558
|
-
await fireEvent.focusOut(wrapper);
|
|
559
|
-
expect(screen.getByTestId('txn-pptc-toggle').className).not.toContain(
|
|
560
|
-
'bal-ba-head-shake',
|
|
561
|
-
);
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
it('no muestra pistas al pasar por ACEPTAR habilitado', async () => {
|
|
565
|
-
const { container } = await render(TxnComponent, {
|
|
566
|
-
inputs: { hasSolicitedData: true },
|
|
567
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
568
|
-
});
|
|
569
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
570
|
-
await fireEvent.mouseEnter(screen.getByTestId('txn-accept-wrapper'));
|
|
571
|
-
expect(container.querySelector('.bal-ba-head-shake')).toBeNull();
|
|
572
|
-
expect(visibleArrows(container)).toHaveLength(0);
|
|
573
|
-
});
|
|
574
|
-
|
|
575
|
-
it('"Permisos requeridos" es un botón accesible que emite su evento', async () => {
|
|
576
|
-
const onPerm = vi.fn();
|
|
577
|
-
@Component({
|
|
578
|
-
standalone: true,
|
|
579
|
-
imports: [TxnComponent],
|
|
580
|
-
template: `<ba-txn (permissionsRequiredClicked)="p()" />`,
|
|
581
|
-
})
|
|
582
|
-
class Host {
|
|
583
|
-
p = onPerm;
|
|
584
|
-
}
|
|
585
|
-
await render(Host, {
|
|
586
|
-
providers: [provideBlockAuthClientForTest(makeClient())],
|
|
587
|
-
});
|
|
588
|
-
await fireEvent.click(
|
|
589
|
-
screen.getByRole('button', { name: 'Permissions required' }),
|
|
590
|
-
);
|
|
591
|
-
expect(onPerm).toHaveBeenCalledOnce();
|
|
592
|
-
});
|
|
593
|
-
});
|