Fix endcustomer package allocation and event create gating
This commit is contained in:
@@ -79,6 +79,7 @@ vi.mock('../../api', () => ({
|
||||
purchased_at: null,
|
||||
expires_at: null,
|
||||
package_limits: null,
|
||||
linked_events_count: 0,
|
||||
},
|
||||
],
|
||||
activePackage: {
|
||||
@@ -95,6 +96,7 @@ vi.mock('../../api', () => ({
|
||||
purchased_at: null,
|
||||
expires_at: null,
|
||||
package_limits: null,
|
||||
linked_events_count: 0,
|
||||
},
|
||||
}),
|
||||
}));
|
||||
@@ -295,6 +297,49 @@ describe('MobileEventsPage', () => {
|
||||
expect(await screen.findByText('New event')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the create button for available endcustomer packages', async () => {
|
||||
vi.mocked(api.getTenantPackagesOverview).mockResolvedValueOnce({
|
||||
packages: [
|
||||
{
|
||||
id: 3,
|
||||
package_id: 3,
|
||||
package_name: 'Classic',
|
||||
package_type: 'endcustomer',
|
||||
included_package_slug: null,
|
||||
active: true,
|
||||
used_events: 0,
|
||||
remaining_events: null,
|
||||
price: 120,
|
||||
currency: 'EUR',
|
||||
purchased_at: null,
|
||||
expires_at: null,
|
||||
package_limits: null,
|
||||
linked_events_count: 0,
|
||||
},
|
||||
],
|
||||
activePackage: {
|
||||
id: 3,
|
||||
package_id: 3,
|
||||
package_name: 'Classic',
|
||||
package_type: 'endcustomer',
|
||||
included_package_slug: null,
|
||||
active: true,
|
||||
used_events: 0,
|
||||
remaining_events: null,
|
||||
price: 120,
|
||||
currency: 'EUR',
|
||||
purchased_at: null,
|
||||
expires_at: null,
|
||||
package_limits: null,
|
||||
linked_events_count: 0,
|
||||
},
|
||||
});
|
||||
|
||||
render(<MobileEventsPage />);
|
||||
|
||||
expect(await screen.findByText('New event')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides the create button when no remaining events are available', async () => {
|
||||
vi.mocked(api.getTenantPackagesOverview).mockResolvedValueOnce({
|
||||
packages: [
|
||||
@@ -336,4 +381,48 @@ describe('MobileEventsPage', () => {
|
||||
expect(await screen.findByText('Demo Event')).toBeInTheDocument();
|
||||
expect(screen.queryByText('New event')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides the create button for consumed endcustomer packages', async () => {
|
||||
vi.mocked(api.getTenantPackagesOverview).mockResolvedValueOnce({
|
||||
packages: [
|
||||
{
|
||||
id: 4,
|
||||
package_id: 4,
|
||||
package_name: 'Classic',
|
||||
package_type: 'endcustomer',
|
||||
included_package_slug: null,
|
||||
active: true,
|
||||
used_events: 0,
|
||||
remaining_events: null,
|
||||
price: 120,
|
||||
currency: 'EUR',
|
||||
purchased_at: null,
|
||||
expires_at: null,
|
||||
package_limits: null,
|
||||
linked_events_count: 1,
|
||||
},
|
||||
],
|
||||
activePackage: {
|
||||
id: 4,
|
||||
package_id: 4,
|
||||
package_name: 'Classic',
|
||||
package_type: 'endcustomer',
|
||||
included_package_slug: null,
|
||||
active: true,
|
||||
used_events: 0,
|
||||
remaining_events: null,
|
||||
price: 120,
|
||||
currency: 'EUR',
|
||||
purchased_at: null,
|
||||
expires_at: null,
|
||||
package_limits: null,
|
||||
linked_events_count: 1,
|
||||
},
|
||||
});
|
||||
|
||||
render(<MobileEventsPage />);
|
||||
|
||||
expect(await screen.findByText('Demo Event')).toBeInTheDocument();
|
||||
expect(screen.queryByText('New event')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user