feat(frontend): newest emails first, mailbox above the SES tools
CI / checks (pull_request) Failing after 12m24s
CI / checks (pull_request) Failing after 12m24s
This commit is contained in:
@@ -59,6 +59,18 @@ describe('AwsSesAdapter', () => {
|
||||
expect(codes).toEqual(['869472', '4410', null])
|
||||
})
|
||||
|
||||
test('lists the newest email first', async () => {
|
||||
const adapter = new AwsSesAdapter('http://floci.test', async () => jsonResponse({
|
||||
messages: [
|
||||
{Id: 'old', Timestamp: '2026-10-23T21:12:41.732Z'},
|
||||
{Id: 'newest', Timestamp: '2026-10-24T05:00:00.000Z'},
|
||||
{Id: 'middle', Timestamp: '2026-10-23T21:56:04.866Z'},
|
||||
],
|
||||
}))
|
||||
|
||||
expect((await adapter.list()).map((resource) => resource.id)).toEqual(['newest', 'middle', 'old'])
|
||||
})
|
||||
|
||||
test('filters messages by subject, sender, and recipients', async () => {
|
||||
const adapter = new AwsSesAdapter('http://floci.test', async () => jsonResponse({
|
||||
messages: [
|
||||
|
||||
@@ -47,7 +47,7 @@ export class AwsSesAdapter implements CloudServiceAdapter {
|
||||
|
||||
async list(query: ResourceQuery = {}): Promise<CloudResource[]> {
|
||||
const messages = await this.fetchInbox()
|
||||
const resources = messages.map(messageToResource)
|
||||
const resources = messages.map(messageToResource).sort(newestFirst)
|
||||
return filterBySearch(resources, query.search)
|
||||
}
|
||||
|
||||
@@ -137,6 +137,10 @@ function findCode(body: string | null | undefined): string | null {
|
||||
return body?.match(CODE_PATTERN)?.[1] ?? null
|
||||
}
|
||||
|
||||
function newestFirst(a: CloudResource, b: CloudResource): number {
|
||||
return (b.createdAt ?? '').localeCompare(a.createdAt ?? '')
|
||||
}
|
||||
|
||||
function filterBySearch(resources: CloudResource[], search?: string): CloudResource[] {
|
||||
const normalized = search?.trim().toLowerCase()
|
||||
if (!normalized) return resources
|
||||
|
||||
Reference in New Issue
Block a user