Files
RenewCMS/features/media_page_size_memory.feature
T

129 lines
6.7 KiB
Gherkin

Feature: Media page remembers the chosen page size
As a verified RenewCMS user
I want the page size I choose on the Media page to be remembered
So that I do not have to pick it again each time I come back or refresh
Background:
Given this slice follows features/articles_page_size_memory.feature and extends features/media_pagination_screen.feature; the URL keeps ?size= as in that spec and no visual or API change is made
And the size options stay "5 per page", "25 per page", "50 per page", "100 per page" and the default stays 25
And the chosen size is stored in localStorage under the key renewcms-page-size-media as the bare number (for example 5), one key per paginated list; Articles uses renewcms-page-size-articles and Activity renewcms-page-size-activity, and the three do not affect each other
And a MEDIA_PAGE_SIZE_KEY constant joins ARTICLES_PAGE_SIZE_KEY and ACTIVITY_PAGE_SIZE_KEY in web/src/lib/pageSizeMemory.ts and the existing readStoredPageSize, storePageSize and resolvePageSize helpers are reused
And only choosing a size in the page-size select writes the stored value; loading a URL never writes it
And an explicit valid ?size= in the URL is authoritative for that load and does not change the stored value
And an invalid ?size= in the URL falls back to 25, never to the stored value, and is replaced in the URL (features/media_pagination_screen.feature)
And a stored value that is not 5, 25, 50 or 100 is treated as absent
And localStorage that is unavailable or throws on read or write never raises an error or breaks the page: reads act as absent and writes are ignored
And logout does not clear the stored size
And a size change still resets page to 1 and drops page from the URL
And the Duplicates tab ignores the stored size (it always loads with size=100) and never writes it
And the picker and hash lookups ignore the stored size (fixed size=25 and size=100)
And the requests are GET /v1/media/?filter=F&sort=S&page=P&size=Z as in features/media_pagination_api.feature
Scenario Outline: Choosing a size stores it
Given nothing is stored and the user is on /media
When the user chooses "<label>" in the page-size select
Then localStorage renewcms-page-size-media is "<stored>"
And on success the URL is <url>
Examples:
| label | stored | url |
| 5 per page | 5 | /media?size=5 |
| 25 per page | 25 | /media |
| 50 per page | 50 | /media?size=50 |
| 100 per page | 100 | /media?size=100 |
Scenario: The stored size is restored when the page is opened without a size
Given localStorage renewcms-page-size-media is "5"
When the user navigates to /media
Then GET ...&page=1&size=5 is sent
And the page-size select reads "5 per page"
And on success the URL is replaced (no history entry) by /media?size=5
Scenario: The size survives leaving the page and coming back
Given the user chose "5 per page" on /media
When the user navigates to /, then back to /media
Then GET ...&size=5 is sent and the select reads "5 per page"
Scenario: The size survives a full page refresh
Given the user chose "5 per page" on /media
When the page is reloaded on /media?size=5, or on /media with the URL typed in without a size
Then GET ...&size=5 is sent and the select reads "5 per page"
Scenario: The stored size is kept across paging, search, tabs, sort and view
Given localStorage renewcms-page-size-media is "50" and the user is on /media?size=50
When the user activates Next, switches to the "Unused" tab, sorts by "Largest", switches to list view or searches "wall"
Then every request carries size=50 and the stored value stays "50"
Scenario: Changing the size again replaces the stored one
Given localStorage renewcms-page-size-media is "5"
When the user chooses "100 per page"
Then localStorage renewcms-page-size-media is "100"
And the next visit to /media without a size sends size=100
Scenario: Returning to 25 is remembered too
Given localStorage renewcms-page-size-media is "5"
When the user chooses "25 per page"
Then localStorage renewcms-page-size-media is "25"
And the next visit to /media sends size=25 and the URL stays /media
Scenario: An explicit size in the URL wins and is not stored
Given localStorage renewcms-page-size-media is "5"
When the user navigates to /media?size=100
Then GET ...&size=100 is sent and the select reads "100 per page"
And localStorage renewcms-page-size-media is still "5"
And a later visit to /media sends size=5
Scenario: An explicit page with no size uses the stored size
Given localStorage renewcms-page-size-media is "5"
When the user navigates to /media?page=3
Then GET ...&page=3&size=5 is sent and on success the URL is replaced by /media?page=3&size=5
Scenario Outline: An invalid stored value falls back to 25
Given localStorage renewcms-page-size-media is "<stored>"
When the user navigates to /media
Then GET ...&page=1&size=25 is sent, the select reads "25 per page" and the URL is /media
Examples:
| stored |
| 10 |
| abc |
| 0 |
| -5 |
| 25.5 |
| |
Scenario: An invalid size in the URL ignores the stored one
Given localStorage renewcms-page-size-media is "5"
When the user navigates to /media?size=10
Then GET ... is sent with size=25 and the URL is replaced by /media
And localStorage renewcms-page-size-media is still "5"
Scenario Outline: Unavailable storage never breaks the page
Given localStorage <failure>
When the user navigates to /media
Then GET ...&page=1&size=25 is sent, the page renders and no error is shown
When the user chooses "50 per page"
Then GET ...&page=1&size=50 is sent and the URL is /media?size=50
Examples:
| failure |
| throws on getItem |
| throws on setItem (quota) |
| is undefined |
Scenario: Logging out keeps the stored size
Given localStorage renewcms-page-size-media is "5"
When the user logs out and logs in again and opens /media
Then GET ...&size=5 is sent
Scenario: The three lists keep separate sizes
Given localStorage has renewcms-page-size-articles "50", renewcms-page-size-activity "100" and renewcms-page-size-media "5"
When the user opens /article, /activity and /media in turn without a size
Then they send size=50, size=100 and size=5 respectively
Scenario: The Duplicates tab ignores the stored size
Given localStorage renewcms-page-size-media is "5"
When the user opens /media?filter=duplicates
Then the requests carry size=100, the stored value stays "5", and returning to the "All" tab sends size=5