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

Implementation for user comment notification #54

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Wokoro
Copy link
Collaborator

@Wokoro Wokoro commented Sep 14, 2019

What does this PR do?

Implementation for users to receive comment notifications trips request on a realtime base.

Description of Task to be completed?

Users of the platform should be able to receive comment notification on their trip request.

When a comment is posted to a request, the requester’s would receive a summary of the comment and a link to view the given trip request.

How should this be manually tested?

  • Clone the project clone [email protected]:andela/cyclops-backend.git
  • Log in as a seeded user
  • Setup and eventSource to listen to http://localhost:3000/api/v1/notifications/comment?slt=${token}, including the token of the user in {token}
  • Visit /trips POST request and enter the parameters:
    request_type: {"oneWayTrip" or "returnTrip"}
    trip_plan: {"singleCity" or "multiCity"}
    leaving_from: {valid uuid of office"}
    return_date
    travel_date"
    destination
  • Visit /comment/trips to make comment providing:
    request_uuid: {valid uuid of a trip you created"}
    message

Any background context you want to provide?

EventSouce API needs to be set up in the frontend to listen to new comments.
The frontend auto-reconnects in the face of a server error.

What are the relevant stories?

#167728039

Screenshots (if appropriate)

realtime_notification

Questions:

none


it('it should call next function for server error', ()=>{
sinon.stub(NotificationRepository, 'getAll').throws();
expect(CommentNotificationController.create).throws
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon semi

NotificationRepository.getAll.restore();
});

it('it should call next function for server error', ()=>{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after => arrow-spacing
Missing space before => arrow-spacing

expect(res.write).to.be.calledWith('\n');
});

it('it should return unread comments', ()=>{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Block must not be padded by blank lines padded-blocks
Missing space after => arrow-spacing
Missing space before => arrow-spacing


after(()=>{ sinon.restore(); });

it('it should set headers should be set', ()=>{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after => arrow-spacing
Missing space before => arrow-spacing

sinon.spy(res, 'write');
});

after(()=>{ sinon.restore(); });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after => arrow-spacing
Missing space before => arrow-spacing

import chai, { expect } from 'chai';
import chaiHttp from 'chai-http';
import CommentNotificationController from '../src/controllers/CommentNotificationController';
import {req, res, next} from './mock.data';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required after '{' object-curly-spacing
A space is required before '}' object-curly-spacing

@@ -1,18 +1,11 @@
import { Router } from 'express';

import userNotificationController from '../controllers/ExampleUserNotificationController';
import authenticateUser from '../middlewares/authenticateUser'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon semi

},

down: (queryInterface, Sequelize) => {
return queryInterface.bulkDelete('Notifications', null, {});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected indentation of 4 spaces but found 6 indent

return queryInterface.bulkInsert('Notifications', notificationData, {});
},

down: (queryInterface, Sequelize) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Sequelize' is defined but never used no-unused-vars
Unexpected block statement surrounding arrow body; move the returned value immediately after the => arrow-body-style

'use strict';

module.exports = {
up: (queryInterface, Sequelize) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Sequelize' is defined but never used no-unused-vars

    Implementation of user comment notification.
    Users should receive comment notification when comments are created
    on thier trip request.

    Finished[167728039]
@Wokoro Wokoro force-pushed the ft-comment-notification-167728039 branch from 8312dfa to 8d2ab58 Compare September 14, 2019 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant