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

Chat frontend #89

Merged
merged 17 commits into from
Mar 26, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions gamersnet_backend/__tests__/chat/testListInteractions.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe('Test Getting interacted users', () => {
.set('Cookie', '')//clear cookie and reset
.set('Cookie', 'token=user1_token')
.query({ userID : user1ID.toHexString() })
.expect('{"interactedIDs":["'+user2ID.toHexString()+'","'+user4ID.toHexString()+'"]}')
.expect('{"users":[{"id":"'+user2ID.toHexString()+'","username":"user2"},{"id":"'+user4ID.toHexString()+'","username":"user4"}]}')
.expect(200).end(done);
});

Expand All @@ -166,7 +166,7 @@ describe('Test Getting interacted users', () => {
.set('Cookie', '')//clear cookie and reset
.set('Cookie', 'token=user2_token')
.query({ userID : user2ID.toHexString() })
.expect('{"interactedIDs":["'+user1ID.toHexString()+'","'+user4ID.toHexString()+'"]}')
.expect('{"users":[{"id":"'+user1ID.toHexString()+'","username":"user1"},{"id":"'+user4ID.toHexString()+'","username":"user4"}]}')
.expect(200).end(done);
});

Expand All @@ -183,7 +183,7 @@ describe('Test Getting interacted users', () => {
.set('Cookie', '')//clear cookie and reset
.set('Cookie', 'token=user4_token')
.query({ userID : user4ID.toHexString() })
.expect('{"interactedIDs":["'+user1ID.toHexString()+'","'+user2ID.toHexString()+'"]}')
.expect('{"users":[{"id":"'+user1ID.toHexString()+'","username":"user1"},{"id":"'+user2ID.toHexString()+'","username":"user2"}]}')
.expect(200).end(done);
});

Expand All @@ -194,14 +194,5 @@ describe('Test Getting interacted users', () => {
.query({ userID : user3ID.toHexString() })
.expect(401).end(done);
});

test('User6 cannot view user1\'s interactions', (done) => {
return request(app).get('/messages/listInteractedIDs')
.set('Cookie', '')//clear cookie and reset
.set('Cookie', 'token=user6_token')
.query({ userID : user1ID.toHexString() })
.expect(401).end(done);
});


});
8 changes: 4 additions & 4 deletions gamersnet_backend/__tests__/chat/testNewMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Test adding Messages', () => {
.set('Cookie', '')//clear cookie and reset
.set('Cookie', 'token=user1_token')
.send({
receiver : user2ID,
receiver : user2ID.toHexString(),
timestamp : Date.now(),
message : "HELLO! "
})
Expand All @@ -75,7 +75,7 @@ describe('Test adding Messages', () => {
.set('Cookie', '')//clear cookie and reset
.set('Cookie', 'token=user2_token')//logged in as user 2 but expired session
.send({
receiver : user1ID,
receiver : user1ID.toHexString(),
timestamp : Date.now(),
message : "HELLO! "
})
Expand All @@ -88,7 +88,7 @@ describe('Test adding Messages', () => {
.set('Cookie', '')//clear cookie and reset
.set('Cookie', 'token=user1_token') //was logged as user1
.send({
receiver : user2ID,
receiver : user2ID.toHexString(),
timestamp : Date.now(),
message : null
})
Expand All @@ -100,7 +100,7 @@ describe('Test adding Messages', () => {
.set('Cookie', '')//clear cookie and reset
.set('Cookie', 'token=user1_token') //was logged as user1
.send({
receiver : user1ID,
receiver : user1ID.toHexString(),
timestamp : Date.now(),
message : "HELLO! "
})
Expand Down
Loading