feat(mp): add Mercado Pago reauthorization notice and status card components

- Implemented MpReauthNotice component to notify users when reauthorization is needed.
- Created MpStatusCard component to display the current status of the Mercado Pago account.
- Added utility functions and constants for handling Mercado Pago status and messages.
- Introduced hooks for managing the connection and disconnection of Mercado Pago accounts.
- Developed a disconnect confirmation modal for user actions.
- Added tests for the new functionality and utility functions.
- Defined schemas for Mercado Pago account status and callback reasons in shared package.
This commit is contained in:
Jose Selesan
2026-10-07 12:00:38 -03:00
parent e03f510874
commit 21a4c69f38
64 changed files with 3154 additions and 425 deletions

View File

@@ -10,9 +10,6 @@ const db = {
groupMember: {
create: mock(),
},
merchantAccount: {
findUnique: mock(),
},
};
mock.module('@/lib/prisma', () => ({
@@ -171,7 +168,6 @@ describe('groups routes', () => {
});
it('creates a group with billing configuration', async () => {
prisma.merchantAccount.findUnique.mockResolvedValue({ id: 'merchant-1', userId });
prisma.group.create.mockResolvedValue({
...group,
days: ['MONDAY'],
@@ -227,8 +223,16 @@ describe('groups routes', () => {
});
});
it('rejects creating a group without a linked merchant account', async () => {
prisma.merchantAccount.findUnique.mockResolvedValue(null);
it('creates a group without Mercado Pago linked, since linking is optional', async () => {
prisma.group.create.mockResolvedValue({
...group,
days: ['MONDAY'],
time: '09:00',
capacity: 20,
price: 500,
billingType: 'MONTHLY',
dueDay: 5,
});
const res = await makeApp({ id: userId }).request('/groups', {
method: 'POST',
@@ -244,9 +248,8 @@ describe('groups routes', () => {
headers: { 'Content-Type': 'application/json' },
});
expect(res.status).toBe(409);
expect(await res.json()).toMatchObject({ code: 'payment_not_setup' });
expect(prisma.group.create).not.toHaveBeenCalled();
expect(res.status).toBe(201);
expect(prisma.group.create).toHaveBeenCalled();
});
it('rejects creating a group with an invalid payload', async () => {