@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,421 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
2
|
-
import { render, screen, fireEvent, waitFor } from '@testing-library/angular';
|
|
3
|
-
import { map } from 'nanostores';
|
|
4
|
-
import { setExtensionInstalled, resetExtension } from '@block-auth.io/core';
|
|
5
|
-
import { TxnsOverviewComponent } from './txns-overview.component';
|
|
6
|
-
import { provideBlockAuthClientForTest } from '../../testing';
|
|
7
|
-
|
|
8
|
-
vi.mock('@wagmi/core', () => ({
|
|
9
|
-
createConfig: vi.fn(() => ({ connectors: [] })),
|
|
10
|
-
connect: vi.fn(), disconnect: vi.fn(), getAccount: vi.fn(() => ({})),
|
|
11
|
-
signMessage: vi.fn(), watchAccount: vi.fn(() => () => undefined), http: vi.fn(),
|
|
12
|
-
}));
|
|
13
|
-
vi.mock('@wagmi/connectors', () => ({
|
|
14
|
-
injected: vi.fn(() => ({ id: 'injected' })), walletConnect: vi.fn(() => ({ id: 'walletConnect' })),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
// Port de packages/react/src/components/txns/TxnsOverview.test.tsx, extendido
|
|
18
|
-
// con la vista poblada (Txn + navegación prev/next), igual que el port Vue.
|
|
19
|
-
describe('TxnsOverview', () => {
|
|
20
|
-
function makeClient(ws: Record<string, any> = {}, ui: Record<string, any> = {}) {
|
|
21
|
-
return {
|
|
22
|
-
txns: {
|
|
23
|
-
reject: vi.fn(),
|
|
24
|
-
accept: vi.fn(),
|
|
25
|
-
report: vi.fn(),
|
|
26
|
-
dataRequest: vi.fn().mockResolvedValue(null),
|
|
27
|
-
},
|
|
28
|
-
closeModal: vi.fn(),
|
|
29
|
-
state: { $ui: map({ ...ui }), $ws: map({ requests: [], ...ws }) },
|
|
30
|
-
} as any;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const acceptButton = () => document.getElementById('btn-txn-accept') as HTMLButtonElement;
|
|
34
|
-
const visibleArrows = () =>
|
|
35
|
-
Array.from(document.querySelectorAll('[aria-hidden="true"]')).filter(
|
|
36
|
-
(el) => el.querySelector('.bal-ba-arrow') && !el.className.includes('bas-invisible'),
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
it('renderiza la vista general de txns (estado vacio sin crashear)', async () => {
|
|
40
|
-
await render(TxnsOverviewComponent, {
|
|
41
|
-
providers: [provideBlockAuthClientForTest(makeClient({}, { isSigning: false }))],
|
|
42
|
-
});
|
|
43
|
-
expect(screen.getByTestId('txns-overview')).toBeDefined();
|
|
44
|
-
expect(screen.queryByText('No transactions found')).toBeNull();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('estado vacio + isSigning muestra el error "No transactions found"', async () => {
|
|
48
|
-
await render(TxnsOverviewComponent, {
|
|
49
|
-
providers: [provideBlockAuthClientForTest(makeClient({}, { isSigning: true }))],
|
|
50
|
-
});
|
|
51
|
-
expect(screen.getByText('No transactions found')).toBeDefined();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('con txns pendientes renderiza el header + TxnType + Txn', async () => {
|
|
55
|
-
await render(TxnsOverviewComponent, {
|
|
56
|
-
providers: [
|
|
57
|
-
provideBlockAuthClientForTest(
|
|
58
|
-
makeClient({
|
|
59
|
-
did: '0x1234567890abcdef',
|
|
60
|
-
requests: [
|
|
61
|
-
{ id: 1, pre_params: JSON.stringify({ appName: 'Acme', domain: 'acme.io', txnType: 'Log In' }) },
|
|
62
|
-
],
|
|
63
|
-
}),
|
|
64
|
-
),
|
|
65
|
-
],
|
|
66
|
-
});
|
|
67
|
-
expect(screen.getByTestId('txns-overview')).toBeDefined();
|
|
68
|
-
expect(screen.getByText('acme.io')).toBeDefined();
|
|
69
|
-
expect(screen.getByText(/Acme/)).toBeDefined();
|
|
70
|
-
expect(screen.getByText('Log In')).toBeDefined();
|
|
71
|
-
expect(screen.getByText('ACCEPT')).toBeDefined();
|
|
72
|
-
expect(screen.getByText('REJECT')).toBeDefined();
|
|
73
|
-
// Single txn -> no prev/next nav.
|
|
74
|
-
expect(screen.queryByLabelText('next transaction')).toBeNull();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('navega entre txns con prev/next', async () => {
|
|
78
|
-
await render(TxnsOverviewComponent, {
|
|
79
|
-
providers: [
|
|
80
|
-
provideBlockAuthClientForTest(
|
|
81
|
-
makeClient({
|
|
82
|
-
requests: [
|
|
83
|
-
{ id: 1, pre_params: JSON.stringify({ txnType: 'Log In' }) },
|
|
84
|
-
{ id: 2, pre_params: JSON.stringify({ txnType: 'Sign message' }) },
|
|
85
|
-
],
|
|
86
|
-
}),
|
|
87
|
-
),
|
|
88
|
-
],
|
|
89
|
-
});
|
|
90
|
-
expect(screen.getByText('Log In')).toBeDefined();
|
|
91
|
-
await fireEvent.click(screen.getByLabelText('next transaction'));
|
|
92
|
-
expect(screen.getByText('Sign message')).toBeDefined();
|
|
93
|
-
await fireEvent.click(screen.getByLabelText('next transaction'));
|
|
94
|
-
expect(screen.getByText('Log In')).toBeDefined();
|
|
95
|
-
await fireEvent.click(screen.getByLabelText('previous transaction'));
|
|
96
|
-
expect(screen.getByText('Sign message')).toBeDefined();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('un pre_params invalido no rompe el render (fallback a valores por defecto)', async () => {
|
|
100
|
-
await render(TxnsOverviewComponent, {
|
|
101
|
-
providers: [
|
|
102
|
-
provideBlockAuthClientForTest(makeClient({ requests: [{ id: 1, pre_params: 'not-json' }] })),
|
|
103
|
-
],
|
|
104
|
-
});
|
|
105
|
-
expect(screen.getByText('dashboard.block-auth.io')).toBeDefined();
|
|
106
|
-
expect(screen.getByText('Log In')).toBeDefined();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('addError de Txn muestra el error correspondiente en TxnsOverview', async () => {
|
|
110
|
-
await render(TxnsOverviewComponent, {
|
|
111
|
-
providers: [
|
|
112
|
-
provideBlockAuthClientForTest(makeClient({ requests: [{ id: 1, pre_params: JSON.stringify({}) }] })),
|
|
113
|
-
],
|
|
114
|
-
});
|
|
115
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
116
|
-
await waitFor(() => expect(acceptButton().disabled).toBe(false));
|
|
117
|
-
await fireEvent.click(screen.getByText('ACCEPT'));
|
|
118
|
-
expect(screen.getByText('No application key found')).toBeDefined();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
describe('con datos solicitados', () => {
|
|
122
|
-
const pending = {
|
|
123
|
-
requests: [{ id: 7, pre_params: JSON.stringify({ appName: 'Shop', appKey: 'app', to: '0xabc' }) }],
|
|
124
|
-
};
|
|
125
|
-
const solicitedTitle = () => screen.getByText('Solicited data');
|
|
126
|
-
const solicitedButton = () => solicitedTitle().closest('button') as HTMLButtonElement;
|
|
127
|
-
|
|
128
|
-
it('pide los datos de la txn y exige ceder, rellenar y guardar los obligatorios', async () => {
|
|
129
|
-
const client = makeClient(pending);
|
|
130
|
-
client.txns.dataRequest.mockResolvedValue({
|
|
131
|
-
txnId: 7,
|
|
132
|
-
params: [
|
|
133
|
-
{ slug: 'users-firstname', mode: 'required', status: 'shared', value: 'Ana' },
|
|
134
|
-
{ slug: 'users-email', mode: 'required', status: 'consent', value: 'ana@block-auth.io' },
|
|
135
|
-
{ slug: 'users-phone', mode: 'required', status: 'missing', value: null },
|
|
136
|
-
],
|
|
137
|
-
});
|
|
138
|
-
await render(TxnsOverviewComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
139
|
-
expect(client.txns.dataRequest).toHaveBeenCalledWith(7);
|
|
140
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
141
|
-
await waitFor(() => expect(solicitedButton().disabled).toBe(false));
|
|
142
|
-
expect(acceptButton().disabled).toBe(true);
|
|
143
|
-
expect(visibleArrows()).toHaveLength(2);
|
|
144
|
-
|
|
145
|
-
await fireEvent.click(solicitedTitle());
|
|
146
|
-
expect(screen.getByText('First Name')).toBeDefined();
|
|
147
|
-
await fireEvent.click(screen.getByLabelText('Share Email'));
|
|
148
|
-
expect(acceptButton().disabled).toBe(true);
|
|
149
|
-
await fireEvent.input(document.querySelector('input[type="tel"]')!, {
|
|
150
|
-
target: { value: ' +34 600 000 000 ' },
|
|
151
|
-
});
|
|
152
|
-
expect(document.getElementById('solicited-data-share-users-phone')?.getAttribute('aria-checked')).toBe('true');
|
|
153
|
-
expect(acceptButton().disabled).toBe(true);
|
|
154
|
-
await fireEvent.click(screen.getByText('Save'));
|
|
155
|
-
expect(acceptButton().disabled).toBe(false);
|
|
156
|
-
expect(visibleArrows()).toHaveLength(0);
|
|
157
|
-
|
|
158
|
-
await fireEvent.click(acceptButton());
|
|
159
|
-
expect(client.txns.accept).toHaveBeenCalledWith({
|
|
160
|
-
lifetime: 3600,
|
|
161
|
-
userParams: { 'users-phone': '+34600000000' },
|
|
162
|
-
grantedParams: ['users-email'],
|
|
163
|
-
revokedParams: [],
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('cierra el modal de datos solicitados con el botón de cerrar', async () => {
|
|
168
|
-
const client = makeClient(pending);
|
|
169
|
-
client.txns.dataRequest.mockResolvedValue({
|
|
170
|
-
txnId: 7,
|
|
171
|
-
params: [{ slug: 'users-email', mode: 'required', status: 'granted', value: 'ana@block-auth.io' }],
|
|
172
|
-
});
|
|
173
|
-
await render(TxnsOverviewComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
174
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
175
|
-
await waitFor(() => expect(acceptButton().disabled).toBe(false));
|
|
176
|
-
await fireEvent.click(solicitedTitle());
|
|
177
|
-
expect(screen.getByText('Email')).toBeDefined();
|
|
178
|
-
await fireEvent.click(screen.getByRole('button', { name: 'Close' }));
|
|
179
|
-
expect(screen.queryByText('Email')).toBeNull();
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('Aceptar del popup de datos lo cierra conservando los cambios sin aceptar el login', async () => {
|
|
183
|
-
const client = makeClient(pending);
|
|
184
|
-
client.txns.dataRequest.mockResolvedValue({
|
|
185
|
-
txnId: 7,
|
|
186
|
-
params: [{ slug: 'users-email', mode: 'optional', status: 'missing', value: null }],
|
|
187
|
-
});
|
|
188
|
-
await render(TxnsOverviewComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
189
|
-
await waitFor(() => expect(solicitedButton().disabled).toBe(false));
|
|
190
|
-
await fireEvent.click(solicitedTitle());
|
|
191
|
-
const slot = document.querySelector('.bal-ba-glass-modal-slot')!;
|
|
192
|
-
expect(slot.classList.contains('bas-inset-y-6')).toBe(true);
|
|
193
|
-
await fireEvent.input(document.querySelector('input[type="email"]')!, {
|
|
194
|
-
target: { value: 'ana@block-auth.io' },
|
|
195
|
-
});
|
|
196
|
-
await fireEvent.click(document.getElementById('solicited-data-accept')!);
|
|
197
|
-
expect(document.querySelector('.bal-ba-glass-modal')).toBeNull();
|
|
198
|
-
expect(client.txns.accept).not.toHaveBeenCalled();
|
|
199
|
-
await fireEvent.click(solicitedTitle());
|
|
200
|
-
expect((document.querySelector('input[type="email"]') as HTMLInputElement).value).toBe(
|
|
201
|
-
'ana@block-auth.io',
|
|
202
|
-
);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it('retira un dato opcional cedido al desmarcar Ceder', async () => {
|
|
206
|
-
const client = makeClient(pending);
|
|
207
|
-
client.txns.dataRequest.mockResolvedValue({
|
|
208
|
-
txnId: 7,
|
|
209
|
-
params: [
|
|
210
|
-
{ slug: 'users-email', mode: 'required', status: 'granted', value: 'ana@block-auth.io' },
|
|
211
|
-
{ slug: 'users-phone', mode: 'optional', status: 'granted', value: '+34 600 000 000' },
|
|
212
|
-
],
|
|
213
|
-
});
|
|
214
|
-
await render(TxnsOverviewComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
215
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
216
|
-
await waitFor(() => expect(acceptButton().disabled).toBe(false));
|
|
217
|
-
expect(visibleArrows()).toHaveLength(0);
|
|
218
|
-
await fireEvent.click(solicitedTitle());
|
|
219
|
-
await fireEvent.click(screen.getByLabelText('Share Phone'));
|
|
220
|
-
await fireEvent.click(acceptButton());
|
|
221
|
-
expect(client.txns.accept).toHaveBeenCalledWith({
|
|
222
|
-
lifetime: 3600,
|
|
223
|
-
userParams: {},
|
|
224
|
-
grantedParams: ['users-email'],
|
|
225
|
-
revokedParams: ['users-phone'],
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it('bloquea ACEPTAR y muestra las flechas si se cambia un dato sin decidir', async () => {
|
|
230
|
-
const client = makeClient(pending);
|
|
231
|
-
client.txns.dataRequest.mockResolvedValue({
|
|
232
|
-
txnId: 7,
|
|
233
|
-
params: [{ slug: 'users-email', mode: 'required', status: 'granted', value: 'ana@block-auth.io' }],
|
|
234
|
-
});
|
|
235
|
-
await render(TxnsOverviewComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
236
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
237
|
-
await waitFor(() => expect(acceptButton().disabled).toBe(false));
|
|
238
|
-
await fireEvent.click(solicitedTitle());
|
|
239
|
-
const emailInput = document.querySelector('input[type="email"]') as HTMLInputElement;
|
|
240
|
-
await fireEvent.input(emailInput, { target: { value: 'otra@block-auth.io' } });
|
|
241
|
-
expect(acceptButton().disabled).toBe(true);
|
|
242
|
-
expect(visibleArrows()).toHaveLength(2);
|
|
243
|
-
await fireEvent.click(screen.getByText('Undo'));
|
|
244
|
-
expect(acceptButton().disabled).toBe(false);
|
|
245
|
-
expect(emailInput.value).toBe('ana@block-auth.io');
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it('al guardar vacío un dato cedido deja de cederlo sin enviarlo', async () => {
|
|
249
|
-
const client = makeClient(pending);
|
|
250
|
-
client.txns.dataRequest.mockResolvedValue({
|
|
251
|
-
txnId: 7,
|
|
252
|
-
params: [
|
|
253
|
-
{ slug: 'users-email', mode: 'required', status: 'granted', value: 'ana@block-auth.io' },
|
|
254
|
-
{ slug: 'users-phone', mode: 'optional', status: 'granted', value: '+34 600 000 000' },
|
|
255
|
-
],
|
|
256
|
-
});
|
|
257
|
-
await render(TxnsOverviewComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
258
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
259
|
-
await waitFor(() => expect(acceptButton().disabled).toBe(false));
|
|
260
|
-
await fireEvent.click(solicitedTitle());
|
|
261
|
-
expect(
|
|
262
|
-
document
|
|
263
|
-
.querySelector('.bal-ba-glass-modal')
|
|
264
|
-
?.parentElement?.classList.contains('bal-ba-glass-modal-slot'),
|
|
265
|
-
).toBe(true);
|
|
266
|
-
await fireEvent.click(screen.getByLabelText('Clear field Phone'));
|
|
267
|
-
const phoneSwitch = document.getElementById('solicited-data-share-users-phone') as HTMLButtonElement;
|
|
268
|
-
expect(phoneSwitch.disabled).toBe(true);
|
|
269
|
-
expect(phoneSwitch.getAttribute('aria-checked')).toBe('false');
|
|
270
|
-
await fireEvent.click(screen.getByText('Save'));
|
|
271
|
-
expect(screen.getByText('This data will not be shared')).toBeDefined();
|
|
272
|
-
expect(acceptButton().disabled).toBe(false);
|
|
273
|
-
await fireEvent.click(acceptButton());
|
|
274
|
-
expect(client.txns.accept).toHaveBeenCalledWith({
|
|
275
|
-
lifetime: 3600,
|
|
276
|
-
userParams: {},
|
|
277
|
-
grantedParams: ['users-email'],
|
|
278
|
-
revokedParams: ['users-phone'],
|
|
279
|
-
});
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it('un obligatorio guardado vacío queda pendiente y bloquea ACEPTAR', async () => {
|
|
283
|
-
const client = makeClient(pending);
|
|
284
|
-
client.txns.dataRequest.mockResolvedValue({
|
|
285
|
-
txnId: 7,
|
|
286
|
-
params: [{ slug: 'users-email', mode: 'required', status: 'granted', value: 'ana@block-auth.io' }],
|
|
287
|
-
});
|
|
288
|
-
await render(TxnsOverviewComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
289
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
290
|
-
await waitFor(() => expect(acceptButton().disabled).toBe(false));
|
|
291
|
-
await fireEvent.click(solicitedTitle());
|
|
292
|
-
await fireEvent.click(screen.getByLabelText('Clear field Email'));
|
|
293
|
-
await fireEvent.click(screen.getByText('Save'));
|
|
294
|
-
expect(acceptButton().disabled).toBe(true);
|
|
295
|
-
expect(
|
|
296
|
-
document
|
|
297
|
-
.getElementById('solicited-data-users-email')
|
|
298
|
-
?.closest('.bal-ba-glass-field')
|
|
299
|
-
?.classList.contains('bal-ba-glass-field-pending'),
|
|
300
|
-
).toBe(true);
|
|
301
|
-
await fireEvent.input(document.querySelector('input[type="email"]')!, {
|
|
302
|
-
target: { value: 'otra@block-auth.io' },
|
|
303
|
-
});
|
|
304
|
-
expect(document.getElementById('solicited-data-share-users-email')?.getAttribute('aria-checked')).toBe('true');
|
|
305
|
-
await fireEvent.click(screen.getByText('Save'));
|
|
306
|
-
expect(acceptButton().disabled).toBe(false);
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
it('deja "Datos solicitados" desactivado cuando no hay nada que mostrar', async () => {
|
|
310
|
-
const client = makeClient(pending, {
|
|
311
|
-
uiConfig: { config: { params: { 'users-email': { mode: 'required' } } } },
|
|
312
|
-
});
|
|
313
|
-
client.txns.dataRequest.mockResolvedValue({ txnId: 7, params: [] });
|
|
314
|
-
await render(TxnsOverviewComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
315
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
316
|
-
await waitFor(() => expect(acceptButton().disabled).toBe(false));
|
|
317
|
-
expect(solicitedButton().disabled).toBe(true);
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
it('no bloquea ACEPTAR mientras espera los datos si la app no pide ninguno', async () => {
|
|
321
|
-
const client = makeClient(pending);
|
|
322
|
-
client.txns.dataRequest.mockReturnValue(new Promise(() => undefined));
|
|
323
|
-
await render(TxnsOverviewComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
324
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
325
|
-
await waitFor(() => expect(acceptButton().disabled).toBe(false));
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
it('sin respuesta del servidor mantiene el cálculo con uiConfig', async () => {
|
|
329
|
-
const client = makeClient(pending, {
|
|
330
|
-
uiConfig: { config: { params: { 'users-email': { mode: 'required' } } } },
|
|
331
|
-
});
|
|
332
|
-
await render(TxnsOverviewComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
333
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
334
|
-
await waitFor(() => expect(solicitedButton().disabled).toBe(false));
|
|
335
|
-
expect(acceptButton().disabled).toBe(true);
|
|
336
|
-
await fireEvent.click(solicitedTitle());
|
|
337
|
-
await fireEvent.input(document.querySelector('input[type="email"]')!, {
|
|
338
|
-
target: { value: 'ana@block-auth.io' },
|
|
339
|
-
});
|
|
340
|
-
await waitFor(() => expect(acceptButton().disabled).toBe(false));
|
|
341
|
-
await fireEvent.click(acceptButton());
|
|
342
|
-
expect(client.txns.accept).toHaveBeenCalledWith({
|
|
343
|
-
lifetime: 3600,
|
|
344
|
-
userParams: { 'users-email': 'ana@block-auth.io' },
|
|
345
|
-
grantedParams: [],
|
|
346
|
-
revokedParams: [],
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
it('si el servidor falla mantiene el cálculo con uiConfig', async () => {
|
|
351
|
-
const client = makeClient(pending, {
|
|
352
|
-
uiConfig: { config: { params: { 'users-email': { mode: 'optional' } } } },
|
|
353
|
-
});
|
|
354
|
-
client.txns.dataRequest.mockRejectedValue(new Error('boom'));
|
|
355
|
-
await render(TxnsOverviewComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
356
|
-
await fireEvent.click(screen.getByTestId('txn-pptc-toggle'));
|
|
357
|
-
await waitFor(() => expect(acceptButton().disabled).toBe(false));
|
|
358
|
-
expect(solicitedButton().disabled).toBe(false);
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
it('muestra el error del servidor en los datos solicitados y permite corregir', async () => {
|
|
362
|
-
const client = makeClient(pending);
|
|
363
|
-
client.txns.dataRequest.mockResolvedValue({ txnId: 7, params: [] });
|
|
364
|
-
const { fixture } = await render(TxnsOverviewComponent, {
|
|
365
|
-
providers: [provideBlockAuthClientForTest(client)],
|
|
366
|
-
});
|
|
367
|
-
await waitFor(() => expect(client.txns.dataRequest).toHaveBeenCalledTimes(1));
|
|
368
|
-
client.state.$ui.setKey('acceptTxnError', 'Required data not authorized');
|
|
369
|
-
fixture.detectChanges();
|
|
370
|
-
await waitFor(() =>
|
|
371
|
-
expect(screen.getByRole('alert').textContent).toContain('required data is missing or invalid'),
|
|
372
|
-
);
|
|
373
|
-
await waitFor(() => expect(client.txns.dataRequest).toHaveBeenCalledTimes(2));
|
|
374
|
-
});
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
describe('con la verificación OTP caducada', () => {
|
|
378
|
-
const pending = { requests: [{ id: 7, pre_params: JSON.stringify({ appName: 'Shop' }) }] };
|
|
379
|
-
afterEach(() => resetExtension());
|
|
380
|
-
|
|
381
|
-
it('cambia ACEPTAR por el aviso y abre la extensión sobre la txn', async () => {
|
|
382
|
-
setExtensionInstalled(true);
|
|
383
|
-
const onExtTxn = vi.fn();
|
|
384
|
-
document.addEventListener('ext:txn', onExtTxn);
|
|
385
|
-
await render(TxnsOverviewComponent, {
|
|
386
|
-
providers: [provideBlockAuthClientForTest(makeClient(pending, { isOtpRequired: true }))],
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
expect(screen.getByText(/Enter your code in the Block-Auth extension/)).toBeDefined();
|
|
390
|
-
expect(screen.queryByText('ACCEPT')).toBeNull();
|
|
391
|
-
await fireEvent.click(screen.getByText('Open extension'));
|
|
392
|
-
expect(onExtTxn).toHaveBeenCalledTimes(1);
|
|
393
|
-
document.removeEventListener('ext:txn', onExtTxn);
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
it('sin la extensión manda a la app y no ofrece abrir nada', async () => {
|
|
397
|
-
await render(TxnsOverviewComponent, {
|
|
398
|
-
providers: [provideBlockAuthClientForTest(makeClient(pending, { isOtpRequired: true }))],
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
expect(screen.getByText(/Enter your code in the Block-Auth app/)).toBeDefined();
|
|
402
|
-
expect(screen.queryByText('Open extension')).toBeNull();
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
// A login whose session expired never gets its txn created: the same
|
|
406
|
-
// notice must show on its own, not "No transactions found".
|
|
407
|
-
it('sin transacción muestra el mismo aviso en lugar de "No transactions found"', async () => {
|
|
408
|
-
setExtensionInstalled(true);
|
|
409
|
-
await render(TxnsOverviewComponent, {
|
|
410
|
-
providers: [
|
|
411
|
-
provideBlockAuthClientForTest(
|
|
412
|
-
makeClient({ requests: [] }, { isOtpRequired: true, isSigning: true }),
|
|
413
|
-
),
|
|
414
|
-
],
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
expect(screen.getByText(/Enter your code in the Block-Auth extension/)).toBeDefined();
|
|
418
|
-
expect(screen.queryByText('No transactions found')).toBeNull();
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
});
|