mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-21 16:52:00 -07:00
fix(tests): Added user e2e tests back in
This commit is contained in:
@@ -30,7 +30,7 @@ const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
|
||||
const jsonFiles = new JsonFiles()
|
||||
|
||||
const JSON_FILE = `system-user-${config.env}.json`
|
||||
const JSON_PATH = `${__dirname.toString()}/../../config/${JSON_FILE}`
|
||||
const JSON_PATH = `${__dirname.toString()}../../config/${JSON_FILE}`
|
||||
|
||||
const LOCALHOST = `http://localhost:${config.port}`
|
||||
const context = {}
|
||||
@@ -90,6 +90,8 @@ class Admin {
|
||||
// applications like the Task Manager and the test scripts can access.
|
||||
|
||||
await jsonFiles.writeJSON(context, JSON_PATH)
|
||||
// console.log('context: ', context)
|
||||
// console.log('JSON_PATH: ', JSON_PATH)
|
||||
|
||||
return context
|
||||
} catch (err) {
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
/*
|
||||
import testUtils from '../../utils/test-utils.js';
|
||||
import { assert } from 'chai';
|
||||
import config from '../../../config/index.js';
|
||||
import axios from 'axios';
|
||||
import sinon from 'sinon';
|
||||
import util from 'util';
|
||||
import testUtils from '../../utils/test-utils.js'
|
||||
import { assert } from 'chai'
|
||||
import config from '../../../config/index.js'
|
||||
import axios from 'axios'
|
||||
import sinon from 'sinon'
|
||||
import util from 'util'
|
||||
|
||||
import UserController from '../../../src/controllers/rest-api/users/controller.js'
|
||||
import Adapters from '../../../src/adapters/index.js'
|
||||
import UseCases from '../../../src/use-cases/index.js'
|
||||
util.inspect.defaultOptions = { depth: 1 }
|
||||
|
||||
const LOCALHOST = `http://localhost:${config.port}`
|
||||
|
||||
const context = {}
|
||||
|
||||
import UserController from '../../../src/controllers/rest-api/users/controller.js';
|
||||
import Adapters from '../../../src/adapters/index.js';
|
||||
const adapters = new Adapters()
|
||||
import UseCases from '../../../src/use-cases/index.js';
|
||||
let uut
|
||||
let sandbox
|
||||
|
||||
@@ -39,7 +38,7 @@ describe('Users', () => {
|
||||
|
||||
// Get the JWT used to log in as the admin 'system' user.
|
||||
const adminJWT = await testUtils.getAdminJWT()
|
||||
// console.log(`adminJWT: ${admi nJWT}`)
|
||||
console.log(`adminJWT: ${adminJWT}`)
|
||||
context.adminJWT = adminJWT
|
||||
|
||||
// const admin = await testUtils.loginAdminUser()
|
||||
@@ -786,4 +785,3 @@ describe('Users', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
*/
|
||||
|
||||
@@ -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