Skip to content
Permalink
Browse files
local
  • Loading branch information
com.xamarin committed Apr 1, 2021
1 parent 8eabb96 commit f6831b51948bb8d034b4083981d39c662f81dfb0
Show file tree
Hide file tree
Showing 219 changed files with 18,821 additions and 8,250 deletions.
@@ -0,0 +1 @@
node_modules

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

BIN +0 Bytes (100%) Database.db
Binary file not shown.
@@ -1,24 +1,10 @@
## HOW TO RUN

1. `npm i` to install all dependencies
2. `nodemon index` to run the server
3. `npm run acceptance` to run acceptance tests
4. `npm test` to see test coverage
5. `npm run linter` to see code quality (eslint results)
6. `npm run jsdoc` to generate documentation about all available methods

You can view and play around with the website after you have ran nodemon command at : __http://localhost:5000__

For technician login: __http://localhost:5000/tech/login__

## IF ERRORS OCCUR WHEN TRYING TO DOWNLOAD A PDF

FIX - manually create a folder `pdfs` in `public` folder

final path should be - `public/pdfs`

## EMAILS DON'T WORK ON UNIVERSITY NETWORK !!!

To send emails change the variables `mailUser`, `mailPass`, `mailHost` and `mailPort` in `__DIRNAME__/Mail/mailer.js` to your Mailtrap or any other mailing service

# ENJOY :)
Dependency to run the APP:
1. ‘npm install I’ to install all the dependencies
2. ‘npm install nodemon index’ for running the sever
3. ‘npm run acceptance’ to run acceptance test
4. ‘npm run test ‘ to run test
5. ‘npm run linter’ to check code quality
6. ‘npm run jsdoc’ this generate documents regards to available methods
7. ‘npm start’ to start the server
8. http://localhost:4000/login to view user login page
9. http://localhost:4000/tech/login to view technician page
@@ -36,36 +36,36 @@ afterAll( async() => {

describe('register', () => {
test('register technician', async done => {
// start generating a trace file
// trace file
await page.tracing.start({path: 'trace/register_technician_har.json',screenshots: true})
await har.start({ path: 'trace/register_technician_trace.har' })
// ARRANGE
await page.goto('http://localhost:5000', { timeout: 30000, waitUntil: 'load' })
await page.goto('http://localhost:5000/tech/register', { timeout: 30000, waitUntil: 'load' })
await page.goto('http://localhost:4000', { timeout: 30000, waitUntil: 'load' })
await page.goto('http://localhost:4000/tech/register', { timeout: 30000, waitUntil: 'load' })
// take a screenshot and save to the file system
await page.screenshot({ path: 'screenshots/register.png' })

// ACT
// complete the form and click submit

// complete form and submit
await page.type('input[name=user]', 'felix')
await page.type('input[name=email]', 'fgeorge0307@gmail.com')
await page.type('input[name=pass]', '123456')
await page.click('input[type=submit]')
await page.waitForSelector('nav')
// await page.waitFor(1000) // sometimes you need a second delay


// ASSERT
const title = await page.title()
expect(title).toBe('Dashboard')

// extracting the text inside the first H1 element on the page
// extracting H1 text element on the page
const heading = await page.evaluate( () => {
const dom = document.querySelector('nav .nav-container a span.hide-md')
return dom.innerText
})
expect(heading).toBe('Domestic Repair')

// grab a screenshot
// grab imgge short
const image = await page.screenshot()
// compare to the screenshot from the previous test run
expect(image).toMatchImageSnapshot()
@@ -76,40 +76,40 @@ describe('register', () => {
}, 10000)

test('register duplicate technician', async done => {
// start generating a trace file
// trace file
await page.tracing.start({path: 'trace/register_dup_technician_har.json',screenshots: true})
await har.start({ path: 'trace/register_dup_technician_trace.har' })
// ARRANGE
await page.goto('http://localhost:5000', { timeout: 30000, waitUntil: 'load' })
await page.goto('http://localhost:5000/tech/register', { timeout: 30000, waitUntil: 'load' })
// take a screenshot and save to the file system
await page.goto('http://localhost:4000', { timeout: 30000, waitUntil: 'load' })
await page.goto('http://localhost:4000/tech/register', { timeout: 30000, waitUntil: 'load' })
// take a imgaeshot and save to the file system
await page.screenshot({ path: 'screenshots/register_dup.png' })

// ACT
// complete the form and click submit
await page.type('input[name=user]', 'dodo')
await page.type('input[name=email]', 'dodo@gmail.com')

// complete form and submit
await page.type('input[name=user]', 'brynt')
await page.type('input[name=email]', 'brynt@gmail.com')
await page.type('input[name=pass]', '123456')
await page.click('input[type=submit]')
await page.waitForSelector('p.error')
// await page.waitFor(1000) // sometimes you need a second delay


// ASSERT
// put
const title = await page.title()
expect(title).toBe('Register')

// extracting the text inside the first H1 element on the page
// extracting H1 text element on the page
const heading = await page.evaluate( () => {
const dom = document.querySelector('p.error')
return dom.innerText
})
expect(heading).toBe('username "dodo" already in use')
expect(heading).toBe('username "brynt" already in use')

// grab a screenshot
// grab a imageshot
const image = await page.screenshot()
// compare to the screenshot from the previous test run
// look on imageshot from the previous test run
expect(image).toMatchImageSnapshot()
// stop logging to the trace files
// stop trace files
await page.tracing.stop()
await har.stop()
done()
@@ -119,17 +119,17 @@ describe('register', () => {

describe('login', () => {
test('login technician', async done => {
// start generating a trace file
// trace file
await page.tracing.start({path: 'trace/login_technician_har.json',screenshots: true})
await har.start({ path: 'trace/login_technician_trace.har' })
// ARRANGE
await page.goto('http://localhost:5000', { timeout: 30000, waitUntil: 'load' })
await page.goto('http://localhost:5000/tech/login', { timeout: 30000, waitUntil: 'load' })
// take a screenshot and save to the file system
await page.goto('http://localhost:4000', { timeout: 30000, waitUntil: 'load' })
await page.goto('http://localhost:4000/tech/login', { timeout: 30000, waitUntil: 'load' })
// imageshot save to the file system
await page.screenshot({ path: 'screenshots/login.png' })

// ACT
// complete the form and click submit

// complete form and submit
await page.type('input[name=user]', 'felix')
await page.type('input[name=pass]', '123456')
await page.click('input[type=submit]')
@@ -140,18 +140,18 @@ describe('login', () => {
const title = await page.title()
expect(title).toBe('Dashboard')

// extracting the text inside the first H1 element on the page
// extracting first text H1 element on the page
const heading = await page.evaluate( () => {
const dom = document.querySelector('nav .nav-container a span.hide-md')
return dom.innerText
})
expect(heading).toBe('Domestic Repair')

// grab a screenshot
// grab a imageshot
const image = await page.screenshot()
// compare to the screenshot from the previous test run
// look on imageshot from the previous test run
expect(image).toMatchImageSnapshot()
// stop logging to the trace files
// stop traced files
await page.tracing.stop()
await har.stop()
done()
@@ -162,35 +162,35 @@ describe('login', () => {
await page.tracing.start({path: 'trace/login_wrong_technician_har.json',screenshots: true})
await har.start({ path: 'trace/login_wrong_technician_trace.har' })
// ARRANGE
await page.goto('http://localhost:5000', { timeout: 30000, waitUntil: 'load' })
await page.goto('http://localhost:5000/tech/login', { timeout: 30000, waitUntil: 'load' })
await page.goto('http://localhost:4000', { timeout: 30000, waitUntil: 'load' })
await page.goto('http://localhost:4000/tech/login', { timeout: 30000, waitUntil: 'load' })
// take a screenshot and save to the file system
await page.screenshot({ path: 'screenshots/login_wrong.png' })

// ACT
// complete the form and click submit
await page.type('input[name=user]', 'dodobrat')
await page.type('input[name=user]', 'grace')
await page.type('input[name=pass]', '123456')
await page.click('input[type=submit]')
await page.waitForSelector('p.error')
// await page.waitFor(1000) // sometimes you need a second delay

// ASSERT
// PUT
const title = await page.title()
expect(title).toBe('Login')

// extracting the text inside the first H1 element on the page
// extracting the H1 text element on the page
const heading = await page.evaluate( () => {
const dom = document.querySelector('p.error')
return dom.innerText
})
expect(heading).toBe('username "dodobrat" not found')
expect(heading).toBe('username "grace" not found')

// grab a screenshot
const image = await page.screenshot()
// compare to the screenshot from the previous test run
// look on imageshot from the previous test run
expect(image).toMatchImageSnapshot()
// stop logging to the trace files
// stop traced files
await page.tracing.stop()
await har.stop()
done()
@@ -3,13 +3,13 @@
set -e
echo afterAll
#Delete the databases that were used for the acceptance testing.
FILE=website.db
FILE=Database.db
if test -f "$FILE"; then
rm -rf website.db
rm -rf Database.db
fi
#Restore the databases from before the acceptance tests were run, and delete the backups.
FILE=websiteBackup.db
FILE=DatabaseBackup.db
if test -f "$FILE"; then
cp websiteBackup.db website.db
rm -rf websiteBackup.db
cp DatabaseBackup.db Database.db
rm -rf DatabaseBackup.db
fi
@@ -6,6 +6,6 @@ echo beforeAll
#Make backups of the databases.
FILE=website.db
if test -f "$FILE"; then
cp website.db websiteBackup.db
rm -rf website.db
cp Database.db DatabaseBackup.db
rm -rf Database.db
fi
@@ -48,8 +48,7 @@ var addSorting = (function() {
}
return cols;
}
// attaches a data attribute to every tr element with an object
// of data values keyed by column name
// attached data attribute to every tr element with an object
function loadRowData(tableRow) {
var tableCols = tableRow.querySelectorAll('td'),
colNode,
@@ -68,7 +67,7 @@ var addSorting = (function() {
}
return data;
}
// loads all row data
// add all row data
function loadData() {
var rows = getTableBody().querySelectorAll('tr'),
i;
@@ -77,7 +76,7 @@ var addSorting = (function() {
rows[i].data = loadRowData(rows[i]);
}
}
// sorts the table using the data for the ith column
// sorts the table
function sortByIndex(index, desc) {
var key = cols[index].key,
sorter = function(a, b) {
@@ -116,13 +115,13 @@ var addSorting = (function() {
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
col.className = cls;
}
// adds sort indicators for current column being sorted
// adds sort indicators
function addSortIndicators() {
getNthColumn(currentSort.index).className += currentSort.desc
? ' sorted-desc'
: ' sorted';
}
// adds event listeners for all sorter widgets
// adds event listeners
function enableUI() {
var i,
el,
@@ -155,7 +154,7 @@ var addSorting = (function() {
}
}
}
// adds sorting functionality to the UI
// SORT FUNTIONAL UI
return function() {
if (!getTable()) {
return;
Binary file not shown.

0 comments on commit f6831b5

Please sign in to comment.