Skip to content
Permalink
Browse files
Merge remote-tracking branch 'upstream/master'
  • Loading branch information
czarniek committed Nov 28, 2019
2 parents ea88837 + b1276e0 commit ea56ef5ab1fe5dfdd184df04c9deafc7c23f5f43
Show file tree
Hide file tree
Showing 33 changed files with 10,112 additions and 347 deletions.
@@ -0,0 +1,4 @@

docs/**
node_modules/**
coverage/**
@@ -8,61 +8,63 @@
"jest": true
},
"parserOptions": {
"ecmaVersion": 8
"ecmaVersion": 2018,
"noInlineConfig": true,
"reportUnusedDisableDirectives": true
},
"rules": {
"arrow-body-style": 2,
"arrow-body-style": "error",
"arrow-spacing": ["warn", {"before": true, "after": true}],
"brace-style": 2,
"camelcase": [2, {"properties": "never"}],
"complexity": ["error", 10],
"brace-style": "error",
"camelcase": ["error", {"properties": "never"}],
"complexity": ["error", 5],
"eol-last": "warn",
"eqeqeq": "error",
"func-call-spacing": ["error", "never"],
"global-require": "error",
"handle-callback-err": "warn",
"indent": [1, "tab", {"SwitchCase": 1}],
"indent": ["warn", "tab", {"SwitchCase": 1}],
"key-spacing": ["error", {"beforeColon": false, "afterColon": true}],
"linebreak-style": 0,
"max-depth": ["error", 3],
"max-len": ["warn", { "code": 120, "tabWidth": 4 }],
"max-lines": ["warn", 150],
"max-lines-per-function": ["error", 35],
"max-lines": ["warn", {"max": 150, "skipBlankLines": true, "skipComments": true}],
"max-lines-per-function": ["warn", {"max": 20, "skipBlankLines": true, "skipComments": true}],
"max-nested-callbacks": ["error", 4],
"max-params": ["error", 6],
"max-statements": ["error", 22],
"no-cond-assign": 2,
"max-params": ["error", 5],
"max-statements": ["error", 20],
"no-cond-assign": "error",
"no-dupe-args": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-empty": "warn",
"no-empty-function": 2,
"no-empty-function": "error",
"no-multiple-empty-lines": "warn",
"no-extra-parens": 2,
"no-func-assign": 2,
"no-irregular-whitespace": 2,
"no-magic-numbers": [1, {"ignore": [-1, 0, 1]}],
"no-multi-spaces": 1,
"no-multi-str": 1,
"no-unexpected-multiline": 2,
"no-unreachable": 2,
"no-self-assign": 2,
"no-trailing-spaces": 1,
"no-undef": 2,
"no-unused-vars": 1,
"no-extra-parens": "error",
"no-func-assign": "error",
"no-irregular-whitespace": "error",
"no-magic-numbers": ["warn", {"ignore": [-1, 0, 1]}],
"no-multi-spaces": "warn",
"no-multi-str": "off",
"no-unexpected-multiline": "error",
"no-unreachable": "error",
"no-self-assign": "error",
"no-trailing-spaces": "warn",
"no-undef": "error",
"no-unused-vars": "warn",
"no-var": 2,
"prefer-arrow-callback": 1,
"prefer-const": 2,
"prefer-arrow-callback": "warn",
"prefer-const": "error",
"prefer-template": "error",
"quotes": [1, "single"],
"semi": [1, "never"],
"quotes": ["warn", "single"],
"semi": ["warn", "never"],
"space-before-blocks": ["error", { "functions": "always", "keywords": "always", "classes": "always" }],
"space-before-function-paren": [2, "never"],
"strict": [2, "global"],
"yoda": 2
},
"space-before-function-paren": ["error", "never"],
"strict": ["error", "global"],
"yoda": "error"
},
"overrides": [{
"files": [ "*.test.js", "*.spec.js", "sqlite-async.js" ],
"files": [ "*.test.js", "*.spec.js", "*.steps.js" ],
"rules": {
"global-require": "off",
"max-lines-per-function": "off",
@@ -0,0 +1,7 @@
#!/bin/sh

set -e # using the options command to abort script at first error
echo
echo "POST-COMMIT"
# ./node_modules/.bin/markdownlint --ignore node_modules .
echo

This file was deleted.

@@ -2,10 +2,30 @@
.DS_Store
node_modules/
coverage/
*.db
screenshots/*
docs/
package-lock.json
public/images/black/
private/
website.db.sqbpro
website.db.sqbpro

data/
coverage/
sessions/
screenshots/
__image_snapshots_/
__diff_output__/
trace/
.node-persist/

*.db
*snap.png
*diff.png
*trace.json
*.0x

*.pptx
*.mp4

*.codio
*.c9
@@ -0,0 +1,42 @@
image: node:latest

stages:
- code-testing
- staging-server
- acceptance-testing

linting:
stage: code-testing
script:
- npm install
- npm run linter

dependency-checks:
stage: code-testing
script:
- npm install
- npm run dependency

unit-testing:
stage: code-testing
script:
- npm install
- npm test

code-coverage:
stage: code-testing
script:
- npm install
- npm run coverage

coverage-report:
stage: staging-server
script:
- npm install
- npm run coverage
artifacts:
paths:
- docs
expire_in: 30 days
only:
- master
@@ -0,0 +1,33 @@

{
"line-length": false,
"no-inline-html": {
"allowed_elements": [
"a", "br"
]
},
"header-increment": true,
"ul-style": {
"style": "dash"
},
"ul-start-left": true,
"no-trailing-spaces": {
"br_spaces": 0
},
"no-hard-tabs": true,
"no-reversed-links": true,
"no-multiple-blanks": true,
"no-missing-space-atx": true,
"no-multiple-space-atx": true,
"blanks-around-headers": true,
"header-start-left": true,
"no-duplicate-header": true,
"single-h1": true,
"blanks-around-fences": true,
"blanks-around-lists": true,
"no-bare-urls": true,
"no-space-in-emphasis": true,
"no-space-in-code": true,
"no-space-in-links": true,
"fenced-code-language": true
}
@@ -1,12 +1,3 @@
## If `npm install` doesn't work and gives an error when setting up the template, here is one possible fix:

>Delete `node_modules` folder and `package-lock.json` <br/>
>Add `package-lock.json` as an exception in `.gitignore` <br/>
>Run `npm i` again
If it still doesn't work and it gives an error with Python and/or Microsoft Visual version, try installing `Microsoft Visual C++ 2017 Redistributable`

Any other bugs or problems please report to your tutor

# Assignment Template

@@ -25,14 +16,37 @@ Mirror Push to this new repository, replacing xxx with the url from the clipboar
Once you are sure the code is in your new repository, delete the temporary local repository.

`cd .. && rm -rf temp/`

Your private repository on GitHub will now contain a complete copy of this template including the commits that were already made. You can now start your assignment by carrying out the following steps:

Clone your private repository

Change your [local config settings](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup). This is a vital step otherwise your commits won't show on the GitHub _graph_ and your grade will be affected.
## Local Config Settings

Before you make any commits you need to update the [local config settings](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup). Start by using the Terminal (or Git Bash on Windows) navigate inside the project. Once you are in this directory run the following commands, substituting you name as it appears on your ID badge and your university email address (without the `uni.` domain prefix).

```bash
git config user.name 'John Doe'
git config user.email 'doej@coventry.ac.uk'
git config core.hooksPath .githooks
git config --add merge.ff false
```

Start working on the assignment. Remember to install all the dependencies listed in the `package.json` file.

## Feature Branching

Start working on the assignment.
You should not be committing directly to the **master** branch, instead each task or activity you complete should be in its own _feature branch_. You should following the following steps:

konrad
kyriakos
1. Log onto GitHub and add an issue to the _issue tracker_, this is your _todo_ list.
2. Create a local feature branch making sure that the name of the branch includes both the issue _number_ and _title_ (in lower case).
1. For example: `git checkout -b iss023/fix-login-bug`.
2. You can see a list of all the local branches using `git branch`.
3. As you work on the issue make your local commits by:
1. staging the files with `git add --all`.
2. committing with the `no-ff` flag, eg. `git commit --no-ff -m 'detailed commit message here'`.
4. When the task is complete and all the tests pass, push the feature branch to GitHub.
1. For example `git push origin iss023/fix-login-bug` would push the branch named above.
2. Switch back to the _master_ branch with `git checkout master`.
5. Back on GitHub raise a **Pull Request** that merges this feature branch to the _master_ branch.
5. If there are no issues you can then merge the branch using the button in the _Pull Request_ interface.
6. Pull the latest version of the master branch code using `git pull origin master`.
@@ -0,0 +1,70 @@
'use strict'

const puppeteer = require('puppeteer')
const { configureToMatchImageSnapshot } = require('jest-image-snapshot')
const PuppeteerHar = require('puppeteer-har')
const shell = require('shelljs')

const width = 800
const height = 600
const delayMS = 5

let browser
let page
let har

// threshold is the difference in pixels before the snapshots dont match
const toMatchImageSnapshot = configureToMatchImageSnapshot({
customDiffConfig: { threshold: 2 },
noColors: true,
})
expect.extend({ toMatchImageSnapshot })

beforeAll( async() => {
browser = await puppeteer.launch({ headless: true, slowMo: delayMS, args: [`--window-size=${width},${height}`] })
page = await browser.newPage()
har = new PuppeteerHar(page)
await page.setViewport({ width, height })
await shell.exec('acceptanceTests/scripts/beforeAll.sh')
})

afterAll( async() => {
browser.close()
await shell.exec('acceptanceTests/scripts/afterAll.sh')
})

beforeEach(async() => {
await shell.exec('acceptanceTests/scripts/beforeEach.sh')
})

describe('Registering', () => {
test('Register a user', async done => {
//start generating a trace file.
await page.tracing.start({path: 'trace/registering_user_har.json',screenshots: true})
await har.start({path: 'trace/registering_user_trace.har'})
//ARRANGE
await page.goto('http://localhost:8080/register', { timeout: 30000, waitUntil: 'load' })
//ACT
await page.type('input[name=user]', 'NewUser')
await page.type('input[name=pass]', 'password')
await page.click('input[type=submit]')
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' })
await page.type('input[name=user]', 'NewUser')
await page.type('input[name=pass]', 'password')
await page.click('input[type=submit]')
//ASSERT
//check that the user is taken to the homepage after attempting to login as the new user:
await page.waitForSelector('h1')
expect( await page.evaluate( () => document.querySelector('h1').innerText ) )
.toBe('Home')

// grab a screenshot
const image = await page.screenshot()
// compare to the screenshot from the previous test run
expect(image).toMatchImageSnapshot()
// stop logging to the trace files
await page.tracing.stop()
await har.stop()
done()
}, 16000)
})
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -e
echo afterAll
#Delete the databases that were used for the acceptance testing.
FILE=website.db
if test -f "$FILE"; then
rm -rf website.db
fi
#Restore the databases from before the acceptance tests were run, and delete the backups.
FILE=websiteBackup.db
if test -f "$FILE"; then
cp websiteBackup.db website.db
rm -rf websiteBackup.db
fi


@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e
echo beforeAll

#Make backups of the databases.
FILE=website.db
if test -f "$FILE"; then
cp website.db websiteBackup.db
rm -rf website.db
fi

@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e
echo beforeEach
#Delete the database files.
FILE=website.db
if test -f "$FILE"; then
rm -rf website.db
fi

0 comments on commit ea56ef5

Please sign in to comment.