feat: setup logs retention by max file size
This commit is contained in:
1 parent
70c8492f4f
commit
f914eae3c5
44 files changed
+2316
-161
No files matched your search
+91
-2
@@ -168,6 +168,8 @@ const updateRunningVersion = 'v2.2.0-beta'
|
||||
const workspaceSettingsBody = {
|
||||
version: updateRunningVersion,
|
||||
activity_retention_days: 90,
|
||||
activity_retention_max_gb: 0,
|
||||
activity_log_size_bytes: 0,
|
||||
activity_last_cleanup_at: '2026-10-06T03:00:00Z',
|
||||
activity_last_cleanup_removed: 142,
|
||||
activity_next_cleanup_at: '2026-10-07T03:00:00Z',
|
||||
@@ -2401,8 +2403,8 @@ function settingsBody(body: unknown): ApiMock {
|
||||
return { status: 200, body }
|
||||
}
|
||||
|
||||
async function scrollSettingsToCleanup(page: Page) {
|
||||
const top = (page.viewportSize()?.width ?? 1440) < 768 ? 480 : 300
|
||||
async function scrollSettingsToCleanup(page: Page, desktopTop = 300, mobileTop = 480) {
|
||||
const top = (page.viewportSize()?.width ?? 1440) < 768 ? mobileTop : desktopTop
|
||||
await page.evaluate((top) => {
|
||||
const card = document.querySelector<HTMLElement>('[data-testid="settings-card"]')
|
||||
if (card?.parentElement && !card.parentElement.querySelector('[data-scroll-room]')) {
|
||||
@@ -2499,6 +2501,92 @@ function successState(settings: ApiMock) {
|
||||
)
|
||||
}
|
||||
|
||||
const retentionPatchPath = 'PATCH /v1/settings/'
|
||||
const retentionGetPath = 'GET /v1/settings/'
|
||||
const retentionFiveGb = { activity_retention_max_gb: 5, activity_log_size_bytes: 3435973837 }
|
||||
|
||||
function retentionApi(
|
||||
settings: Record<string, unknown>,
|
||||
overrides: Record<string, ApiMock> = {},
|
||||
): Record<string, ApiMock> {
|
||||
return cleanupApi(settingsBody(purgeSettingsBody()), {
|
||||
[retentionGetPath]: settingsBody({ ...workspaceSettingsBody, ...settings }),
|
||||
...overrides,
|
||||
})
|
||||
}
|
||||
|
||||
function retentionState(
|
||||
api: Record<string, ApiMock>,
|
||||
steps?: (page: Page) => Promise<void>,
|
||||
exception?: DiffException,
|
||||
): VisualState {
|
||||
const scroll = (page: Page) => scrollSettingsToCleanup(page, 560, 936)
|
||||
return {
|
||||
path: '/settings',
|
||||
now: boardNow,
|
||||
api,
|
||||
exception,
|
||||
steps: async (page) => {
|
||||
await scroll(page)
|
||||
await steps?.(page)
|
||||
await page.mouse.move(0, 0)
|
||||
await scroll(page)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
function chooseRetention(control: string, option: string) {
|
||||
return async (page: Page) => {
|
||||
await page.locator(`[aria-labelledby="${control}"]`).click()
|
||||
await page.getByRole('option', { name: option, exact: true }).click()
|
||||
}
|
||||
}
|
||||
|
||||
const retentionStates: Record<string, VisualState> = {
|
||||
'Default, 90 days or 5 GB': retentionState(
|
||||
retentionApi(
|
||||
{ activity_retention_max_gb: 1, activity_log_size_bytes: 3435973837 },
|
||||
{
|
||||
[retentionPatchPath]: settingsBody({
|
||||
...workspaceSettingsBody,
|
||||
...retentionFiveGb,
|
||||
}),
|
||||
},
|
||||
),
|
||||
async (page) => {
|
||||
await chooseRetention('retention-size-label', '5 GB')(page)
|
||||
await page.getByText('Saved', { exact: true }).first().waitFor()
|
||||
},
|
||||
),
|
||||
'Age only (no size limit)': retentionState(retentionApi({})),
|
||||
'Size only (forever)': retentionState(
|
||||
retentionApi({ ...retentionFiveGb, activity_retention_days: 0 }),
|
||||
),
|
||||
'Shortening the period': retentionState(
|
||||
retentionApi(retentionFiveGb),
|
||||
chooseRetention('retention-label', '30 days'),
|
||||
),
|
||||
Forever: retentionState(
|
||||
retentionApi({
|
||||
activity_retention_days: 0,
|
||||
activity_last_cleanup_at: null,
|
||||
activity_next_cleanup_at: null,
|
||||
}),
|
||||
),
|
||||
'Save error': retentionState(
|
||||
retentionApi({}, { [retentionPatchPath]: { status: 500 } }),
|
||||
async (page) => {
|
||||
await chooseRetention('retention-label', '365 days')(page)
|
||||
await page.getByText("Couldn't save the retention period").waitFor()
|
||||
},
|
||||
{
|
||||
maxPercent: 13,
|
||||
reason: 'Board draws 28 px buttons on mobile; foundations.md requires 44 px touch targets',
|
||||
approvedBy: 'user',
|
||||
},
|
||||
),
|
||||
}
|
||||
|
||||
const cleanupStates: Record<string, VisualState> = {
|
||||
'Default: off, never run': cleanupState(cleanupApi(settingsBody(purgeSettingsBody()))),
|
||||
'On: 30 days, last run': cleanupState(cleanupApi(settingsBody(purgeOnBody))),
|
||||
@@ -3155,6 +3243,7 @@ export const visualStates: Record<string, Record<string, VisualState>> = {
|
||||
},
|
||||
settings: {
|
||||
...cleanupStates,
|
||||
...retentionStates,
|
||||
'Up to date': { path: '/settings', skip: 'clock-sensitive' },
|
||||
Checking: {
|
||||
path: '/settings',
|
||||
|
||||
Reference in new issue
Block a user