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

#158457036 Send invites to player and control number of players #12

Closed

Conversation

Onnassiz
Copy link
Collaborator

What does this PR do?

This PR allows users to search for other users and send an invitation to these users. It also prevents a game start when the number of connected users is less than 3 and notifies the 13th user trying to join a game that the game slot is full.

Description of Task to be completed?

  • search for users
  • send an email invitation to users
  • secure search and send-invitation endpoints
  • design reusable modal
  • implement modal warnings when necessary
  • test backend and frontend features
  • etc.

How should this be manually tested?

This PR can be tested using the review app link below

What are the relevant pivotal tracker stories?

[158457036]

Any background context you want to add?

Screenshots

screen shot 2018-07-11 at 8 09 54 pm

screen shot 2018-07-11 at 8 11 00 pm

screen shot 2018-07-11 at 8 11 52 pm

@Onnassiz Onnassiz temporarily deployed to et-cfh-staging-pr-12 July 11, 2018 19:13 Inactive
@Onnassiz Onnassiz force-pushed the ft-send-invites-to-at-most-11-users-158457036 branch from 1972fee to 132d454 Compare July 12, 2018 05:52
@Onnassiz Onnassiz force-pushed the ft-send-invites-to-at-most-11-users-158457036 branch from 132d454 to 84bf260 Compare July 12, 2018 06:06
@Onnassiz Onnassiz force-pushed the ft-send-invites-to-at-most-11-users-158457036 branch from 84bf260 to 0602483 Compare July 12, 2018 06:16
@Onnassiz Onnassiz temporarily deployed to et-cfh-staging-pr-12 July 12, 2018 06:16 Inactive
@Onnassiz Onnassiz force-pushed the ft-send-invites-to-at-most-11-users-158457036 branch from 0602483 to 3062b4c Compare July 12, 2018 06:18
@Onnassiz Onnassiz temporarily deployed to et-cfh-staging-pr-12 July 12, 2018 06:19 Inactive
@Onnassiz Onnassiz force-pushed the ft-send-invites-to-at-most-11-users-158457036 branch from 3062b4c to 43d6215 Compare July 12, 2018 06:31
@Onnassiz Onnassiz temporarily deployed to et-cfh-staging-pr-12 July 12, 2018 06:31 Inactive
@Onnassiz Onnassiz force-pushed the ft-send-invites-to-at-most-11-users-158457036 branch from 43d6215 to cf3bee5 Compare July 12, 2018 08:19
@Onnassiz Onnassiz temporarily deployed to et-cfh-staging-pr-12 July 12, 2018 08:20 Inactive
console.log('userDonated success', results);
});
.then(function (results) {
console.log('userDonated success', results);

Choose a reason for hiding this comment

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

Unexpected console statement no-console


socket.on('gameFilledUp', function (data) {

Choose a reason for hiding this comment

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

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

var notificationQueue = [];
var timeout = false;
var self = this;
var joinOverrideTimeout = 0;

Choose a reason for hiding this comment

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

'joinOverrideTimeout' is assigned a value but never used no-unused-vars


var notificationQueue = [];
var timeout = false;
var self = this;

Choose a reason for hiding this comment

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

'self' is assigned a value but never used no-unused-vars

return {
restrict: 'EA',
link: function(scope, elem, attr) {
link(scope, elem, attr) {

Choose a reason for hiding this comment

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

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

angular.module('mean.system')
.controller('GameController', ['$scope', 'game', '$timeout', '$location', 'MakeAWishFactsService', '$dialog', function ($scope, game, $timeout, $location, MakeAWishFactsService, $dialog) {
.controller('GameController', ['$scope', '$http', '$q', 'game', '$timeout', '$location', 'MakeAWishFactsService', '$dialog', '$rootScope', ($scope, $http, $q, game, $timeout, $location, MakeAWishFactsService, $rootScope) => {

Choose a reason for hiding this comment

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

'$rootScope' is defined but never used no-unused-vars

localStorage.setItem('#cfhetusertoken', response.token);
$location.path('/app');
}, (error) => {
console.log(error);

Choose a reason for hiding this comment

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

Unexpected console statement no-console

localStorage.setItem('#cfhetusertoken', response.token);
$location.path('/app');
}, (error) => {
console.log(error);

Choose a reason for hiding this comment

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

Unexpected console statement no-console

-webkit-box-shadow: 0px 0px 0px 0px transparent !important;
-moz-box-shadow: 0px 0px 0px 0px transparent !important;
box-shadow: 0px 0px 0px 0px transparent !important;
-webkit-border-radius: 8px !important;

Choose a reason for hiding this comment

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

Line should be indented 2 spaces, but was indented 4 spaces
!important should not be used
Avoid vendor prefixes.

.crDonateWidget {
-webkit-box-shadow: 0px 0px 0px 0px transparent !important;
-moz-box-shadow: 0px 0px 0px 0px transparent !important;
box-shadow: 0px 0px 0px 0px transparent !important;

Choose a reason for hiding this comment

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

Line should be indented 2 spaces, but was indented 4 spaces
!important should not be used
0px should be written without units as 0

});
});

after((done) => {

Choose a reason for hiding this comment

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

'after' is not defined no-undef


after(function(done) {
done();
it('should be able to show an error when try to save without name', (done) => {

Choose a reason for hiding this comment

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

'it' is not defined no-undef

});
});
describe('Method Save', () => {
it('should be able to save without problems', done => user.save((err) => {

Choose a reason for hiding this comment

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

'it' is not defined no-undef

});
});
});
describe('Method Save', () => {

Choose a reason for hiding this comment

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

'describe' is not defined no-undef

// The tests
describe('<Unit Test>', () => {
describe('Model User:', () => {
before((done) => {

Choose a reason for hiding this comment

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

'before' is not defined no-undef

app = require('../../server'),
mongoose = require('mongoose'),
User = mongoose.model('User');
const should = require('should');

Choose a reason for hiding this comment

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

'require' is not defined no-undef

@@ -0,0 +1,78 @@
import 'babel-polyfill';

Choose a reason for hiding this comment

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

Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

@@ -0,0 +1,70 @@
import 'babel-polyfill';

Choose a reason for hiding this comment

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

Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

@@ -66,6 +66,10 @@ angular.module('mean.system')
game.timeLimits = data.timeLimits;
});

socket.on('gameFilledUp', function (data) {

Choose a reason for hiding this comment

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

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

socket.join(game.gameID);
socket.gameID = game.gameID;
console.log(socket.id,'has joined newly created game',game.gameID);

Choose a reason for hiding this comment

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

Unexpected console statement no-console

Hasstrup and others added 8 commits July 12, 2018 14:41
- Implements receipt of jwt token on signup
- Implements correct controller on signup/login page
- Implements caching of data in browser

[Finishes #158457035]
-setup api endpoint for finding users
-setup api endpoint for sending email to users
-create a nodemailer function for sending email
-create an email and url validator
-write test cases for finding players and sending email
-modify angular game controller
-added validation to search field by creating a directive
-styled text field and buttons
-etc

[#158457036]
-setup materialize
-modal design for less that 3 players
-modal design for more than 11 players

[#158457036]
-remove multiple modals
-use reusable modal
-add questions and answers to db
-change maximum player limit to 12
-link start button modal to game

[#158457036]
    -removed submit button from search form
    -added search on key press
    -modify karma config for test
    [#158457036]
-modify request header from controller
-add middleware to routes
-modify auth verification
[#158457036]
-resolve package-lock.json errors
-change play as guest href
-move files into view folder

[#158457036]
- Add new modal
- Emit socket event when max player limit is reached
- refactor fireGame function
[#158457036]
@Onnassiz Onnassiz force-pushed the ft-send-invites-to-at-most-11-users-158457036 branch from ee2637b to 7b11fff Compare July 12, 2018 13:44
@coveralls
Copy link

coveralls commented Jul 12, 2018

Pull Request Test Coverage Report for Build 195

  • 165 of 194 (85.05%) changed or added relevant lines in 10 files are covered.
  • 8 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+1.0%) to 63.459%

Changes Missing Coverage Covered Lines Changed/Added Lines %
app/helpers/sendInvitationEmail.js 13 14 92.86%
app/middleware/auth.js 9 18 50.0%
config/socket/socket.js 53 72 73.61%
Files with Coverage Reduction New Missed Lines %
config/socket/socket.js 8 72.25%
Totals Coverage Status
Change from base Build 184: 1.0%
Covered Lines: 747
Relevant Lines: 1038

💛 - Coveralls

@@ -40,9 +42,11 @@ module.exports = (config) => {
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN ||

Choose a reason for hiding this comment

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

Trailing spaces not allowed no-trailing-spaces

@@ -4,13 +4,17 @@ import * as answers from '../app/controllers/answers';
import questions from '../app/controllers/questions';
import avatars from '../app/controllers/avatars';
import index from '../app/controllers/index';
import middleware from '../app/middleware/auth';

Choose a reason for hiding this comment

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

Missing file extension for "../app/middleware/auth" import/extensions

import request from 'supertest';
import { expect } from 'chai';
import app from '../../server';
import { Tokenizer } from '../../app/helpers/tokenizer';

Choose a reason for hiding this comment

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

Missing file extension for "../../app/helpers/tokenizer" import/extensions

@@ -0,0 +1,77 @@
import request from 'supertest';
import { expect } from 'chai';
import app from '../../server';

Choose a reason for hiding this comment

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

Missing file extension for "../../server" import/extensions

@@ -0,0 +1,77 @@
import request from 'supertest';
import { expect } from 'chai';

Choose a reason for hiding this comment

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

Missing file extension for "chai" import/extensions

@@ -0,0 +1,29 @@
import { expect } from 'chai';
import sendInvitationEmail from '../../app/helpers/sendInvitationEmail';

Choose a reason for hiding this comment

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

Missing file extension for "../../app/helpers/sendInvitationEmail" import/extensions

@@ -0,0 +1,29 @@
import { expect } from 'chai';

Choose a reason for hiding this comment

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

Missing file extension for "chai" import/extensions

const auth = (req, res, next) => {
let token = req.headers.authorization || req.headers['x-access-token'];
token = token.replace('Bearer ', '');

Choose a reason for hiding this comment

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

Trailing spaces not allowed no-trailing-spaces

@@ -0,0 +1,39 @@
import jwt from 'jsonwebtoken';

Choose a reason for hiding this comment

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

Missing file extension for "jsonwebtoken" import/extensions

if (error) {
return console.log(error);
}
console.log('Message sent: %s', info.messageId);

Choose a reason for hiding this comment

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

Unexpected console statement no-console

@Onnassiz Onnassiz force-pushed the ft-send-invites-to-at-most-11-users-158457036 branch from 7b11fff to 9ce92b7 Compare July 12, 2018 14:01
// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);

Choose a reason for hiding this comment

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

Unexpected console statement no-console

@@ -0,0 +1,56 @@
/* eslint no-useless-escape: 0 */
import nodemailer from 'nodemailer';
import IsUrl from 'is-url';

Choose a reason for hiding this comment

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

Missing file extension for "is-url" import/extensions

@@ -0,0 +1,56 @@
/* eslint no-useless-escape: 0 */
import nodemailer from 'nodemailer';

Choose a reason for hiding this comment

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

Missing file extension for "nodemailer" import/extensions

* @description Controller for handling requests to '/api/auth/login',
* returns token in response as JSON.
* @param {object} passport - passport with all the startegies registered
* @description Controller for handling requests to '/api/auth/login',

Choose a reason for hiding this comment

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

Trailing spaces not allowed no-trailing-spaces

@@ -44,6 +48,12 @@ const signin = (req, res) => {
* @param {object} res - response object provided by express
* @param {function} next - next function for passing the request to next handler
* @description Controller for handling requests to '/api/auth/login', returns token in response as JSON.
* @param {object} passport - passport with all the startegies registered
* @description Controller for handling requests to '/api/auth/login',

Choose a reason for hiding this comment

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

Trailing spaces not allowed no-trailing-spaces

@@ -6,30 +8,32 @@ import mongoose from 'mongoose';
import passport from 'passport';
import avatarsList from './avatars';
import { Tokenizer } from '../helpers/tokenizer';
import sendInvitationEmail from '../helpers/sendInvitationEmail';

Choose a reason for hiding this comment

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

Missing file extension for "../helpers/sendInvitationEmail" import/extensions

  - Mock http request for angular
  - write unit test cases for controller methods
  - modified controller methods to return promise
  [Finishes #158457036]
@Onnassiz Onnassiz force-pushed the ft-send-invites-to-at-most-11-users-158457036 branch from 9ce92b7 to e7b10bd Compare July 12, 2018 14:07
@Onnassiz Onnassiz closed this Jul 12, 2018
@Onnassiz Onnassiz deleted the ft-send-invites-to-at-most-11-users-158457036 branch July 12, 2018 14:14
@Onnassiz Onnassiz restored the ft-send-invites-to-at-most-11-users-158457036 branch July 12, 2018 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants