mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-service.git
synced 2026-09-21 16:52:03 -07:00
fix(tests): Added user e2e tests back in
This commit is contained in:
@@ -4,15 +4,21 @@
|
||||
|
||||
// Public NPM libraries
|
||||
import mongoose from 'mongoose'
|
||||
|
||||
import axios from 'axios'
|
||||
|
||||
// Local libraries
|
||||
import config from '../../config/index.js'
|
||||
|
||||
import User from '../../src/adapters/localdb/models/users.js'
|
||||
import JsonFiles from '../../src/adapters/json-files.js'
|
||||
|
||||
// Hack to get __dirname back.
|
||||
// https://blog.logrocket.com/alternatives-dirname-node-js-es-modules/
|
||||
import * as url from 'url'
|
||||
|
||||
const jsonFiles = new JsonFiles()
|
||||
|
||||
const LOCALHOST = `http://localhost:${config.port}`
|
||||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
|
||||
|
||||
// Remove all collections from the DB.
|
||||
async function cleanDb () {
|
||||
@@ -112,9 +118,11 @@ async function loginTestUser () {
|
||||
|
||||
async function loginAdminUser () {
|
||||
try {
|
||||
const FILENAME = `../../config/system-user-${config.env}.json`
|
||||
const adminUserData = require(FILENAME)
|
||||
console.log(`adminUserData: ${JSON.stringify(adminUserData, null, 2)}`)
|
||||
const FILENAME = `${__dirname.toString()}../../config/system-user-${config.env}.json`
|
||||
// console.log('FILENAME: ', FILENAME)
|
||||
|
||||
const adminUserData = await jsonFiles.readJSON(FILENAME)
|
||||
// console.log(`adminUserData: ${JSON.stringify(adminUserData, null, 2)}`)
|
||||
|
||||
const options = {
|
||||
method: 'POST',
|
||||
@@ -151,8 +159,9 @@ async function getAdminJWT () {
|
||||
// process.env.KOA_ENV = process.env.KOA_ENV || 'dev'
|
||||
// console.log(`env: ${process.env.KOA_ENV}`)
|
||||
|
||||
const FILENAME = `../../config/system-user-${config.env}.json`
|
||||
const adminUserData = require(FILENAME)
|
||||
const FILENAME = `${__dirname.toString()}../../config/system-user-${config.env}.json`
|
||||
// console.log('FILENAME: ', FILENAME)
|
||||
const adminUserData = await jsonFiles.readJSON(FILENAME)
|
||||
// console.log(`adminUserData: ${JSON.stringify(adminUserData, null, 2)}`)
|
||||
|
||||
return adminUserData.token
|
||||
|
||||
Reference in New Issue
Block a user