fix integration tests and paths for client tests

This commit is contained in:
Matteo Pagliazzi
2019-10-03 17:40:38 +02:00
parent d19b3857ee
commit 2a4e103812
37 changed files with 50 additions and 126 deletions

View File

@@ -87,11 +87,9 @@
"test:nodemon": "gulp test:nodemon", "test:nodemon": "gulp test:nodemon",
"coverage": "COVERAGE=true mocha --require register-handlers.js --reporter html-cov > coverage.html; open coverage.html", "coverage": "COVERAGE=true mocha --require register-handlers.js --reporter html-cov > coverage.html; open coverage.html",
"sprites": "gulp sprites:compile", "sprites": "gulp sprites:compile",
"client:dev": "node webpack/dev-server.js", "client:dev": "cd website/client && npm run serve",
"client:build": "gulp build:client", "client:build": "cd website/client && npm run build",
"client:unit": "cross-env NODE_ENV=test karma start test/client/unit/karma.conf.js --single-run", "client:unit": "cd website/client && npm run test:unit",
"client:unit:watch": "cross-env NODE_ENV=test karma start test/client/unit/karma.conf.js",
"client:test": "npm run client:unit",
"start": "gulp nodemon", "start": "gulp nodemon",
"postinstall": "gulp build", "postinstall": "gulp build",
"apidoc": "gulp apidoc" "apidoc": "gulp apidoc"

View File

