Skip to content

Commit dc6c33b

Browse files
Merge pull request #5 from ChangePlusPlusVandy/setup/dev-setup
prettier formatting check
2 parents a672e9b + f3cf757 commit dc6c33b

File tree

4 files changed

+31
-82
lines changed

4 files changed

+31
-82
lines changed
Lines changed: 14 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,36 @@
1-
name: Prettier Auto-Format
1+
name: Format Check
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: ["*"]
76
pull_request:
8-
branches:
9-
- main
10-
11-
permissions:
12-
contents: write
13-
pull-requests: write
7+
branches: ["main"]
148

159
jobs:
16-
prettier-frontend:
17-
name: Prettier Frontend
10+
format-check:
1811
runs-on: ubuntu-latest
1912

2013
steps:
21-
- name: Checkout repository
14+
- name: Checkout code
2215
uses: actions/checkout@v4
23-
with:
24-
token: ${{ secrets.GITHUB_TOKEN }}
25-
fetch-depth: 0
26-
ref: ${{ github.head_ref || github.ref_name }}
2716

28-
- name: Set up Node.js
17+
- name: Setup Node.js
2918
uses: actions/setup-node@v4
3019
with:
3120
node-version: 20
3221

33-
- name: Install dependencies
22+
- name: Install frontend dependencies
3423
working-directory: ./frontend
3524
run: npm install
3625

37-
- name: Run Prettier and Format Code
38-
working-directory: ./frontend
39-
run: npm run format
40-
41-
- name: Commit formatting changes
42-
run: |
43-
git config --local user.email "action@github.com"
44-
git config --local user.name "GitHub Action"
45-
git add .
46-
git diff --staged --quiet || git commit -m "Auto-format frontend code with Prettier 🤖"
47-
48-
- name: Push changes
49-
run: |
50-
git push origin main --force-with-lease
51-
52-
prettier-backend:
53-
name: Prettier Backend
54-
runs-on: ubuntu-latest
55-
56-
steps:
57-
- name: Checkout repository
58-
uses: actions/checkout@v4
59-
with:
60-
token: ${{ secrets.GITHUB_TOKEN }}
61-
fetch-depth: 0
62-
ref: ${{ github.head_ref || github.ref_name }}
63-
64-
- name: Set up Node.js
65-
uses: actions/setup-node@v4
66-
with:
67-
node-version: 20
68-
69-
- name: Install dependencies
26+
- name: Install backend dependencies
7027
working-directory: ./backend
7128
run: npm install
7229

73-
- name: Run Prettier and Format Code
74-
working-directory: ./backend
75-
run: npm run format
76-
77-
- name: Commit formatting changes
78-
run: |
79-
git config --local user.email "action@github.com"
80-
git config --local user.name "GitHub Action"
81-
git add .
82-
git diff --staged --quiet || git commit -m "Auto-format backend code with Prettier 🤖"
30+
- name: Check frontend formatting
31+
working-directory: ./frontend
32+
run: npm run format:check
8333

84-
- name: Push changes
85-
run: |
86-
git push origin main --force-with-lease
34+
- name: Check backend formatting
35+
working-directory: ./backend
36+
run: npm run format:check

backend/__tests__/controllers/organizationController.test.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,7 @@ describe('OrganizationController', () => {
164164

165165
expect(prismaMock.organization.findFirst).toHaveBeenCalledWith({
166166
where: {
167-
OR: [
168-
{ email: 'neworg@nonprofit.org' },
169-
{ name: 'New Community Services' }
170-
],
167+
OR: [{ email: 'neworg@nonprofit.org' }, { name: 'New Community Services' }],
171168
},
172169
});
173170

@@ -199,11 +196,13 @@ describe('OrganizationController', () => {
199196
});
200197

201198
expect(res.status).toHaveBeenCalledWith(201);
202-
expect(res.json).toHaveBeenCalledWith(expect.objectContaining({
203-
email: 'neworg@nonprofit.org',
204-
name: 'New Community Services',
205-
status: 'PENDING',
206-
}));
199+
expect(res.json).toHaveBeenCalledWith(
200+
expect.objectContaining({
201+
email: 'neworg@nonprofit.org',
202+
name: 'New Community Services',
203+
status: 'PENDING',
204+
})
205+
);
207206
});
208207

209208
it('should reject registration with missing required fields - POST /api/organizations/register', async () => {
@@ -219,7 +218,7 @@ describe('OrganizationController', () => {
219218

220219
expect(res.status).toHaveBeenCalledWith(400);
221220
expect(res.json).toHaveBeenCalledWith({
222-
error: 'Email, password, name, and contact person are required'
221+
error: 'Email, password, name, and contact person are required',
223222
});
224223
});
225224

@@ -240,7 +239,7 @@ describe('OrganizationController', () => {
240239

241240
expect(res.status).toHaveBeenCalledWith(400);
242241
expect(res.json).toHaveBeenCalledWith({
243-
error: 'Organization with this email or name already exists'
242+
error: 'Organization with this email or name already exists',
244243
});
245244
});
246245
});
@@ -413,7 +412,7 @@ describe('OrganizationController', () => {
413412
where: { id: 'org123' },
414413
data: expect.objectContaining({
415414
email: 'newemail@nonprofit.org',
416-
}),
415+
}),
417416
});
418417

419418
expect(res.json).toHaveBeenCalled();
@@ -574,6 +573,4 @@ describe('OrganizationController', () => {
574573
expect(res.json).toHaveBeenCalledWith({ error: 'Organization not found' });
575574
});
576575
});
577-
578-
579-
});
576+
});

backend/controllers/organizationController.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export const registerOrganization = async (req: Request, res: Response) => {
7676
} = req.body;
7777

7878
if (!email || !password || !name || !contactPerson) {
79-
return res.status(400).json({ error: 'Email, password, name, and contact person are required' });
79+
return res
80+
.status(400)
81+
.json({ error: 'Email, password, name, and contact person are required' });
8082
}
8183
const existingOrg = await prisma.organization.findFirst({
8284
where: {

backend/types/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ export interface UpdateOrganizationInput {
8080
contactPerson?: string;
8181
contactTitle?: string;
8282
tags?: string[];
83-
role?: OrganizationRole;
83+
role?: OrganizationRole;
8484
status?: OrganizationStatus;
85-
}
85+
}

0 commit comments

Comments
 (0)