Commit 3351b716 authored by pengyunqian's avatar pengyunqian

Merge branch 'pyq' into dev

parents 8edd5f55 70afaa9b
/*
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/
module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,
// Stop running tests after `n` failures
// bail: 0,
// The directory where Jest should store its cached dependency information
// cacheDirectory: "/private/var/folders/5p/f45l166j057533bqfd5n9w880000gp/T/jest_dy",
// Automatically clear mock calls and instances between every test
clearMocks: true,
// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,
// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: undefined,
// The directory where Jest should output its coverage files
// coverageDirectory: undefined,
// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],
// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",
// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],
// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,
// A path to a custom dependency extractor
// dependencyExtractor: undefined,
// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,
// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],
// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,
// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,
// A set of global variables that need to be available in all test environments
// globals: {},
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",
// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],
// An array of file extensions your modules use
moduleFileExtensions: ["js", "json", "vue"],
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
"@/(.*)$": "<rootDir>/src/$1"
},
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],
// Activates notifications for test results
// notify: false,
// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",
// A preset that is used as a base for Jest's configuration
// preset: undefined,
// Run tests from one or more projects
// projects: undefined,
// Use this configuration option to add custom reporters to Jest
// reporters: undefined,
// Automatically reset mock state between every test
// resetMocks: false,
// Reset the module registry before running each individual test
// resetModules: false,
// A path to a custom resolver
// resolver: undefined,
// Automatically restore mock state between every test
// restoreMocks: false,
// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,
// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],
// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",
// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],
// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],
// The test environment that will be used for testing
testEnvironment: "jsdom",
// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
// Adds a location field to test results
// testLocationInResults: false,
// The glob patterns Jest uses to detect test files
// testMatch: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[tj]s?(x)"
// ],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],
// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
// This option allows the use of a custom results processor
// testResultsProcessor: undefined,
// This option allows use of a custom test runner
// testRunner: "jest-circus/runner",
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",
// A map from regular expressions to paths to transformers
transform: {
"^.+\\.vue$": "vue3-jest",
"^.+\\.js$": "babel-jest"
}
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
// "\\.pnp\\.[^\\/]+$"
// ],
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
// Indicates whether each individual test should be reported during the run
// verbose: undefined,
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],
// Whether to use watchman for file crawling
// watchman: true,
};
......@@ -11,7 +11,7 @@
"web-dev": "NODE_ENV=development vue-cli-service serve",
"web-test": "NODE_ENV=test vue-cli-service build",
"web-build": "NODE_ENV=production vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"test:unit": "jest",
"lint": "vue-cli-service lint"
},
"dependencies": {
......@@ -34,6 +34,7 @@
"vuex": "^4.0.0-beta.4"
},
"devDependencies": {
"@testing-library/vue": "^6.4.2",
"@vue/cli-plugin-babel": "^4.5.6",
"@vue/cli-plugin-eslint": "^4.5.6",
"@vue/cli-plugin-unit-jest": "^4.5.6",
......@@ -42,15 +43,18 @@
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/test-utils": "^2.0.0-alpha.1",
"babel-eslint": "^10.1.0",
"babel-jest": "^27.0.6",
"cross-env": "^7.0.3",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-vue": "^7.0.0-alpha.0",
"jest": "^27.0.6",
"less": "^3.0.4",
"less-loader": "^5.0.0",
"nodemon": "^2.0.7",
"pm2": "3.5.1",
"prettier": "^1.19.1"
"prettier": "^1.19.1",
"vue3-jest": "^27.0.0-alpha.1"
},
"browserslist": [
"> 1%",
......
......@@ -18,7 +18,8 @@ exports.httpReq = (ctx, opts) => {
request(opts, (err, res, body) => {
console.info(
`[Api] httpReq (${opts.url}, user:[${opts.qs.op_cur_user
`[Api] httpReq (${opts.url}, user:[${
opts.qs.op_cur_user
}]) spent: ${+new Date() - time_start}ms`
);
......@@ -31,5 +32,3 @@ exports.httpReq = (ctx, opts) => {
});
});
};
......@@ -70,7 +70,7 @@
<script>
import {
get_role_info as reqGet_role_info,
getAll_role_list as reqGetAll_role_list
getAll_role_list as reqGetAll_role_list,
} from "../../service/role";
export default {
name: "RoleDetail",
......@@ -82,7 +82,7 @@ export default {
multiple: true, //设置为多选
value: "id", //value值和哪个值绑定
label: "desc", //label值和哪个值绑定
children: "sub_permissions" //children值和哪个值绑定
children: "sub_permissions", //children值和哪个值绑定
},
selectedOptions: [],
permissionsAll: [],
......@@ -95,17 +95,17 @@ export default {
update_user_name: "",
create_time: "",
create_user_name: "",
role_account_list: []
}
role_account_list: [],
},
};
},
mounted() {
this.roleId = this.$route.query.roleId;
let { email } = this.$store.state.userInfo;
reqGetAll_role_list(email, this.appId).then(res => {
reqGetAll_role_list(email, this.appId).then((res) => {
this.permissionsAll = res.permissions;
});
reqGet_role_info(this.roleId, this.appId).then(res => {
reqGet_role_info(this.roleId, this.appId).then((res) => {
const {
role_name,
role_status,
......@@ -114,7 +114,7 @@ export default {
create_time,
create_user_name,
role_account_list,
permissions
permissions,
} = res.result;
this.role_info_detail = {
role_name,
......@@ -123,7 +123,7 @@ export default {
update_user_name,
create_time,
create_user_name,
role_account_list
role_account_list,
};
this.editEchoData(permissions);
});
......@@ -135,18 +135,18 @@ export default {
//遍历回显值selectedOptions
editEchoData(permissions) {
let selectData = [];
permissions.map(item => {
permissions.map((item) => {
let one = { id: item.id };
if (item.sub_permissions) {
item.sub_permissions.map(info => {
item.sub_permissions.map((info) => {
let selectId = [one.id, info.id];
selectData.push(selectId);
});
}
});
this.selectedOptions = selectData;
}
}
},
},
};
</script>
<style lang="less" scoped>
......
import { render } from "@testing-library/vue";
import ExaminePage from "..";
import { getApplyList } from "@/service/Withdrawal/withdrawal";
import store from "@/store";
jest.mock("@/service/Withdrawal/withdrawal");
it("should not enable audition for people without such privilege", () => {
const $route = {
path: "/op/withdrawal/examine"
};
getApplyList.mockResolvedValue({
code: 0,
status: "success",
result: {
list: [
{
withdraw_apply_id: "21072711253403105009",
wallet_id: "21072214560673105003",
user_id: 510227177373,
amount: "6.00",
withdraw_apply_status: 0,
withdraw_audit_time: "2021-07-27 11:25:34",
refuse_reason: "",
audit_user_name: "",
create_time: "2021-07-27 11:25:34",
lately_amount: "0.00",
id: "21072711253403105009",
city_name: "简网员工",
lately_share: 0,
lately_download: 0,
history_share: 52,
history_download: 0,
history_download_keep: "0%",
status_text: "待审核"
}
],
count: 1
}
});
const { getByText } = render(ExaminePage, {
store,
global: {
mocks: {
$route,
$store: {
getters: {
moduleSubPermissions: jest.fn().mockReturnValue(true)
}
}
}
}
});
getByText("审核");
});
......@@ -37,7 +37,11 @@
<el-form inline class="search_condition">
<!-- 用户id -->
<el-form-item label="用户id">
<el-input v-model="searchProps.user_id"></el-input>
<el-input v-model="searchProps.user_id" @input="
searchProps.user_id = $event
.replace(/[^a-z0-9A-Z\u4e00-\u9fa5()()\\-]+/g, '')
.replace(/\s/g, '')
"></el-input>
</el-form-item>
<el-button
type="primary"
......@@ -73,13 +77,23 @@
prop="lately_share"
align="center"
></el-table-column>
<el-table-column
label="近两天分享下载量"
prop="lately_download"
align="center"
></el-table-column>
<el-table-column
label="历史分享增长"
prop="history_share"
align="center"
></el-table-column>
<el-table-column
label="历史分享留存"
label="历史分享下载量"
prop="history_download"
align="center"
></el-table-column>
<el-table-column
label="历史下载留存"
prop="history_download_keep"
align="center"
></el-table-column>
......@@ -102,7 +116,7 @@
></el-table-column>
<!-- 操作快捷键 -->
<el-table-column label="操作" align="center" fixed="right" width="200">
<template #default="scope">
<template v-slot:default="scope">
<el-button
type="text"
@click="handleDetail('look', scope.row.id)"
......@@ -221,8 +235,8 @@
label="分享用户量"
width="120"
>
<template #default="scope">
<span>{{ "+" + scope.row.amount }}</span>
<template v-slot:default="scope">
<span>{{ scope ? "+" + scope.row.amount : null }}</span>
</template>
</el-table-column>
<el-table-column
......@@ -266,7 +280,7 @@ import {
getApplyDetail,
getFreezingFund,
getRolesForUser,
} from "../../../service/Withdrawal/withdrawal";
} from "@/service/Withdrawal/withdrawal";
import { ElMessage } from "element-plus";
import { fetchCurrentUser } from "../../../service/user";
......@@ -332,7 +346,6 @@ export default {
},
async mounted() {
const res = await this.getPermissionsAll();
console.log(res);
if (!res) {
this.$router.push({ name: "Forbidden" });
......@@ -532,7 +545,7 @@ export default {
(item) => item.id === AUDIT_PERMSSION_ID
);
return !!auditPermission;
return auditPermission.length !== 0;
},
},
};
......
......@@ -7,19 +7,26 @@ const withdrawalRoutes = [
{
path: "/op/withdrawal/examine",
name: "Examine",
component: () => import(/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Examine"),
component: () =>
import(/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Examine")
},
//用户管理
{
path: "/op/withdrawal/user",
name: "User",
component: () => import(/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/User/userList"),
component: () =>
import(
/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/User/userList"
)
},
//角色管理
{
path: "/op/withdrawal/roleAddRole",
name: "AddRole",
component: () => import(/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Role/add-role"),
component: () =>
import(
/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Role/add-role"
),
meta: {
requireAuth: true,
keepAlive: true
......@@ -28,7 +35,10 @@ const withdrawalRoutes = [
{
path: "/op/withdrawal/roleManageRole",
name: "ManageRole",
component: () => import(/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Role/manage-role"),
component: () =>
import(
/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Role/manage-role"
),
meta: {
requireAuth: true,
keepAlive: true
......@@ -37,11 +47,11 @@ const withdrawalRoutes = [
{
path: "/op/withdrawal/roleRoleDetail",
name: "RoleDetail",
component: () => import(/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Role/role-detail"),
meta: {
keepAlive: true
}
},
component: () =>
import(
/* webpackChunkName: "Withdrawal" */ "@/pages/Withdrawal/Role/role-detail"
)
}
];
export default withdrawalRoutes;
\ No newline at end of file
export default withdrawalRoutes;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment