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, {
|
const [findTemplateSearchParams] = useQueryStates(templatesSearchParams, {
|
||||||
history: 'push',
|
history: 'push',
|
||||||
});
|
});
|
||||||
|
const page = findTemplateSearchParams.page || undefined;
|
||||||
|
const perPage = findTemplateSearchParams.perPage || undefined;
|
||||||
|
|
||||||
const isOrgView = findTemplateSearchParams.view === 'organisation';
|
const isOrgView = findTemplateSearchParams.view === 'organisation';
|
||||||
const showOrgFilter = organisation.type !== OrganisationType.PERSONAL;
|
const showOrgFilter = organisation.type !== OrganisationType.PERSONAL;
|
||||||
@@ -62,8 +64,8 @@ export default function TemplatesPage() {
|
|||||||
|
|
||||||
const teamTemplatesQuery = trpc.template.findTemplates.useQuery(
|
const teamTemplatesQuery = trpc.template.findTemplates.useQuery(
|
||||||
{
|
{
|
||||||
page: findTemplateSearchParams.page ?? undefined,
|
page,
|
||||||
perPage: findTemplateSearchParams.perPage ?? undefined,
|
perPage,
|
||||||
folderId,
|
folderId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -73,8 +75,8 @@ export default function TemplatesPage() {
|
|||||||
|
|
||||||
const orgTemplatesQuery = trpc.template.findOrganisationTemplates.useQuery(
|
const orgTemplatesQuery = trpc.template.findOrganisationTemplates.useQuery(
|
||||||
{
|
{
|
||||||
page: findTemplateSearchParams.page ?? undefined,
|
page,
|
||||||
perPage: findTemplateSearchParams.perPage ?? undefined,
|
perPage,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enabled: isOrgView,
|
enabled: isOrgView,
|
||||||
|
|||||||
@@ -149,6 +149,18 @@ test.describe('Organisation Templates - Listing', () => {
|
|||||||
await expect(page.getByText(orgTemplate.title)).toBeVisible();
|
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 }) => {
|
test('should not show private templates from other teams under the organisation view', async ({ page }) => {
|
||||||
const { ownerA, teamA, memberB, teamB } = await seedOrgTemplateScenario();
|
const { ownerA, teamA, memberB, teamB } = await seedOrgTemplateScenario();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user