Skip to content

Fix CI and add more unit tests #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .github/workflows/validate-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
env:
# `POSTGRES_HOST` is `postgres`
# optional (defaults to `postgres`)
POSTGRES_DB: test
POSTGRES_DB: postgres
# required
POSTGRES_PASSWORD: test
POSTGRES_PASSWORD: password
# optional (defaults to `5432`)
POSTGRES_PORT: 5432
# optional (defaults to `postgres`)
Expand All @@ -41,14 +41,14 @@ jobs:
neon-proxy:
image: ghcr.io/timowilhelm/local-neon-http-proxy:main
env:
PG_CONNECTION_STRING: postgres://postgres:[email protected]:5432/test
PG_CONNECTION_STRING: postgres://postgres:password@postgres:5432/postgres
ports:
- '4444:4444'

env:
NODE_OPTIONS: --max-old-space-size=8192
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
DATABASE_URL: postgres://postgres:test@db.localtest.me:5432/test
DATABASE_URL: postgres://postgres:password@db.localtest.me:5432/postgres

steps:
- name: Checkout
Expand Down Expand Up @@ -133,9 +133,6 @@ jobs:
npx inngest-cli@latest dev &
pnpm wait-on tcp:8288
- name: Setup upterm session
uses: lhotari/action-upterm@v1

- name: Run tests
run: ./bin/shdotenv -q -e ./apps/web/.env.local pnpm run test::ci

Expand Down
2 changes: 1 addition & 1 deletion apps/web/__tests__/end-to-end.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {env, testEnv, testEnvRequired} from '@openint/env'
import {initOpenIntSDK} from '@openint/sdk'
import {setupTestOrg, tearDownTestOrg} from './test-utils'

jest.setTimeout(30 * 1000) // long timeout because we have to wait for next.js to compile
jest.setTimeout(60 * 1000) // long timeout because we have to wait for next.js to compile

let fixture: Awaited<ReturnType<typeof setupTestOrg>>
let sdk: ReturnType<typeof initOpenIntSDK>
Expand Down
50 changes: 27 additions & 23 deletions packages-v1/api-v1/__tests__/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,33 @@ test.each(Object.entries(viewers))(
},
)

describeEachDatabase({drivers: ['pg']}, (db) => {
test('anon user has no access to connector_config', async () => {
await expect(
trpcClientForViewer(null).listConnectorConfigs.query(),
).rejects.toThrow('Admin only')
})
describeEachDatabase(
{drivers: ['pg'], migrate: true, enableExtensions: true},
(db) => {
test('anon user has no access to connector_config', async () => {
await expect(
trpcClientForViewer(null).listConnectorConfigs.query(),
).rejects.toThrow('Admin only')
})

beforeAll(async () => {
await db
.insert(schema.connector_config)
.values({org_id: 'org_123', id: 'ccfg_123'})
})
beforeAll(async () => {
await db.$truncateAll()
await db
.insert(schema.connector_config)
.values({org_id: 'org_123', id: 'ccfg_123'})
})

test('org has access to its own connector config', async () => {
const client = trpcClientForViewer({role: 'org', orgId: 'org_123'})
const res = await client.listConnectorConfigs.query()
expect(res.items).toHaveLength(1)
expect(res.items[0]?.id).toEqual('ccfg_123')
})
test('org has access to its own connector config', async () => {
const client = trpcClientForViewer({role: 'org', orgId: 'org_123'})
const res = await client.listConnectorConfigs.query()
expect(res.items).toHaveLength(1)
expect(res.items[0]?.id).toEqual('ccfg_123')
})

test('org has no access to other orgs connector config', async () => {
const client = trpcClientForViewer({role: 'org', orgId: 'org_456'})
const res = await client.listConnectorConfigs.query()
expect(res.items).toHaveLength(0)
})
})
test('org has no access to other orgs connector config', async () => {
const client = trpcClientForViewer({role: 'org', orgId: 'org_456'})
const res = await client.listConnectorConfigs.query()
expect(res.items).toHaveLength(0)
})
},
)
Loading