This study case belongs to Essential Academy program from Caio & Mike
Essential Feed – Study Case
Image Feed Feature
Initial Story
Story
As a user
I want the app to load the feed
So I can see the feed
Acceptance Criteria
Given a user
When the user opens the feed
Then the feed is displayed
BDD Specs
Story: Customer requests to see the feed
Narrative #1
As an online customer
I want the app to automatically load my latest image feed
So I can always enjoy the newest images of my friends
Scenarios (Acceptance criteria):
Given the customer has connectivity
When the customer requests to see the feed
Then the app should display the latest feed from remote
And replace the cache with the new feed
Narrative #2
As an offline customer
I want the app to show the latest saved version of my image feed
So I can always enjoy images of my friends
Scenarios (Acceptance criteria):
Given the customer doesn't have connectivity
And there's a cached version of the feed
And the cache is less than seven days old
When the customer requests to see the feed
Then the app should display the latest feed saved
Given the customer doesn't have connectivity
And there's a cached version of the feed
And the cache is seven days old or more
When the customer requests to see the feed
Then the app should display an error message
Given the customer doesn't have connectivity
And the cache is empty
When the customer requests to see the feed
Then the app should display an error message
Use Cases
Load Feed From Remote Use Case
Data:
- URL
Primary course (happy path):
- Execute “Load Image Feed” command with above data.
- System downloads data from the URL.
- System validates downloaded data.
- System creates image feed from valid data.
- System delivers image feed.
Invalid data – error course (sad path):
- System delivers invalid data error.
No connectivity – error course (sad path):
- System delivers connectivity error.
Load Feed From Cache Use Case
Data:
- Max age (7 days)
Primary course (happy path):
- Execute “Load Image Feed” command with above data.
- System retrieves feed data from cache.
- System validates cache is less than seven days old.
- System creates image feed from cached data.
- System delivers image feed.
Retrieval error course (sad path):
- System delivers error.
Expired cache course (sad path):
- System delivers no feed images.
No cache course (sad path):
- System delivers no feed images.
Validate Feed Cache Cache Use Case
Data:
- Max age (7 days)
Primary course (happy path):
- Execute “Validate” command with above data.
- System retrieves feed data from cache.
- System validates cache is less than seven days old.
Retrieval error course (sad path):
- System deletes cache.
Expired cache course (sad path):
- System deletes cache.
No cache course (sad path):
- System delivers no feed images.
Cache Feed Use Case
Data:
- Image Feed
Primary course (happy path):
- Execute “Save Image Feed” command with above data.
- System deletes old cache data.
- System encodes image feed.
- System timestamps the new cache.
- System saves new cache data.
- System delivers success message.
Deleting error course (sad path):
- System delivers error.
Saving error course (sad path):
- System delivers error.
Flow Chart
Architecture
Model Specs
Feed Image
Property | Type |
---|---|
id |
UUID |
description |
String (optional) |
location |
String (optional) |
url |
URL (optional) |
Payload contract
// GET *URL* (TBD)
// 200 RESPONSE
{
"items": [
{
"id": "a UUID",
"description": "a description",
"location": "a location",
"image": "https://a-image.url"
},
{
"id": "another UUID",
"description": "another description",
"image": "https://another-image.url"
},
{
"id": "even another UUID",
"location": "even another location",
"image": "https://even-another-image.url"
},
{
"id": "yet another UUID",
"image": "https://a-image.url"
}
// ...
]
}