Skip to content

Commit 8b02688

Browse files
committed
feat: add tests, refactor
1 parent 2876d04 commit 8b02688

File tree

16 files changed

+445
-270
lines changed

16 files changed

+445
-270
lines changed

dev-test/config.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ site_url: https://example.com
55

66
publish_mode: editorial_workflow
77
media_folder: assets/uploads
8-
pagination:
9-
enabled: false
10-
per_page: 5
118

129
collections: # A list of collections the CMS should be able to edit
1310
- name: 'posts' # Used in routes, ie.: /admin/collections/:slug/edit
@@ -22,7 +19,7 @@ collections: # A list of collections the CMS should be able to edit
2219
create: true # Allow users to create new documents in this collection
2320
pagination:
2421
enabled: true
25-
per_page: 8
22+
per_page: 10
2623
editor:
2724
visualEditing: true
2825
view_filters:

docs/PAGINATION_IMPLEMENTATION_PLAN.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,9 @@ pagination?: boolean | {
251251
**Files to Modify:**
252252
- `/packages/decap-cms-core/src/actions/entries.ts` - All entry action creators
253253
- `/packages/decap-cms-core/src/backend.ts` - Check for incompatible features
254-
### Phase 8: Testing & Documentation
255-
**Goal:** Ensure quality and provide documentation
254+
255+
### Phase 8: Testing
256+
**Goal:** Ensure quality
256257

257258
**Tasks:**
258259
1. Unit tests:
@@ -271,18 +272,10 @@ pagination?: boolean | {
271272
- User workflows with pagination
272273
- Large collections (1000+ entries)
273274
- i18n collections with many locales/entries
274-
4. Documentation:
275-
- Configuration guide
276-
- Backend implementation guide for other backends
277-
- Migration guide for users
278275
5. Performance testing:
279276
- Measure improvement with large collections
280277
- Memory usage comparison
281278

282-
**Files to Create:**
283-
- `/docs/pagination.md` - User documentation
284-
- `/docs/pagination-backend-implementation.md` - Developer guide
285-
286279
### Phase 7: User Preferences & Polish
287280
**Goal:** Make pagination user-friendly and persistent
288281

packages/decap-cms-backend-github/src/implementation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ export default class GitHub implements Implementation {
435435
depth,
436436
}).then(files => {
437437
const filtered = files.filter(file => filterByExtension(file, extension));
438-
438+
439439
if (usePagination) {
440440
// Paginated: return only the requested page
441441
const result = this.getCursorAndFiles(filtered, page, pageSize);

packages/decap-cms-backend-test/src/implementation.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export default class TestBackend implements Implementation {
176176
};
177177
const meta = cursor.meta!;
178178
const currentPageSize = meta.get('pageSize', DEFAULT_PAGE_SIZE);
179-
179+
180180
const newIndex = (() => {
181181
if (action === 'next') {
182182
return (index as number) + 1;
@@ -198,7 +198,10 @@ export default class TestBackend implements Implementation {
198198
data: f.content as string,
199199
file: { path: f.path, id: f.path },
200200
}));
201-
const entries = allEntries.slice(newIndex * currentPageSize, newIndex * currentPageSize + currentPageSize);
201+
const entries = allEntries.slice(
202+
newIndex * currentPageSize,
203+
newIndex * currentPageSize + currentPageSize,
204+
);
202205
const newCursor = getCursor(folder, extension, allEntries, newIndex, depth, currentPageSize);
203206
return Promise.resolve({ entries, cursor: newCursor });
204207
}
@@ -221,14 +224,12 @@ export default class TestBackend implements Implementation {
221224
const pageSize = options?.pageSize ?? DEFAULT_PAGE_SIZE;
222225
const page = options?.page ?? 1;
223226
const usePagination = options?.pagination ?? false;
224-
227+
225228
const cursor = getCursor(folder, extension, entries, page - 1, depth, pageSize);
226-
229+
227230
// If pagination is enabled, return only the requested page
228231
// Otherwise, return all entries (for backward compatibility)
229-
const ret = usePagination
230-
? take(entries.slice((page - 1) * pageSize), pageSize)
231-
: entries;
232+
const ret = usePagination ? take(entries.slice((page - 1) * pageSize), pageSize) : entries;
232233
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
233234
// @ts-ignore
234235
ret[CURSOR_COMPATIBILITY_SYMBOL] = cursor;

0 commit comments

Comments
 (0)