@@ -11,7 +11,7 @@ import {
each, each,
} from 'lodash'; } from 'lodash';
import { model as User } from '../../../../../website/server/models/user'; import { model as User } from '../../../../../website/server/models/user';
import * as payments from '../../../../../website/server/libs/payments/payments'; import payments from '../../../../../website/server/libs/payments/payments';
describe('POST /groups/:groupId/leave', () => { describe('POST /groups/:groupId/leave', () => {
let typesOfGroups = { let typesOfGroups = {

View File

@@ -4,7 +4,7 @@ import {
sleep, sleep,
} from '../../../../helpers/api-integration/v3'; } from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid'; import { v4 as generateUUID } from 'uuid';
import { quests as questScrolls } from '../../../../../website/common/script/content'; import { quests as questScrolls } from '../../../../../website/common/script/content/quests';
import { chatModel as Chat } from '../../../../../website/server/models/message'; import { chatModel as Chat } from '../../../../../website/server/models/message';
import apiError from '../../../../../website/server/libs/apiError'; import apiError from '../../../../../website/server/libs/apiError';

View File

@@ -1,6 +1,6 @@
import Avatar from 'client/components/avatar'; import Avatar from '@/components/avatar';
import Vue from 'vue'; import Vue from 'vue';
import generateStore from 'client/store'; import generateStore from '@/store';
context('avatar.vue', () => { context('avatar.vue', () => {
let Constructr; let Constructr;

View File

@@ -1,7 +1,7 @@
import {mount} from '@vue/test-utils'; import {mount} from '@vue/test-utils';
import Vue from 'vue'; import Vue from 'vue';
import CategoryTags from 'client/components/categories/categoryTags.vue'; import CategoryTags from '@/components/categories/categoryTags.vue';
describe('Category Tags', () => { describe('Category Tags', () => {
let wrapper; let wrapper;

View File

@@ -1,6 +1,6 @@
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import ChallengeDetailComponent from 'client/components/challenges/challengeDetail.vue'; import ChallengeDetailComponent from '@/components/challenges/challengeDetail.vue';
import Store from 'client/libs/store'; import Store from '@/libs/store';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Store); localVue.use(Store);

View File

@@ -1,6 +1,5 @@
import Vue from 'vue'; import Vue from 'vue';
import MembersModalComponent from 'client/components/groups/membersModal.vue'; import MembersModalComponent from '@/components/groups/membersModal.vue';
/* eslint-disable no-skipped-tests */
describe.skip('Members Modal Component', () => { describe.skip('Members Modal Component', () => {
describe('Party Sort', () => { describe('Party Sort', () => {
let CTor; let CTor;
@@ -29,4 +28,3 @@ describe.skip('Members Modal Component', () => {
}); });
}); });
}); });
/* eslint-enable no-skipped-tests */

View File

@@ -1,5 +1,5 @@
import Vue from 'vue'; import Vue from 'vue';
import MemberDetailsComponent from 'client/components/memberDetails.vue'; import MemberDetailsComponent from '@/components/memberDetails.vue';
describe('Members Details Component', () => { describe('Members Details Component', () => {
let CTor; let CTor;

View File

@@ -1,8 +1,8 @@
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import NotificationsComponent from 'client/components/notifications.vue'; import NotificationsComponent from '@/components/notifications.vue';
import Store from 'client/libs/store'; import Store from '@/libs/store';
import { hasClass } from 'client/store/getters/members'; import { hasClass } from '@/store/getters/members';
import { toNextLevel } from 'common/script/statHelpers'; import { toNextLevel } from '@/../../common/script/statHelpers';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Store); localVue.use(Store);

View File

@@ -1,6 +1,6 @@
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import SidebarSection from 'client/components/sidebarSection.vue'; import SidebarSection from '@/components/sidebarSection.vue';
describe('Sidebar Section', () => { describe('Sidebar Section', () => {
let wrapper; let wrapper;

View File

@@ -1,10 +1,6 @@
import { mount, createLocalVue } from '@vue/test-utils'; import { mount, createLocalVue } from '@vue/test-utils';
import TaskColumn from '@/components/tasks/column.vue';
import TaskColumn from 'client/components/tasks/column.vue'; import Store from '@/libs/store';
import Store from 'client/libs/store';
// eslint-disable no-exclusive-tests
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Store); localVue.use(Store);

View File

@@ -1,5 +1,5 @@
import Vue from 'vue'; import Vue from 'vue';
import DrawerComponent from 'client/components/ui/drawer.vue'; import DrawerComponent from '@/components/ui/drawer.vue';
describe('DrawerComponent', () => { describe('DrawerComponent', () => {
it('sets the correct default data', () => { it('sets the correct default data', () => {

View File

@@ -1,13 +0,0 @@
import { expect } from 'chai'
import { shallowMount } from '@vue/test-utils'
import HelloWorld from '@/components/HelloWorld.vue'
describe('HelloWorld.vue', () => {
it('renders props.msg when passed', () => {
const msg = 'new message'
const wrapper = shallowMount(HelloWorld, {
propsData: { msg }
})
expect(wrapper.text()).to.include(msg)
})
})

View File

@@ -1,4 +1,4 @@
import floorFilter from 'client/filters/floor'; import floorFilter from '@/filters/floor';
describe('floor filter', () => { describe('floor filter', () => {
it('can floor a decimal number', () => { it('can floor a decimal number', () => {

View File

@@ -1,4 +1,4 @@
import roundFilter from 'client/filters/round'; import roundFilter from '@/filters/round';
describe('round filter', () => { describe('round filter', () => {
it('can round a decimal number', () => { it('can round a decimal number', () => {

View File

@@ -1,4 +1,4 @@
import roundBigNumberFilter from 'client/filters/roundBigNumber'; import roundBigNumberFilter from '@/filters/roundBigNumber';
describe('round big number filter', () => { describe('round big number filter', () => {
it('can round a decimal number', () => { it('can round a decimal number', () => {

View File

@@ -1,6 +1,6 @@
import { asyncResourceFactory, loadAsyncResource } from 'client/libs/asyncResource'; import { asyncResourceFactory, loadAsyncResource } from '@/libs/asyncResource';
import axios from 'axios'; import axios from 'axios';
import generateStore from 'client/store'; import generateStore from '@/store';
import { sleep } from '../../../../helpers/sleep'; import { sleep } from '../../../../helpers/sleep';
describe('async resource', () => { describe('async resource', () => {

View File

@@ -1,4 +1,4 @@
import deepFreeze from 'client/libs/deepFreeze'; import deepFreeze from '@/libs/deepFreeze';
describe('deepFreeze', () => { describe('deepFreeze', () => {
it('deeply freezes an object', () => { it('deeply freezes an object', () => {

View File

@@ -1,4 +1,4 @@
import {highlightUsers} from '../../../../../website/client/libs/highlightUsers'; import {highlightUsers} from '@/libs/highlightUsers';
import habiticaMarkdown from 'habitica-markdown'; import habiticaMarkdown from 'habitica-markdown';
describe('highlightUserAndEmail', () => { describe('highlightUserAndEmail', () => {

View File

@@ -1,5 +1,5 @@
import i18n from 'client/libs/i18n'; import i18n from '@/libs/i18n';
import commoni18n from 'common/script/i18n'; import commoni18n from '@/../../common/script/i18n';
import Vue from 'vue'; import Vue from 'vue';
describe('i18n plugin', () => { describe('i18n plugin', () => {

View File

@@ -1,6 +1,6 @@
import Vue from 'vue'; import Vue from 'vue';
import StoreModule, { mapState, mapGetters, mapActions } from 'client/libs/store'; import StoreModule, { mapState, mapGetters, mapActions } from '@/libs/store';
import { flattenAndNamespace } from 'client/libs/store/helpers/internals'; import { flattenAndNamespace } from '@/libs/store/helpers/internals';
describe('Store', () => { describe('Store', () => {
let store; let store;

View File

@@ -2,7 +2,7 @@ import {
getTypeLabel, getTypeLabel,
getFilterLabels, getFilterLabels,
getActiveFilter, getActiveFilter,
} from 'client/libs/store/helpers/filterTasks.js'; } from '@/libs/store/helpers/filterTasks.js';
describe('Filter Category for Tasks', () => { describe('Filter Category for Tasks', () => {
describe('getTypeLabel', () => { describe('getTypeLabel', () => {

View File

@@ -1,7 +1,7 @@
import { import {
orderSingleTypeTasks, orderSingleTypeTasks,
// orderMultipleTypeTasks, // orderMultipleTypeTasks,
} from 'client/libs/store/helpers/orderTasks.js'; } from '@/libs/store/helpers/orderTasks.js';
import shuffle from 'lodash/shuffle'; import shuffle from 'lodash/shuffle';

View File

@@ -1,6 +1,6 @@
import groupsUtilities from 'client/mixins/groupsUtilities'; import groupsUtilities from '@/mixins/groupsUtilities';
import { TAVERN_ID } from 'common/script/constants'; import { TAVERN_ID } from '@/../../common/script/constants';
import generateStore from 'client/store'; import generateStore from '@/store';
import Vue from 'vue'; import Vue from 'vue';
describe('Groups Utilities Mixin', () => { describe('Groups Utilities Mixin', () => {

View File

@@ -1,10 +1,10 @@
import axios from 'axios'; import axios from 'axios';
import generateStore from 'client/store'; import generateStore from '@/store';
import content from 'common/script/content'; import content from '@/../../common/script/content';
import getItemInfo from 'common/script/libs/getItemInfo'; import getItemInfo from '@/../../common/script/libs/getItemInfo';
import getOfficialPinnedItems from 'common/script/libs/getOfficialPinnedItems'; import getOfficialPinnedItems from '@/../../common/script/libs/getOfficialPinnedItems';
describe('shops actions', () => { describe('shops actions', () => {
let store; let store;

View File

@@ -1,5 +1,5 @@
import axios from 'axios'; import axios from 'axios';
import generateStore from 'client/store'; import generateStore from '@/store';
describe('tasks actions', () => { describe('tasks actions', () => {
let store; let store;

View File

@@ -1,5 +1,5 @@
import axios from 'axios'; import axios from 'axios';
import generateStore from 'client/store'; import generateStore from '@/store';
describe('user actions', () => { describe('user actions', () => {
let store; let store;

View File

@@ -1,4 +1,4 @@
import { hasClass } from 'client/store/getters/members'; import { hasClass } from '@/store/getters/members';
describe('hasClass getter', () => { describe('hasClass getter', () => {
it('returns false if level < 10', () => { it('returns false if level < 10', () => {

View File

@@ -1,4 +1,4 @@
import generateStore from 'client/store'; import generateStore from '@/store';
describe('canDelete getter', () => { describe('canDelete getter', () => {
it('cannot delete active challenge task', () => { it('cannot delete active challenge task', () => {

View File

@@ -1,4 +1,4 @@
import generateStore from 'client/store'; import generateStore from '@/store';
describe('getTagsFor getter', () => { describe('getTagsFor getter', () => {
it('returns the tags for a task', () => { it('returns the tags for a task', () => {

View File

@@ -1,4 +1,4 @@
import generateStore from 'client/store'; import generateStore from '@/store';
describe('getTaskClasses getter', () => { describe('getTaskClasses getter', () => {
let store, getTaskClasses; let store, getTaskClasses;

View File

@@ -1,4 +1,4 @@
import generateStore from 'client/store'; import generateStore from '@/store';
describe('Store Getters for Tasks', () => { describe('Store Getters for Tasks', () => {
let store, habits, dailys, todos, rewards; let store, habits, dailys, todos, rewards;

View File

@@ -1,4 +1,4 @@
import { data, gems, buffs, preferences, tasksOrder } from 'client/store/getters/user'; import { data, gems, buffs, preferences, tasksOrder } from '@/store/getters/user';
context('user getters', () => { context('user getters', () => {
describe('data', () => { describe('data', () => {

View File

@@ -1,5 +1,5 @@
import generateStore from 'client/store'; import generateStore from '@/store';
import Store from 'client/libs/store'; import Store from '@/libs/store';
describe('Application store', () => { describe('Application store', () => {
it('is an instance of Store', () => { it('is an instance of Store', () => {

View File

@@ -1,21 +0,0 @@
{
"env": {
"test": {
"presets": [
["es2015"],
],
plugins: [
["istanbul"],
],
},
},
"presets": [
["es2015", { modules: false }]
],
"plugins": [
"transform-object-rest-spread",
"syntax-async-functions",
"syntax-dynamic-import",
"transform-regenerator",
],
}

View File

@@ -1,13 +0,0 @@
{
"extends": [
"habitrpg/browser",
"habitrpg/esnext"
],
"plugins": [
"html"
],
"parser": "babel-eslint",
"rules": {
"strict": 0
}
}

View File

@@ -1,21 +0,0 @@
# Running
For information about installing and running Habitica locally, see [Setting up Habitica Locally](http://habitica.fandom.com/wiki/Setting_up_Habitica_Locally).
# Preparation Reading
- Vue 2 (https://vuejs.org)
- Webpack (https://webpack.github.io/) is the build system and it includes plugins for code transformation, right now we have: BabelJS for ES6 transpilation, eslint for code style, less and postcss for css compilation. The code comes from https://github.com/vuejs-templates/webpack which is a Webpack template for Vue, with some small modifications to adapt it to our use case. Docs http://vuejs-templates.github.io/webpack/
- We're using `.vue` files that make it possible to have HTML, JS and CSS for each component together in a single location. They're implemented as a webpack plugin and the docs can be found here http://vue-loader.vuejs.org/en/
- SemanticUI is the UI framework http://semantic-ui.com/. So far I've only used the CSS part, it also has JS plugins but I've yet to use them. It supports theming so if it's not too difficult we'll want to customize the base theme with our own styles instead of writing CSS rules to override the original styling.
The code is in `/website/client`. We're using something very similar to Vuex (equivalent of React's Redux) for state management http://vuex.vuejs.org/en/index.html
The API is almost the same except that we don't use mutations but only actions because it would make it difficult to work with common code
The project is developed directly in the `develop` branch as long as we'll be able to avoid splitting it into a different branch.
So far most of the work has been on the template, so there's no complex logic to understand. The only thing I would suggest you to read about is Vuex for data management: it's basically a Flux implementation: there's a central store that hold the data for the entire app, and every change to the data must happen through an action, the data cannot be mutated directly.
For further resources, see [Guidance for Blacksmiths](http://habitica.fandom.com/wiki/Guidance_for_Blacksmiths), and in particular the ["Website Technology Stack" section](http://habitica.fandom.com/wiki/Guidance_for_Blacksmiths#Website_Technology_Stack).