mirror of
https://github.com/documenso/documenso.git
synced 2026-08-26 00:02:43 +10:00
fix(templates): use defaults for zero pagination values
This commit is contained in:
@@ -41,6 +41,8 @@ export default function TemplatesPage() {
|
||||
const [findTemplateSearchParams] = useQueryStates(templatesSearchParams, {
|
||||
history: 'push',
|
||||
});
|
||||
const page = findTemplateSearchParams.page || undefined;
|
||||
const perPage = findTemplateSearchParams.perPage || undefined;
|
||||
|
||||
const isOrgView = findTemplateSearchParams.view === 'organisation';
|
||||
const showOrgFilter = organisation.type !== OrganisationType.PERSONAL;
|
||||
@@ -62,8 +64,8 @@ export default function TemplatesPage() {
|
||||
|
||||
const teamTemplatesQuery = trpc.template.findTemplates.useQuery(
|
||||
{
|
||||
page: findTemplateSearchParams.page ?? undefined,
|
||||
perPage: findTemplateSearchParams.perPage ?? undefined,
|
||||
page,
|
||||
perPage,
|
||||
folderId,
|
||||
},
|
||||
{
|
||||
@@ -73,8 +75,8 @@ export default function TemplatesPage() {
|
||||
|
||||
const orgTemplatesQuery = trpc.template.findOrganisationTemplates.useQuery(
|
||||
{
|
||||
page: findTemplateSearchParams.page ?? undefined,
|
||||
perPage: findTemplateSearchParams.perPage ?? undefined,
|
||||
page,
|
||||
perPage,
|
||||
},
|
||||
{
|
||||
enabled: isOrgView,
|
||||
|
||||
@@ -149,6 +149,18 @@ test.describe('Organisation Templates - Listing', () => {
|
||||
await expect(page.getByText(orgTemplate.title)).toBeVisible();
|
||||
});
|
||||
|
||||
test('should use default pagination when URL values are zero', async ({ page }) => {
|
||||
const { memberB, teamB, orgTemplate } = await seedOrgTemplateScenario();
|
||||
|
||||
await apiSignin({
|
||||
page,
|
||||
email: memberB.email,
|
||||
redirectPath: `/t/${teamB.url}/templates?view=organisation&page=0&perPage=0`,
|
||||
});
|
||||
|
||||
await expect(page.getByText(orgTemplate.title)).toBeVisible();
|
||||
});
|
||||
|
||||
test('should not show private templates from other teams under the organisation view', async ({ page }) => {
|
||||
const { ownerA, teamA, memberB, teamB } = await seedOrgTemplateScenario();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user