Skip to content

Commit 65f8be5

Browse files
authored
Fix CI and add more unit tests (#287)
* try to fix ci * Seriously.... * Align db setting between docker and workflow * fix CasingCache bug in upsert * switch upsert to node-postgres from postgres.js * Separating upsert tests into two * Test upsert for neon also * test upsert against all 3 drivers * Remove upterm again * Finally fix failing test related to upsert in RLS how was it not discovered before * Add helper method * Add test case clarifying rls behavior * Update schema dump * Fix type error * fix test * Disable pglite for now due to extension finiky * Increase e2e timeout
1 parent 5d40e4b commit 65f8be5

File tree

17 files changed

+977
-450
lines changed

17 files changed

+977
-450
lines changed

.github/workflows/validate-workflow.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
env:
1818
# `POSTGRES_HOST` is `postgres`
1919
# optional (defaults to `postgres`)
20-
POSTGRES_DB: test
20+
POSTGRES_DB: postgres
2121
# required
22-
POSTGRES_PASSWORD: test
22+
POSTGRES_PASSWORD: password
2323
# optional (defaults to `5432`)
2424
POSTGRES_PORT: 5432
2525
# optional (defaults to `postgres`)
@@ -41,14 +41,14 @@ jobs:
4141
neon-proxy:
4242
image: ghcr.io/timowilhelm/local-neon-http-proxy:main
4343
env:
44-
PG_CONNECTION_STRING: postgres://postgres:[email protected]:5432/test
44+
PG_CONNECTION_STRING: postgres://postgres:password@postgres:5432/postgres
4545
ports:
4646
- '4444:4444'
4747

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

5353
steps:
5454
- name: Checkout
@@ -133,9 +133,6 @@ jobs:
133133
npx inngest-cli@latest dev &
134134
pnpm wait-on tcp:8288
135135
136-
- name: Setup upterm session
137-
uses: lhotari/action-upterm@v1
138-
139136
- name: Run tests
140137
run: ./bin/shdotenv -q -e ./apps/web/.env.local pnpm run test::ci
141138

apps/web/__tests__/end-to-end.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {env, testEnv, testEnvRequired} from '@openint/env'
77
import {initOpenIntSDK} from '@openint/sdk'
88
import {setupTestOrg, tearDownTestOrg} from './test-utils'
99

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

1212
let fixture: Awaited<ReturnType<typeof setupTestOrg>>
1313
let sdk: ReturnType<typeof initOpenIntSDK>

packages-v1/api-v1/__tests__/auth.spec.ts

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,33 @@ test.each(Object.entries(viewers))(
2323
},
2424
)
2525

26-
describeEachDatabase({drivers: ['pg']}, (db) => {
27-
test('anon user has no access to connector_config', async () => {
28-
await expect(
29-
trpcClientForViewer(null).listConnectorConfigs.query(),
30-
).rejects.toThrow('Admin only')
31-
})
26+
describeEachDatabase(
27+
{drivers: ['pg'], migrate: true, enableExtensions: true},
28+
(db) => {
29+
test('anon user has no access to connector_config', async () => {
30+
await expect(
31+
trpcClientForViewer(null).listConnectorConfigs.query(),
32+
).rejects.toThrow('Admin only')
33+
})
3234

33-
beforeAll(async () => {
34-
await db
35-
.insert(schema.connector_config)
36-
.values({org_id: 'org_123', id: 'ccfg_123'})
37-
})
35+
beforeAll(async () => {
36+
await db.$truncateAll()
37+
await db
38+
.insert(schema.connector_config)
39+
.values({org_id: 'org_123', id: 'ccfg_123'})
40+
})
3841

39-
test('org has access to its own connector config', async () => {
40-
const client = trpcClientForViewer({role: 'org', orgId: 'org_123'})
41-
const res = await client.listConnectorConfigs.query()
42-
expect(res.items).toHaveLength(1)
43-
expect(res.items[0]?.id).toEqual('ccfg_123')
44-
})
42+
test('org has access to its own connector config', async () => {
43+
const client = trpcClientForViewer({role: 'org', orgId: 'org_123'})
44+
const res = await client.listConnectorConfigs.query()
45+
expect(res.items).toHaveLength(1)
46+
expect(res.items[0]?.id).toEqual('ccfg_123')
47+
})
4548

46-
test('org has no access to other orgs connector config', async () => {
47-
const client = trpcClientForViewer({role: 'org', orgId: 'org_456'})
48-
const res = await client.listConnectorConfigs.query()
49-
expect(res.items).toHaveLength(0)
50-
})
51-
})
49+
test('org has no access to other orgs connector config', async () => {
50+
const client = trpcClientForViewer({role: 'org', orgId: 'org_456'})
51+
const res = await client.listConnectorConfigs.query()
52+
expect(res.items).toHaveLength(0)
53+
})
54+
},
55+
)

0 commit comments

Comments
 (0)