Skip to content
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

feat: add test coverage to: health #4440

Merged
merged 20 commits into from
Dec 28, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:

- name: Run Tests 🧪
env:
NEXT_PUBLIC_LENS_NETWORK: staging
DATABASE_URL: ${{ secrets.STAGING_DATABASE_URL }}
NEXT_PUBLIC_LENS_NETWORK: 'staging'
DATABASE_URL: ${{ secrets.DATABASE_URL }}
CLICKHOUSE_PASSWORD: ${{ secrets.CLICKHOUSE_PASSWORD }}
SECRET: ${{ secrets.SECRET }}
EVER_ACCESS_KEY: ${{ secrets.EVER_ACCESS_KEY }}
Expand All @@ -54,4 +54,20 @@ jobs:
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
IRYS_PRIVATE_KEY: ${{ secrets.IRYS_PRIVATE_KEY }}
IMAGEKIT_URL: ${{ secrets.IMAGEKIT_URL }}
run: pnpm test:e2e
run: |
cd apps/api
{
echo "NEXT_PUBLIC_LENS_NETWORK=${NEXT_PUBLIC_LENS_NETWORK}"
echo "DATABASE_URL=${DATABASE_URL}"
echo "CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD}"
echo "SECRET=${SECRET}"
echo "EVER_ACCESS_KEY=${EVER_ACCESS_KEY}"
echo "EVER_ACCESS_SECRET=${EVER_ACCESS_SECRET}"
echo "LENS_IPFS_AUTH_KEY=${LENS_IPFS_AUTH_KEY}"
echo "IPAPI_KEY=${IPAPI_KEY}"
echo "GOOGLE_API_KEY=${GOOGLE_API_KEY}"
echo "IRYS_PRIVATE_KEY=${IRYS_PRIVATE_KEY}"
echo "IMAGEKIT_URL=${IMAGEKIT_URL}"
} > .env
cd ../..
pnpm test:e2e
2 changes: 1 addition & 1 deletion apps/api/src/db/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ datasource db {
}

generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
}

model Verified {
Expand Down
16 changes: 15 additions & 1 deletion apps/api/src/utils/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();
const prismaClientSingleton = () => {
return new PrismaClient();
};

type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>;

const globalForPrisma = globalThis as unknown as {
prisma: PrismaClientSingleton | undefined;
};

const prisma = globalForPrisma.prisma ?? prismaClientSingleton();

export default prisma;

if (process.env.NODE_ENV !== 'production') {
globalForPrisma.prisma = prisma;
}
2 changes: 1 addition & 1 deletion apps/api/tests/ens/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import axios from 'axios';
import { describe, expect, test } from 'vitest';

describe('ens/index', () => {
test('should return symbol', async () => {
test('should return ens names', async () => {
const response = await axios.post(`${TEST_URL}/ens`, {
addresses: [
'0x03Ba34f6Ea1496fa316873CF8350A3f7eaD317EF',
Expand Down
10 changes: 10 additions & 0 deletions apps/api/tests/health.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { TEST_URL } from '@utils/constants';
import axios from 'axios';
import { describe, expect, test } from 'vitest';

describe('health', () => {
test('should return pong', async () => {
const response = await axios.get(`${TEST_URL}/health`);
expect(response.data.ping).toEqual('pong');
});
});
6 changes: 3 additions & 3 deletions packages/lib/getUniswapURL.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('getUniswapURL', () => {
const amount = 123.45;
const outputCurrency = '0x0123456789abcdef';
const expectedURL =
'https://app.uniswap.org/#/swap?chain=polygon&exactAmount=123.45&exactField=output&outputCurrency=0x0123456789abcdef';
'https://app.uniswap.org/#/swap?chain=polygon_mumbai&exactAmount=123.45&exactField=output&outputCurrency=0x0123456789abcdef';
const result = getUniswapURL(amount, outputCurrency);
expect(result).toBe(expectedURL);
});
Expand All @@ -16,7 +16,7 @@ describe('getUniswapURL', () => {
const amount = 0;
const outputCurrency = '0x0123456789abcdef';
const expectedURL =
'https://app.uniswap.org/#/swap?chain=polygon&exactAmount=0&exactField=output&outputCurrency=0x0123456789abcdef';
'https://app.uniswap.org/#/swap?chain=polygon_mumbai&exactAmount=0&exactField=output&outputCurrency=0x0123456789abcdef';
const result = getUniswapURL(amount, outputCurrency);
expect(result).toBe(expectedURL);
});
Expand All @@ -26,7 +26,7 @@ describe('getUniswapURL', () => {
const outputCurrency = '';
// Note: The resulting URL will still contain "&outputCurrency=", but with an empty value.
const expectedURL =
'https://app.uniswap.org/#/swap?chain=polygon&exactAmount=123.45&exactField=output&outputCurrency=';
'https://app.uniswap.org/#/swap?chain=polygon_mumbai&exactAmount=123.45&exactField=output&outputCurrency=';
const result = getUniswapURL(amount, outputCurrency);
expect(result).toBe(expectedURL);
});
Expand Down