Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
274 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cd databases/ | ||
rm -rf *.db | ||
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
'use strict' | ||
|
||
const puppeteer = require('puppeteer') | ||
const { configureToMatchImageSnapshot } = require('jest-image-snapshot') | ||
const width = 800 | ||
const height = 600 | ||
const delayMS = 0 | ||
const shell = require('shelljs') | ||
|
||
let browser | ||
let page | ||
|
||
// 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: false, slowMo: delayMS, args: [`--window-size=${width},${height}`] }) | ||
page = await browser.newPage() | ||
await page.setViewport({ width, height }) | ||
}) | ||
|
||
beforeEach( () => shell.exec('./abolishDB.sh')) | ||
|
||
afterAll( () => browser.close() ) | ||
|
||
describe('menu', () => { | ||
|
||
test('Main Menu', async done => { | ||
|
||
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' }) | ||
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' }) | ||
|
||
await page.click('[href="/register"]') | ||
|
||
await page.type('input[name=user]', 'Craig') | ||
await page.type('input[name=pass]', 'bread') | ||
|
||
await page.waitFor(1000) | ||
await page.click('input[type=submit]') | ||
await page.waitFor(1000) | ||
|
||
let title = await page.title() | ||
expect(title).toBe('Log In') | ||
|
||
await page.type('input[name=user]', 'Craig') | ||
await page.type('input[name=pass]', 'bread') | ||
|
||
await page.click('input[type=submit]') | ||
title = await page.title() | ||
expect(title).toBe('Main Menu') | ||
|
||
await page.click('button[name=Menu]') | ||
title = await page.title() | ||
expect(title).toBe('Main Menu') | ||
|
||
done() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
'use strict' | ||
|
||
const puppeteer = require('puppeteer') | ||
const { configureToMatchImageSnapshot } = require('jest-image-snapshot') | ||
const width = 800 | ||
const height = 600 | ||
const delayMS = 0 | ||
const shell = require('shelljs') | ||
|
||
let browser | ||
let page | ||
|
||
// 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: false, slowMo: delayMS, args: [`--window-size=${width},${height}`] }) | ||
page = await browser.newPage() | ||
await page.setViewport({ width, height }) | ||
}) | ||
|
||
beforeEach( () => shell.exec('./abolishDB.sh')) | ||
|
||
afterAll( () => browser.close() ) | ||
|
||
describe('login test cases', () => { | ||
|
||
test('No Username', async done => { | ||
|
||
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' }) | ||
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' }) | ||
|
||
await page.type('input[name=pass]', 'bread') | ||
|
||
await page.click('input[type=submit]') | ||
|
||
const title = await page.title() | ||
expect(title).toBe('ERROR') | ||
done() | ||
}) | ||
|
||
test('No password', async done => { | ||
|
||
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' }) | ||
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' }) | ||
|
||
await page.type('input[name=user]', 'bread') | ||
|
||
await page.click('input[type=submit]') | ||
|
||
const title = await page.title() | ||
expect(title).toBe('ERROR') | ||
done() | ||
}) | ||
}) | ||
|
||
describe('register', () => { | ||
|
||
test('No Username register', async done => { | ||
shell.exec('abolishDB.sh') | ||
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' }) | ||
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' }) | ||
|
||
await page.click('[href="/register"]') | ||
|
||
await page.type('input[name=pass]', 'bread') | ||
|
||
await page.click('input[type=submit]') | ||
|
||
const title = await page.title() | ||
expect(title).toBe('ERROR') | ||
done() | ||
}) | ||
|
||
test('No Password register', async done => { | ||
|
||
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' }) | ||
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' }) | ||
|
||
await page.click('[href="/register"]') | ||
|
||
await page.type('input[name=user]', 'bread') | ||
|
||
await page.click('input[type=submit]') | ||
|
||
const title = await page.title() | ||
expect(title).toBe('ERROR') | ||
done() | ||
}) | ||
|
||
test('Successful register', async done => { | ||
|
||
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' }) | ||
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' }) | ||
|
||
await page.click('[href="/register"]') | ||
|
||
await page.type('input[name=user]', 'Craig') | ||
await page.type('input[name=pass]', 'bread') | ||
|
||
await page.click('input[type=submit]') | ||
|
||
let title = await page.title() | ||
expect(title).toBe('Log In') | ||
|
||
await page.type('input[name=user]', 'Craig') | ||
await page.type('input[name=pass]', 'bread') | ||
|
||
await page.click('input[type=submit]') | ||
title = await page.title() | ||
expect(title).toBe('Main Menu') | ||
done() | ||
}) | ||
}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
server: { | ||
command: 'node index.js', | ||
port: 8080, | ||
}, | ||
launch: { | ||
headless: false, | ||
devtools: true, | ||
timeout: 30000 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
0 info it worked if it ends with ok | ||
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'acceptance' ] | ||
2 info using npm@3.5.2 | ||
3 info using node@v8.10.0 | ||
4 verbose run-script [ 'preacceptance', 'acceptance', 'postacceptance' ] | ||
5 info lifecycle 10_auth@1.0.0~preacceptance: 10_auth@1.0.0 | ||
6 silly lifecycle 10_auth@1.0.0~preacceptance: no script for preacceptance, continuing | ||
7 info lifecycle 10_auth@1.0.0~acceptance: 10_auth@1.0.0 | ||
8 verbose lifecycle 10_auth@1.0.0~acceptance: unsafe-perm in lifecycle true | ||
9 verbose lifecycle 10_auth@1.0.0~acceptance: PATH: /usr/share/npm/bin/node-gyp-bin:/home/cc/Documents/340CT_Project/node_modules/.bin:/home/cc/.local/bin:/home/cc/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games | ||
10 verbose lifecycle 10_auth@1.0.0~acceptance: CWD: /home/cc/Documents/340CT_Project | ||
11 silly lifecycle 10_auth@1.0.0~acceptance: Args: [ '-c', './test.sh' ] | ||
12 silly lifecycle 10_auth@1.0.0~acceptance: Returned: code: 1 signal: null | ||
13 info lifecycle 10_auth@1.0.0~acceptance: Failed to exec acceptance script | ||
14 verbose stack Error: 10_auth@1.0.0 acceptance: `./test.sh` | ||
14 verbose stack Exit status 1 | ||
14 verbose stack at EventEmitter.<anonymous> (/usr/share/npm/lib/utils/lifecycle.js:232:16) | ||
14 verbose stack at emitTwo (events.js:126:13) | ||
14 verbose stack at EventEmitter.emit (events.js:214:7) | ||
14 verbose stack at ChildProcess.<anonymous> (/usr/share/npm/lib/utils/spawn.js:24:14) | ||
14 verbose stack at emitTwo (events.js:126:13) | ||
14 verbose stack at ChildProcess.emit (events.js:214:7) | ||
14 verbose stack at maybeClose (internal/child_process.js:925:16) | ||
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) | ||
15 verbose pkgid 10_auth@1.0.0 | ||
16 verbose cwd /home/cc/Documents/340CT_Project | ||
17 error Linux 4.15.0-66-generic | ||
18 error argv "/usr/bin/node" "/usr/bin/npm" "run" "acceptance" | ||
19 error node v8.10.0 | ||
20 error npm v3.5.2 | ||
21 error code ELIFECYCLE | ||
22 error 10_auth@1.0.0 acceptance: `./test.sh` | ||
22 error Exit status 1 | ||
23 error Failed at the 10_auth@1.0.0 acceptance script './test.sh'. | ||
23 error Make sure you have the latest version of node.js and npm installed. | ||
23 error If you do, this is most likely a problem with the 10_auth package, | ||
23 error not with npm itself. | ||
23 error Tell the author that this fails on your system: | ||
23 error ./test.sh | ||
23 error You can get information on how to open an issue for this project with: | ||
23 error npm bugs 10_auth | ||
23 error Or if that isn't available, you can get their info via: | ||
23 error npm owner ls 10_auth | ||
23 error There is likely additional logging output above. | ||
24 verbose exit [ 1, true ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
echo hello | ||
mkdir -p screenshots | ||
mkdir -p trace | ||
cd databases/ | ||
rm -rf *.db | ||
cd .. | ||
# [ ! -d "node_modules" ] && echo "INSTALLING MODULES" && npm install | ||
node index.js& | ||
node_modules/.bin/jest --runInBand --detectOpenHandles acceptance\ tests/* | ||
read -p "Press enter to continue" | ||
kill %1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters