diff --git a/config/custom-environment-variables.json b/config/custom-environment-variables.json index f8590c9f7..cdacb42d8 100644 --- a/config/custom-environment-variables.json +++ b/config/custom-environment-variables.json @@ -11,6 +11,9 @@ "__format": "json" } }, + "source": { + "commitsPerPage": "COMMITS_PER_PAGE" + }, "supportWebsite": "SUPPORT_WEBSITE", "fallbackPreferredSeed": { "__name": "FALLBACK_PREFERRED_SEED", diff --git a/config/default.json b/config/default.json index f6e43023d..9fd2c5e3b 100644 --- a/config/default.json +++ b/config/default.json @@ -16,6 +16,9 @@ } ] }, + "source": { + "commitsPerPage": 30 + }, "supportWebsite": "https://radicle.zulipchat.com", "fallbackPreferredSeed": { "hostname": "seed.radicle.garden", diff --git a/module.d.ts b/module.d.ts index 71193ab34..6f273d69c 100644 --- a/module.d.ts +++ b/module.d.ts @@ -10,6 +10,9 @@ declare module "virtual:*" { defaultHttpdScheme: string; pinned: { baseUrl: BaseUrl }[]; }; + source: { + commitsPerPage: number; + }; reactions: string[]; supportWebsite: string; fallbackPreferredSeed: BaseUrl; diff --git a/playwright.config.ts b/playwright.config.ts index 90a2865b8..c11291942 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -82,10 +82,19 @@ const config: PlaywrightTestConfig = { }, ], - webServer: { - command: "npm run start -- --strictPort --port 3001", - port: 3001, - }, + webServer: [ + { + command: "npm run start -- --strictPort --port 3001", + port: 3001, + }, + // Required by test tests/e2e/project/commits.spec.ts "loading more commits, adds them to the commits list" + { + command: "npm run start -- --strictPort --port 3002", + port: 3002, + // eslint-disable-next-line @typescript-eslint/naming-convention + env: { COMMITS_PER_PAGE: "4" }, + }, + ], }; export default config; diff --git a/src/views/projects/History.svelte b/src/views/projects/History.svelte index 56ba1044d..a8bc47fa2 100644 --- a/src/views/projects/History.svelte +++ b/src/views/projects/History.svelte @@ -9,7 +9,7 @@ } from "@http-client"; import type { ProjectRoute } from "./router"; - import { COMMITS_PER_PAGE } from "./router"; + import config from "virtual:config"; import { HttpdClient } from "@http-client"; import { baseUrlToString } from "@app/lib/utils"; import { groupCommits } from "@app/lib/commit"; @@ -58,9 +58,9 @@ const response = await api.project.getAllCommits(project.id, { parent: allCommitHeaders[0].id, page, - perPage: COMMITS_PER_PAGE, + perPage: config.source.commitsPerPage, }); - allCommitHeaders = response; + allCommitHeaders = [...allCommitHeaders, ...response]; } catch (e) { error = e; } diff --git a/src/views/projects/router.ts b/src/views/projects/router.ts index d04a4177d..c8b0e0026 100644 --- a/src/views/projects/router.ts +++ b/src/views/projects/router.ts @@ -29,7 +29,6 @@ import { handleError, unreachableError } from "@app/views/projects/error"; import { HttpdClient } from "@http-client"; import { ResponseError, ResponseParseError } from "@http-client/lib/fetcher"; -export const COMMITS_PER_PAGE = 30; export const PATCHES_PER_PAGE = 10; export const ISSUES_PER_PAGE = 10; @@ -524,7 +523,7 @@ async function loadHistoryView( await api.project.getAllCommits(project.id, { parent: commitId, page: 0, - perPage: COMMITS_PER_PAGE, + perPage: config.source.commitsPerPage, }), ]); diff --git a/tests/e2e/project/commits.spec.ts b/tests/e2e/project/commits.spec.ts index 0c83b03f2..1438ae014 100644 --- a/tests/e2e/project/commits.spec.ts +++ b/tests/e2e/project/commits.spec.ts @@ -87,6 +87,17 @@ test("peer and branch switching", async ({ page }) => { } }); +test("loading more commits, adds them to the commits list", async ({ + page, +}) => { + await page.goto(`http://localhost:3002${sourceBrowsingUrl}`); + await page.getByRole("button", { name: "Commits" }).click(); + await expect(page.locator("div > div > .teaser")).toHaveCount(4); + + await page.getByRole("button", { name: "More" }).click(); + await expect(page.locator("div > div > .teaser")).toHaveCount(8); +}); + test("commit messages with double colon not converted into single colon", async ({ page, }) => {