Skip to content
Permalink
Browse files
Merge pull request #21 from 340CT-1920SEPJAN/develop
Develop
  • Loading branch information
sellers3 committed Dec 2, 2019
2 parents dbb7650 + 8361256 commit f2e37868de0801d5520d916aa7a35ef614bc2209
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 13 deletions.
@@ -2,8 +2,8 @@ image: node:10.0.0

stages:
- build
- code-testing
- acceptance-testing
- quality-check
- testing

install-dependencies:
stage: build
@@ -14,29 +14,29 @@ install-dependencies:
- node_modules/

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

unit-testing:
stage: acceptance-testing
stage: testing
script:
- npm install
- apt-get update
- apt-get install -y -q gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget -y
- npm run test

code-coverage:
stage: acceptance-testing
stage: testing
script:
- npm install
- apt-get update
- apt-get install -y -q gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget -y
- npm run coverage

acceptance-tests:
stage: acceptance-testing
stage: testing
script:
- npm install --only=dev
- apt-get update
@@ -5,7 +5,7 @@ const puppeteer = require('puppeteer')
const { configureToMatchImageSnapshot } = require('jest-image-snapshot')
const width = 800
const height = 600
const delayMS = 10
const delayMS = 100
const shell = require('shelljs')

let browser
@@ -32,6 +32,8 @@ describe('menu', () => {

test('Main Menu', async done => {

jest.setTimeout(30000)

await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' })
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' })

@@ -0,0 +1,60 @@
/* eslint-disable max-len */
'use strict'

const puppeteer = require('puppeteer')
const { configureToMatchImageSnapshot } = require('jest-image-snapshot')
const width = 800
const height = 600
const delayMS = 100
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: true, slowMo: delayMS, args: [`--window-size=${width},${height}`, '--no-sandbox'] })
page = await browser.newPage()
await page.setViewport({ width, height })
})

beforeEach( () => shell.exec('./abolishDB.sh'))

afterAll( () => browser.close() )

describe('menu', () => {

test('Main Menu', async done => {

jest.setTimeout(30000)

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.select('select[name=auth]', 'Kitchen')
await page.type('input[name=user]', 'Craig')
await page.type('input[name=pass]', 'bread')

await page.click('input[type=submit]')

await page.type('input[name=user]', 'Craig')
await page.type('input[name=pass]', 'bread')

await page.click('input[type=submit]')

await page.click('button[name=Order]')
const title = await page.title()
expect(title).toBe('Main Menu')

done()

})
})
@@ -28,14 +28,10 @@ module.exports = class Order {
keywords: 'Menu, Restaurant, Price,',
creator: 'User'})
doc.addPage()
//doc.setFontSize(22)
//doc.text(20, 20, 'This is a title')
//doc.setFontSize(16)
//doc.text(20, 30, 'This is some normal sized text underneath.')
const fileName = `testFile${new Date().getSeconds()}.pdf`
// eslint-disable-next-line handle-callback-err
fs.writeFile(fileName, doc.output(), (err, data) => {
console.log(`${fileName } was created! great success!`)
console.log(`${fileName} was created! great success!`)
})
}
}
@@ -92,6 +92,7 @@ router.get('/menu', async ctx => {
router.post('/menu', async ctx => {
try {
const body = ctx.request.body
console.log(body)
const pdf = new PDF()
pdf.createPDF(body)
ctx.redirect('/menu')
@@ -35,6 +35,7 @@ router.post('/register', koaBody, async ctx => {
try {
// extract the data from the request
const body = ctx.request.body
console.log(body)
// call the functions in the module
const user = await new User(dbUsers)
await user.register(body.user, body.pass, body.auth)
@@ -16,7 +16,7 @@
<select name="auth">
<option value="Admin">Admin</option>
<option value="Kitchen">Kitchen</option>
<option value="Waiting">waiting</option>
<option value="Waiting">Waiting</option>
</select>
</p>
<p>Username:<br /><input type="text" name="user" placeholder="your preferred username (no spaces)" value=""></p>

0 comments on commit f2e3786

Please sign in to comment.