276a72b4ce
* Migrated manual tests to jest and started working on better coverage * Added a bookmarklet and push key generation tool allowing URL pushing from bookmarklets * Updated web scraping with tons of bug fixes * Updated attachments page to handle new push links * Aggressive note change checking, if patches get out of sync, server overwrites bad updates.
67 lines
1.3 KiB
JavaScript
67 lines
1.3 KiB
JavaScript
const Note = require('../../models/Note')
|
|
const User = require('../../models/User')
|
|
const ShareNote = require('../../models/ShareNote')
|
|
|
|
const testUserName = 'jestTestUserNote'
|
|
const password = 'Beans1234!!!'
|
|
let newUserId = null
|
|
let masterKey = null
|
|
|
|
const testUserName2 = 'jestTestUserDude'
|
|
const password2 = 'Rice1234!!!'
|
|
let newUserId2 = null
|
|
let masterKey2 = null
|
|
|
|
|
|
let testNoteId = 0
|
|
let testNoteId2 = 0
|
|
// let sharedNoteId = 0 //ID of note shared with user
|
|
const shareUserId = 61
|
|
const searchWord1 = 'beans'
|
|
const searchWord2 = 'RICE'
|
|
const updatedNoteText = 'Some Note Text for Testing more '+searchWord2+' is nice'
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
// Find and Delete Previous Test user, log in, get key
|
|
return
|
|
User.getByUserName(testUserName)
|
|
.then(user => {
|
|
User.deleteUser(user?.id, password)
|
|
})
|
|
.then(user => {
|
|
User.getByUserName(testUserName2)
|
|
})
|
|
.then(user => {
|
|
User.deleteUser(user?.id, password)
|
|
})
|
|
.then((results) => {
|
|
|
|
return User.register(testUserName, password)
|
|
})
|
|
.then(({ token, userId }) => {
|
|
newUserId = userId
|
|
|
|
return User.getMasterKey(userId, password)
|
|
})
|
|
.then((newMasterKey) => {
|
|
masterKey = newMasterKey
|
|
|
|
return true
|
|
})
|
|
.catch(((error) => {
|
|
console.log(error)
|
|
}))
|
|
|
|
})
|
|
|
|
|
|
|
|
afterAll(done => {
|
|
// Close Database
|
|
const db = require('../../config/database')
|
|
db.end()
|
|
done()
|
|
}) |