Files
omnivore/packages/api/test/services/save_email.test.ts
Jackson Harper da28998130 Pull ul list out of newsletter blurb
next/react doesnt want child elements of the paragraphs

Improve formatting

Improve wording

Use buttons in the subscribe directly blocks

Simplify docs on setting up forwarding rules

Add extra padding on bottom of help docs

Remove unused style

Add emails help page

Improve formatting

Prefetch page content on iOS

Reduce the reader overly length now that items are precached

Add invalidation when highlights are added to items

fix missing index_settings.json file in api dockerfile for creating elastic index (#363)

Handle full email address objects in the to param from sendgrid

These come in a format like:

"jacksonh-dfdf@inbox.omnivore.app" <jacksonh-dfdf@inbox-demo.omnivore.app>

New IDs for short highlights because they dont cascade delete now

Testing CI issues

Simplify test

CI test

Use promises for async tests

Temporarily remove test to debug CI

Re-enable

re-enable test, return error

Specify a userId when looking up saved email pages

create a unique url for newsletters without a URL

Use 500ms on page test timeouts

Increase timeout

Dont use deep equal to match newsletter label

Run just the labels API

Run against just the newsletter emails

Run without the page tests

Fix

Set the allow uncaught flag

Remove highlight tests

Remove newsletters tests

more resolver tests

Remove newsetter tests

Comment out resolver tests

Use nock for external requests in tests

Specify puppeteer url for tests

Comment out more tests

uncomment tests

re-enable

re-enable email test

Re-disable

Re-enable one pdf attachment test

Re-disable pdf attachment test

Use promises on setTimeout tests

rm label tests

mv label tests into a context

Comment out pdf tests

Comment out pdf tests

Async test

Async wrappers

Delay when creating test pages

More debugging

Unique short ids

Remove potentially problematic test

Fetch page before returning for test

handler in before block

more debugging

More debugging

Move errors checks into contexts

Use a context when saving newsletters to force index refresh

Prettier fix

Fix newsletter label check, remove setTimeout

Re-enable test

timeout on pdf router handler

Fix method call

comment out PDF test

Unique fake username

Comment out PDF test

Debugging signed urls

Re-enable

New email

pdf test

PDF tests

Comment out pdf test

Add nock stubs for email URLs

Use full address for PDF test

Remove debug

Use full email addresses
2022-04-02 16:56:24 -07:00

48 lines
1.4 KiB
TypeScript

import 'mocha'
import { expect } from 'chai'
import 'chai/register-should'
import { createTestUser, deleteTestUser } from '../db'
import { SaveContext, saveEmail } from '../../src/services/save_email'
import { createPubSubClient } from '../../src/datalayer/pubsub'
import { getPageByParam } from '../../src/elastic'
describe('saveEmail', () => {
const username = 'fakeUser'
after(async () => {
await deleteTestUser(username)
})
it('doesnt fail if saved twice', async () => {
const user = await createTestUser(username)
const ctx: SaveContext = {
pubsub: createPubSubClient(),
uid: user.id,
refresh: true,
}
await saveEmail(ctx, {
originalContent: 'fake content',
url: 'https://example.com',
title: 'fake title',
author: 'fake author',
})
// This ensures row level security doesnt prevent
// resaving the same URL
const secondResult = await saveEmail(ctx, {
originalContent: 'fake content',
url: 'https://example.com',
title: 'fake title',
author: 'fake author',
})
expect(secondResult).to.not.be.undefined
const page = await getPageByParam({ userId: user.id })
expect(page).to.exist
expect(page?.url).to.equal('https://example.com')
expect(page?.title).to.equal('fake title')
expect(page?.author).to.equal('fake author')
expect(page?.content).to.contain('fake content')
})
})