-
Notifications
You must be signed in to change notification settings - Fork 0
[Issue #96]: Opportunity listing page (first pass) #97
Conversation
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
---|---|---|---|
🟢 | Statements | 83.87% (+0.3% 🔼) |
879/1048 |
🟡 | Branches | 68.25% (-0.14% 🔻) |
230/337 |
🟡 | Functions | 76.11% (+0.09% 🔼) |
172/226 |
🟢 | Lines | 83.45% (+0.32% 🔼) |
827/991 |
Show new covered files 🐣
St.❔ |
File | Statements | Branches | Functions | Lines |
---|---|---|---|---|---|
🟢 | ... / OpportunityListingAPI.ts |
88.89% | 100% | 75% | 88.89% |
🟢 | ... / isSummary.ts |
100% | 100% | 100% | 100% |
Show files with reduced coverage 🔻
St.❔ |
File | Statements | Branches | Functions | Lines |
---|---|---|---|---|---|
🔴 | src/errors.ts | 51.72% | 50% (-7.14% 🔻) |
50% | 51.72% |
Test suite run success
175 tests passing in 57 suites.
Report generated by 🧪jest coverage report action from 9a11a74
@@ -69,7 +65,7 @@ export default abstract class BaseApi { | |||
basePath: string, | |||
namespace: string, | |||
subPath: string, | |||
queryParamData: QueryParamData, | |||
queryParamData?: QueryParamData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all queryParamData / searchInput references need to be an optional param because they're only used for search (SearchOpportunityAPI
class) and not when the derived OpportunityListingAPI
class is used.
@@ -0,0 +1,24 @@ | |||
import "server-only"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only ever run this code on the next server
@@ -32,6 +32,7 @@ export function getNextRoutes(src: string): string[] { | |||
.replace("/page.tsx", "") | |||
.replace(/\[locale\]/g, "") | |||
.replace(/\\/g, "/") | |||
.replace(/\[id\]/g, "1") // for id-based routes like /opportunity/[id] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allow pa11y to run on the opportunity listing page by just setting any [id]
found to 1 - resulting in /opportunity/1
@@ -12,6 +12,7 @@ jest.mock("../../src/utils/getRoutes", () => { | |||
|
|||
const mockedListPaths = listPaths as jest.MockedFunction<typeof listPaths>; | |||
|
|||
// TODO: https://github.com/navapbc/simpler-grants-gov/issues/98 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test is a little wonky rn - it's not actually mocking properly so it pulls what the sitemap actually pulls (so we have to update the test every time there's a new route - which is not really testing the functions in getRoutes
in isolation) - so there's a ticket to come back to this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
{Object.entries(opportunity.data).map(([key, value]) => ( | ||
<tr key={key}> | ||
<td className="word-wrap">{key}</td> | ||
<td className="word-wrap">{JSON.stringify(value)}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a small bit of special logic for the summary field so that it doesn't print out as the full JSON, but instead pulls out each of the fields? Just to make it look a little bit nicer / make it look like we've done a lot more and are truly just waiting on shoving it into whatever designs.
So, rather than summary
with a value of { ... }
(the whole object), do something like (in hacky python pseudo-code):
for key, value in obj.items():
if key == "summary":
for summary_key, summary_value in value.items():
print(summary_key)
print(JSON.stringify(summary_value)
else:
print(key)
print(value)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @chouinar I added this:
return meta; | ||
} | ||
|
||
export default async function OpportunityListing({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still catching up on whether or not making a page async affects ability to statically render the page. The opportunity pages are the same for everyone and rarely update so should not be rebuilt for every single request. Statically rendering seems like the easiest way to achieve that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can punt this consideration for #85 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes HHS#2068 - Add new id-based opportunity page - Add new `OpportunityListingAPI` class extended from `BaseAPI` - Make `searchInputs`/`QueryParamData` in `BaseAPI` and `errors.ts` optional params (only used for search page) - Update sitemap to replace [id] in url with 1 - Add test coverage
Fixes HHS#2068 - Add new id-based opportunity page - Add new `OpportunityListingAPI` class extended from `BaseAPI` - Make `searchInputs`/`QueryParamData` in `BaseAPI` and `errors.ts` optional params (only used for search page) - Update sitemap to replace [id] in url with 1 - Add test coverage
Fixes #2068 - Add new id-based opportunity page - Add new `OpportunityListingAPI` class extended from `BaseAPI` - Make `searchInputs`/`QueryParamData` in `BaseAPI` and `errors.ts` optional params (only used for search page) - Update sitemap to replace [id] in url with 1 - Add test coverage
Summary
Fixes #96
Time to review: 10 min
Changes proposed
OpportunityListingAPI
class extended fromBaseAPI
searchInputs
/QueryParamData
inBaseAPI
anderrors.ts
optional params (only used for search page)Context for reviewers
Page just shows a table with simple results:
Screen.Recording.2024-06-18.at.7.00.46.PM.mov