Skip to content

Commit

Permalink
Merge pull request #133 from saurabhbakolia/develop
Browse files Browse the repository at this point in the history
Develop to Master
  • Loading branch information
saurabhbakolia authored Oct 18, 2024
2 parents 4535025 + c83853f commit 2688cf1
Show file tree
Hide file tree
Showing 109 changed files with 22,335 additions and 44,808 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Greetings

on: [pull_request_target, issues]

jobs:
greeting:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: "👋 Thank you @${{ github.actor }} for raising an issue! We appreciate your effort in helping us improve. Our team will review it shortly. Stay tuned!"
pr-message: " 🎉 Thank you @${{ github.actor }} for your contribution! Your pull request has been submitted successfully. A maintainer will review it as soon as possible. We appreciate your support in making this project better"
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run lint-fix && npm run lint-format
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
build
dist
*.min.js
26 changes: 22 additions & 4 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
module.exports = {
trailingComma: "es5",
tabWidth: 2,
semi: true,
singleQuote: true,
arrowParens: 'always',
trailingComma: 'es5',
tabWidth: 4,
semi: true,
singleQuote: true,
bracketSpacing: true,
embeddedLanguageFormatting: 'auto',
htmlWhitespaceSensitivity: 'css',
insertPragma: false,
jsxBracketSameLine: false,
jsxSingleQuote: true,
proseWrap: 'preserve',
quoteProps: 'as-needed',
requirePragma: false,
semi: true,
singleQuote: true,
trailingComma: 'es5',
useTabs: false,
vueIndentScriptAndStyle: false,
printWidth: 140,
tabWidth: 2,
rangeStart: 0,
};
6 changes: 0 additions & 6 deletions backend/.env

This file was deleted.

1 change: 0 additions & 1 deletion backend/.eslintignore

This file was deleted.

1 change: 1 addition & 0 deletions backend/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run lint && npm run format
120 changes: 60 additions & 60 deletions backend/__tests__/auth.test.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
const request = require("supertest");
const app = require("../server.js");
const request = require('supertest');
const app = require('../server.js');

describe("Auth Routes", () => {
it("should register a new user", async () => {
const response = await request(app).post("/api/auth/register").send({
firstName: "Test",
lastName: "Test",
username: "test",
email: "[email protected]",
password: "test123",
});
describe('Auth Routes', () => {
it('should register a new user', async () => {
const response = await request(app).post('/api/auth/register').send({
firstName: 'Test',
lastName: 'Test',
username: 'test',
email: '[email protected]',
password: 'test123',
});

expect(response.status).toBe(400);
expect(response.status).toBe(400);

// const setCookieHeader = response.headers['set-cookie'];
// expect(setCookieHeader).toBeDefined();
// expect(Array.isArray(setCookieHeader)).toBe(true);
// expect(setCookieHeader).not.toHaveLength(0);
// const refreshTokenCookie = setCookieHeader.find(
// (cookie) => cookie.startsWith('refreshToken=')
// );
// expect(refreshTokenCookie).toBeDefined();
});
// const setCookieHeader = response.headers['set-cookie'];
// expect(setCookieHeader).toBeDefined();
// expect(Array.isArray(setCookieHeader)).toBe(true);
// expect(setCookieHeader).not.toHaveLength(0);
// const refreshTokenCookie = setCookieHeader.find(
// (cookie) => cookie.startsWith('refreshToken=')
// );
// expect(refreshTokenCookie).toBeDefined();
});

// it("should login an existing user and return tokens", async () => {
// const response = await request(app).post("/api/auth/login").send({
// email: "[email protected]",
// password: "password123",
// });
// it("should login an existing user and return tokens", async () => {
// const response = await request(app).post("/api/auth/login").send({
// email: "[email protected]",
// password: "password123",
// });

// expect(response.status).toBe(200);
// expect(response.headers["set-cookie"]).toBeInstanceOf(Array);
// expect(response.headers["set-cookie"]).not.toHaveLength(0);
// const cookies = response.headers["set-cookie"].map(
// (cookie) => cookie.split(";")[0],
// );
// expect(cookies).toEqual(
// expect.arrayContaining([expect.stringMatching(/^accessToken=/)]),
// );
// expect(cookies).toEqual(
// expect.arrayContaining([expect.stringMatching(/^refreshToken=/)]),
// );
// });
// expect(response.status).toBe(200);
// expect(response.headers["set-cookie"]).toBeInstanceOf(Array);
// expect(response.headers["set-cookie"]).not.toHaveLength(0);
// const cookies = response.headers["set-cookie"].map(
// (cookie) => cookie.split(";")[0],
// );
// expect(cookies).toEqual(
// expect.arrayContaining([expect.stringMatching(/^accessToken=/)]),
// );
// expect(cookies).toEqual(
// expect.arrayContaining([expect.stringMatching(/^refreshToken=/)]),
// );
// });

// it("should refresh access token using refresh token", async () => {
// const loginResponse = await request(app).post("/api/auth/login").send({
// email: "[email protected]",
// password: "password123",
// });
// it("should refresh access token using refresh token", async () => {
// const loginResponse = await request(app).post("/api/auth/login").send({
// email: "[email protected]",
// password: "password123",
// });

// expect(loginResponse.status).toBe(200);
// expect(loginResponse.status).toBe(200);

// // Ensure set-cookie header exists before using it
// const setCookieHeader = loginResponse.headers["set-cookie"];
// expect(setCookieHeader).toBeDefined();
// expect(Array.isArray(setCookieHeader)).toBe(true);
// expect(setCookieHeader).not.toHaveLength(0); // Check that set-cookie header is not empty
// // Ensure set-cookie header exists before using it
// const setCookieHeader = loginResponse.headers["set-cookie"];
// expect(setCookieHeader).toBeDefined();
// expect(Array.isArray(setCookieHeader)).toBe(true);
// expect(setCookieHeader).not.toHaveLength(0); // Check that set-cookie header is not empty

// // Check for refreshToken cookie
// const refreshTokenCookie = setCookieHeader.find((cookie) =>
// cookie.startsWith("refreshToken="),
// );
// expect(refreshTokenCookie).toBeDefined();
// // Check for refreshToken cookie
// const refreshTokenCookie = setCookieHeader.find((cookie) =>
// cookie.startsWith("refreshToken="),
// );
// expect(refreshTokenCookie).toBeDefined();

// // Check for accessToken cookie
// expect(setCookieHeader).toEqual(
// expect.arrayContaining([expect.stringMatching(/^accessToken=/)]),
// );
// });
// // Check for accessToken cookie
// expect(setCookieHeader).toEqual(
// expect.arrayContaining([expect.stringMatching(/^accessToken=/)]),
// );
// });
});
2 changes: 1 addition & 1 deletion backend/__tests__/setup.test.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// This file should only contain setup code, not tests.
require("@testing-library/jest-dom/extend-expect"); // For extended DOM assertions
require('@testing-library/jest-dom/extend-expect'); // For extended DOM assertions
16 changes: 8 additions & 8 deletions backend/__tests__/testEnv.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require("dotenv").config();
describe("Environment Variables", () => {
it("should load JWT_SECRET from environment variables", () => {
// Ensure the JWT_SECRET environment variable is loaded
expect(process.env.JWT_SECRET).toBeDefined();
// Optionally, you can check its value or other properties
expect(process.env.JWT_SECRET).toBe("someone");
});
require('dotenv').config();
describe('Environment Variables', () => {
it('should load JWT_SECRET from environment variables', () => {
// Ensure the JWT_SECRET environment variable is loaded
expect(process.env.JWT_SECRET).toBeDefined();
// Optionally, you can check its value or other properties
expect(process.env.JWT_SECRET).toBe('someone');
});
});
Loading

0 comments on commit 2688cf1

Please sign in to comment.