Skip to content

Commit

Permalink
Merge pull request #242 from labzero/develop
Browse files Browse the repository at this point in the history
Merge to master
  • Loading branch information
JeffreyATW authored Mar 1, 2019
2 parents 8258654 + ec39a44 commit 8ba6a3f
Show file tree
Hide file tree
Showing 195 changed files with 4,953 additions and 4,696 deletions.
22 changes: 9 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
test:
docker:
# image for running tests
- image: circleci/node:9.11-browsers
- image: cypress/browsers:chrome69
environment:
- DB_NAME=lunch_test
- DB_USER=lunch_test
Expand Down Expand Up @@ -34,7 +34,7 @@ jobs:
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-test-dependencies-{{ checksum "package.json" }}

# install deps
- run:
Expand All @@ -44,7 +44,8 @@ jobs:
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- ~/.cache
key: v1-test-dependencies-{{ checksum "package.json" }}

# run unit tests
- run: mkdir ~/repo/junit
Expand All @@ -64,19 +65,14 @@ jobs:
- run:
name: setup /etc/hosts
command: |
echo 127.0.0.1 local.lunch.pink | sudo tee -a /etc/hosts
echo 127.0.0.1 integration-test.local.lunch.pink | sudo tee -a /etc/hosts
echo 127.0.0.1 local.lunch.pink | tee -a /etc/hosts
echo 127.0.0.1 integration-test.local.lunch.pink | tee -a /etc/hosts
# build the app
- run:
name: build-release
command: NODE_ENV=test npm run build

- run:
name: start-server
command: NODE_ENV=test npm run serve
background: true

- run:
name: integration-tests
command: NODE_ENV=test npm run integration-test-ci
Expand Down Expand Up @@ -108,9 +104,9 @@ jobs:
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-build-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- v1-build-dependencies-

# install deps
- run:
Expand All @@ -120,7 +116,7 @@ jobs:
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
key: v1-build-dependencies-{{ checksum "package.json" }}

# build the release
- run:
Expand Down
10 changes: 5 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ module.exports = {
'airbnb',
'plugin:flowtype/recommended',
'plugin:css-modules/recommended',
'prettier',
'prettier/flowtype',
'prettier/react',
],

plugins: [
Expand Down Expand Up @@ -51,8 +48,8 @@ module.exports = {
// https://github.com/benmosher/eslint-plugin-import/issues/458
'import/no-extraneous-dependencies': 'off',

'jsx-a11y/anchor-is-valid': [
'error',
'jsx-a11y/anchor-is-valid': [
'error',
{
specialLink: ['to'],
},
Expand Down Expand Up @@ -80,14 +77,17 @@ module.exports = {
'key-spacing': 0,
'no-confusing-arrow': 0,
'react/jsx-quotes': 0,
'max-len': 0,
'jsx-quotes': [
2,
'prefer-double'
],
'arrow-parens': 'off',
'generator-star-spacing': 'off',
'import/prefer-default-export': 0,

'react/forbid-prop-types': 'off',
'react/destructuring-assignment': 'off',
},

settings: {
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ yarn-error.log*
# Don't use npm install
package-lock.json

# Cypress sample files and data from runs
cypress/fixtures/
cypress/plugins/
cypress/screenshots/
cypress/videos/

# Misc
.DS_Store
.env
Expand Down
16 changes: 0 additions & 16 deletions .prettierrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ addons:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
cache: yarn
script:
- yarn lint
- yarn test
Expand Down
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ EXPOSE 3000
# Copy application files
COPY ./build .

CMD [ "node", "server.js" ]
# Run the container under "node" user by default
USER node

# Set NODE_ENV env variable to "production" for faster expressjs
ENV NODE_ENV production

CMD [ "node", "server.js" ]
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,20 @@ For `GOOGLE_*` env variables:
* Create a Google Developer app in the [console](https://console.developers.google.com/).
* Enable the Google+ API, Contacts API, Google Maps JavaScript API, Google Places API Web Service, and Google Maps Geocoding API.
* Go to the Credentials section and create an OAuth client ID.
* Click the OAuth Consent tab and add `lunch.pink` as an authorized domain.
* Click the Credentials tab, choose "OAuth" from the Create Credentials dropdown.
* Choose "Web Application" as the type.
* For local development:
* Enter `http://local.lunch.pink:3000` and `https://local.lunch.pink:3000` as authorized JavaScript origins
* Enter `http://local.lunch.pink:3000/login/google/callback` and `https://local.lunch.pink:3000/login/google/callback` as authorized redirect URIs
* Add your deployment target(s) as additional origins/redirect URIs.
* Go back to the Credentials section and create two API keys - one for the client, and one for the server.
* For the client, optionally limit requests to certain referrers.
* On each API key, add `http://*.lunch.pink` and `https://*.lunch.pink` as HTTP referrers.

#### Database

Set up a PostgreSQL database and enter the credentials into `.env`. If you want to use another database dialect, change it in `database.js`.

To seed your database with a Superuser, fill out the `SUPERUSER_*` env variables accordingly, then run

```bash
npx sequelize db:seed:all
```
Set up a PostgreSQL database and enter the admin credentials into `.env`. If you want to use another database dialect, change it in `database.js`.

After setting up and starting the app, you will be able to log in with this user and create a team. If you did not supply a SUPERUSER_PASSWORD, you will need to log in via OAuth, using the email address you supplied for SUPERUSER_EMAIL.

Expand All @@ -66,6 +64,12 @@ yarn
npx sequelize db:migrate
```

To seed your database with a Superuser, fill out the `SUPERUSER_*` env variables accordingly, then run

```bash
npx sequelize db:seed:all
```

## Development server

### Running
Expand All @@ -74,6 +78,8 @@ npx sequelize db:migrate
npm start
```

`npm start` will default to `localhost`, but the browser should point to `https://local.lunch.pink:3000`

## Production server

### Building
Expand Down Expand Up @@ -136,7 +142,13 @@ npm run integration
Individual files can be run using:

```bash
npm run integration-file /path/to/file
npm run integration-file path/to/file
```

Or selected using the Cypress Test Runner in interactive mode:

```bash
npm run integration-interactive
```

### Linting
Expand Down
3 changes: 2 additions & 1 deletion .babelrc.js → babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// https://babeljs.io/docs/usage/api/
module.exports = {
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-transform-modules-commonjs',
],
presets: [
Expand All @@ -22,7 +24,6 @@ module.exports = {
},
},
],
["@babel/preset-stage-2", { "decoratorsLegacy": true }],
'@babel/preset-flow',
'@babel/preset-react',
],
Expand Down
7 changes: 7 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"baseUrl": "https://local.lunch.pink:3000/",
"port": 4000,
"env": {
"subdomain": "https://integration-test.local.lunch.pink:3000/"
}
}
12 changes: 12 additions & 0 deletions cypress/integration/lunch_tests/landing.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-disable no-undef */

describe('landing page', () => {
before(() => {
cy.visit('/');
});

it('contains hero text and has login link', () => {
cy.contains('Figure it out');
cy.get('#header .btn').contains('Log in').should('have.attr', 'href', '/login');
});
});
26 changes: 26 additions & 0 deletions cypress/integration/lunch_tests/login.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable no-undef */
import * as helpers from '../../support/helpers';

describe('login page', () => {
beforeEach(() => {
cy.visit('/login');
});

it('contains email and password fields, Google login, and forgot password link', () => {
cy.contains('Email/password');
cy.contains('Sign in with Google');
cy.contains('Forgot password?');
});

it('logs in and out successfully', () => {
cy.get('#login-email').type('[email protected]');
cy.get('#login-password').type('test');
cy.get('button[type="submit"]').click();
helpers.deleteTeam();
cy.contains('You’re not currently a part of any teams!');

cy.get('#header button').click();
cy.get('nav.Menu-root.Menu-open a').contains('Log Out').click();
cy.contains('Figure it out');
});
});
75 changes: 75 additions & 0 deletions cypress/integration/lunch_tests/other.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* eslint-env mocha */
/* eslint-disable no-undef */
import * as helpers from '../../support/helpers';

const subdomain = Cypress.env('subdomain');

describe('other pages', () => {
before(() => {
helpers.login();
helpers.deleteTeam();
helpers.createTeam();
});

beforeEach(() => {
helpers.login();
});

describe('hamburger menu', () => {
it('expands to show menu contents', () => {
cy.visit('');
cy.get('#header button').click();
cy.get('.Header-menuBackground').should('be.visible');
cy.get('a.Menu-button').should('be.visible');
cy.get('nav.Menu-root.Menu-open').should('be.visible').within(() => {
cy.get('a').contains('Team').should('have.attr', 'href', '/team');
cy.get('a').contains('Tags').should('have.attr', 'href', '/tags');
cy.get('a').contains('My Teams').should('have.attr', 'href', '//local.lunch.pink:3000/teams');
cy.get('a').contains('Account').should('have.attr', 'href', '//local.lunch.pink:3000/account');
cy.get('a').contains('Log Out').should('have.attr', 'href', '//local.lunch.pink:3000/logout');
});
});
});

describe('Account page', () => {
it('should have "Name," "Email," and "Change Password?" inputs and Submit button', () => {
cy.visit('/account');
cy.get('label').contains('Name').should('have.attr', 'for', 'account-name');
cy.get('label').contains('Email');
cy.contains('Change password?');
cy.contains('Submit');
});
});

describe('Tags page', () => {
it('should display a list of tags when there are tags', () => {
helpers.addRestaurant();
helpers.addTag();
cy.visit(`${subdomain}tags`);
cy.contains('waterfront');
helpers.deleteTag();
helpers.deleteRestaurant();
});

it('should display blurb when no tags', () => {
cy.visit(`${subdomain}tags`);
cy.get('button.Tag-button').click();
cy.get('.modal-footer .btn-primary').click();
cy.contains('Once you add tags');
});
});

describe('About page', () => {
it('should have some content', () => {
cy.visit('/about');
cy.contains('About Lunch');
});
});

describe('404 page', () => {
it('should have some content', () => {
cy.visit('/404', { failOnStatusCode: false });
cy.contains('Page not found');
});
});
});
Loading

0 comments on commit 8ba6a3f

Please sign in to comment.