Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek29 committed Nov 28, 2024
1 parent e557542 commit e29e028
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,27 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Create env file
working-directory: server
run: echo "JWT_SECRET_KEY=D4fg0Eg6pk" >> .env

- name: Setup server
working-directory: server
run: npm ci
run: npm i
env:
JWT_SECRET_KEY: ${{secrets.JWT_SECRET_KEY}}

- name: Setup socket
working-directory: socket
run: npm ci
run: npm i

- name: setup client
working-directory: client
run: npm ci
run: npm i

- name: Run app
working-directory: client
run: |
nohup npm run start:test &
sleep 10
- name: install playwright browser
working-directory: client
run: npx playwright install --with-deps
Expand Down
1 change: 0 additions & 1 deletion client/src/context/ChatContext/ChatContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ interface ChatContextType {
updateLastMessage: Message | null;
};


export const ChatContext = createContext<ChatContextType | undefined>(undefined);

6 changes: 3 additions & 3 deletions client/src/context/ChatContext/ChatProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const ChatProvider = ({ children, user }: Props) => {
const [allUsers, setAllUsers] = useState<User[]>([]);
const [socket, setSocket] = useState<Socket | null>(null);
const [onlineUsers, setOnlineUsers] = useState<OnlineUsers[]>([]);
const [sendMessageError, setSendMessageError] = useState<ChatsError>(null);
// const [sendMessageError, setSendMessageError] = useState<ChatsError>(null);
const [newMessage, setNewMessage] = useState<Message | null>(null);
const [updateLastMessage, setUpdateLastMessage] = useState<Message | null>(null);

Expand Down Expand Up @@ -83,7 +83,7 @@ export const ChatProvider = ({ children, user }: Props) => {
};
}, [socket, currentChat]);

// send with socket user chats when new open chat opened
// send with socket user chats when new chat opened
useEffect(() => {
if (socket === null) return;
const recipientId = newChat?.members.find((id) => id !== user?._id);
Expand Down Expand Up @@ -201,7 +201,7 @@ export const ChatProvider = ({ children, user }: Props) => {
chatId: chatId
}))
if (response.error) {
return setSendMessageError(response);
return console.log('Error sending message', response);
}
setNewMessage(response);
setMessages((prev: Message[] | null) => {
Expand Down
9 changes: 8 additions & 1 deletion client/tests/auth.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import test, { expect, Page } from "@playwright/test";
import generator from 'generate-password';


// const VITE_SERVER_HOST = .env.VITE_SERVER_PORT || 'localhost';
// const VITE_SERVER_PORT = '5173';

// const siteUrl = ``

async function registerUser(page: Page) {
const email = `${generateString()}@${generateString()}.com`;
const name = generateString();
const password = generateStrongPassword();
await page.goto('http://localhost:5173/register');
await page.goto('0.0.0.0:5173/register');
// await page.goto('http://localhost:5173/register');
await page.getByPlaceholder('Name').fill(name);
await page.getByPlaceholder('Email').fill(email);
await page.getByPlaceholder('Password').fill(password);
Expand Down
4 changes: 4 additions & 0 deletions client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
host: process.env.VITE_SERVER_HOST || 'localhost',
port: parseInt(process.env.VITE_PORT || '5173'),
}
})
5 changes: 0 additions & 5 deletions socket/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ io.on('connection', (socket) => {
const user = onlineUsers.find(user => user.userId === message.recipientId);
if (user) {
io.to(user.socketId).emit('receiveMessage', message);
// io.to(user.socketId).emit('getNotification', {
// senderId: message.senderId,
// isRead: false,
// date: new Date()
// });
}
});

Expand Down

0 comments on commit e29e028

Please sign in to comment.