Skip to content
Permalink
Browse files
Merge pull request #18 from 340CT-1920SEPJAN/develop
Develop
  • Loading branch information
sellers3 committed Dec 1, 2019
2 parents 7d26793 + 73fb0ed commit 082294b1cbb185a440f6e2c6f5e02fd3ae3f23b6
Show file tree
Hide file tree
Showing 11 changed files with 6,260 additions and 2,566 deletions.
@@ -1,9 +1,18 @@
image: node:12.10.0
image: node:10.0.0

stages:
- build
- code-testing
- acceptance-testing

install-dependencies:
stage: build
script:
- npm install
artifacts:
paths:
- node_modules/

linting:
stage: code-testing
script:
@@ -15,23 +24,21 @@ unit-testing:
script:
- npm install
- apt-get update
- apt-get install -y -q libatk-bridge-2.0.so.0 gconf-service libasound2 libc6 libcairo2 libcups2 libexpat1 libfontconfig1 libgcc1 libnspr4 libstdc++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
- 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
script:
- npm install
- apt-get update
- apt-get install -y -q libatk-bridge-2.0.so.0 gconf-service libasound2 libc6 libcairo2 libcups2 libexpat1 libfontconfig1 libgcc1 libnspr4 libstdc++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
- 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
script:
- npm install --only=dev
- 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 acceptance
only:
- master
- 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 acceptance
@@ -1,10 +1,11 @@
/* eslint-disable max-len */
'use strict'

const puppeteer = require('puppeteer')
const { configureToMatchImageSnapshot } = require('jest-image-snapshot')
const width = 800
const height = 600
const delayMS = 0
const delayMS = 10
const shell = require('shelljs')

let browser
@@ -18,7 +19,7 @@ const toMatchImageSnapshot = configureToMatchImageSnapshot({
expect.extend({ toMatchImageSnapshot })

beforeAll( async() => {
browser = await puppeteer.launch({ headless: true, slowMo: delayMS, args: [`--window-size=${width},${height} --no-sandbox`] })
browser = await puppeteer.launch({ headless: true, slowMo: delayMS, args: [`--window-size=${width},${height}`, '--no-sandbox'] })
page = await browser.newPage()
await page.setViewport({ width, height })
})
@@ -39,9 +40,7 @@ describe('menu', () => {
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()

@@ -96,9 +95,7 @@ describe('menu', () => {
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()

await page.type('input[name=user]', 'Craig')
@@ -157,9 +154,7 @@ describe('menu', () => {
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()

await page.type('input[name=user]', 'Craig')
@@ -218,9 +213,7 @@ describe('menu', () => {
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()

await page.type('input[name=user]', 'Craig')
@@ -246,10 +239,8 @@ describe('menu', () => {

await page.click('input[name=add]')

await page.waitFor(1000)
await page.goto('http://localhost:8080/ready', { timeout: 30000, waitUntil: 'load' })
await page.click('input[name=ready]')
await page.waitFor(1000)

let ID = await page.evaluate(() => {
const dom = document.querySelectorAll('td[name=readyID]')
@@ -260,7 +251,6 @@ describe('menu', () => {
expect(ID).toStrictEqual(['1'])

await page.click('input[name=unready]')
await page.waitFor(1000)

ID = await page.evaluate(() => {
const dom = document.querySelectorAll('td[name=unreadyID]')
@@ -1,10 +1,11 @@
/* eslint-disable max-len */
'use strict'

const puppeteer = require('puppeteer')
const { configureToMatchImageSnapshot } = require('jest-image-snapshot')
const width = 800
const height = 600
const delayMS = 0
const delayMS = 10
const shell = require('shelljs')

let browser
@@ -18,7 +19,7 @@ const toMatchImageSnapshot = configureToMatchImageSnapshot({
expect.extend({ toMatchImageSnapshot })

beforeAll( async() => {
browser = await puppeteer.launch({ headless: false, slowMo: delayMS, args: [`--window-size=${width},${height} --no-sandbox`] })
browser = await puppeteer.launch({ headless: true, slowMo: delayMS, args: [`--window-size=${width},${height}`, '--no-sandbox'] })
page = await browser.newPage()
await page.setViewport({ width, height })
})
@@ -4,7 +4,7 @@ module.exports = {
displayName: 'test',
verbose: true,
collectCoverage: true,
'preset': 'jest-puppeteer',
"preset": "jest-puppeteer",
coverageThreshold: {
global: {
branches: 0,
@@ -6,7 +6,7 @@ module.exports = {
port: 8080,
},
launch: {
headless: false,
headless: true,
devtools: true,
timeout: 30000
}
@@ -0,0 +1,41 @@
/* eslint-disable no-magic-numbers */
/* eslint-disable max-lines-per-function */
'use strict'

const pdf = require('/home/cc/Documents/340CT_Project/node_modules/pdf/lib/pdf').pdf
const fs = require('fs')

module.exports = class Order {

createPDF(data) {
console.log('data = ', data)
const doc = new pdf()
doc.text(20, 20, 'Menu')
doc.text(20, 30, 'Name')
doc.text(100, 30, 'Type')
doc.text(140, 30, 'Price')
let line = 40
for(let i = 0; i< data.itemName.length; i++) {
doc.text(20, line, data.itemName[i])
doc.text(100, line, data.itemType[i])
doc.text(140, line,${data.itemPrice[i]}`)
line = line + 10
}
doc.setProperties({
title: 'Menu',
subject: 'Items in the current Menu',
author: 'User',
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!`)
})
}
}

0 comments on commit 082294b

Please sign in to comment.