Skip to content

Commit

Permalink
Solves #12: add e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe HENRY committed Nov 23, 2018
1 parent d077d97 commit 2c82cbf
Show file tree
Hide file tree
Showing 16 changed files with 324 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Expand Up @@ -7,8 +7,8 @@ module.exports = {
rules: {
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
"max-len": ["error", {"code": 120}],
"prettier/prettier": ["warn", {printWidth: 120}]
"max-len": ["error", { code: 120 }],
"prettier/prettier": [process.env.NODE_ENV === "production" ? "off" : "error", { printWidth: 120 }]
},
parserOptions: {
parser: "babel-eslint"
Expand Down
15 changes: 14 additions & 1 deletion .gitlab-ci.yml
Expand Up @@ -4,7 +4,7 @@ stages:
- test
- deploy_dev

test:
test_unit:
stage: test
except:
- triggers
Expand All @@ -15,6 +15,19 @@ test:
- npm install
- npm run test:unit

test_e2e:
stage: test
except:
- triggers
tags:
- docker
environment:
name: production
image: cypress/base:10
script:
- npm install
- npm run test:e2e -- --headless

deploy_dev:
stage: deploy_dev
except:
Expand Down
7 changes: 2 additions & 5 deletions jest.config.js
Expand Up @@ -2,16 +2,13 @@ module.exports = {
moduleFileExtensions: ["js", "jsx", "json", "vue"],
transform: {
"^.+\\.vue$": "vue-jest",
".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$":
"jest-transform-stub",
".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$": "jest-transform-stub",
"^.+\\.jsx?$": "babel-jest"
},
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1"
},
snapshotSerializers: ["jest-serializer-vue"],
testMatch: [
"**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"
],
testMatch: ["**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"],
testURL: "http://localhost/"
};
1 change: 1 addition & 0 deletions public/.eslintignore
@@ -0,0 +1 @@
*js
1 change: 0 additions & 1 deletion src/App.vue
Expand Up @@ -27,7 +27,6 @@
import UserMenu from "@/components/UserMenu.vue";
import Snackbar from "@/components/Snackbar.vue";
export default {
components: {
"op-user-menu": UserMenu,
Expand Down
9 changes: 4 additions & 5 deletions src/components/Snackbar.vue
Expand Up @@ -6,16 +6,15 @@
</template>

<script>
import { mapState } from 'vuex';
import { mapState } from "vuex";
export default {
name: 'Snackbar',
name: "Snackbar",
computed: {
...mapState('ui', ['snackbar'])
...mapState("ui", ["snackbar"])
}
}
};
</script>

<style>
</style>
24 changes: 12 additions & 12 deletions src/components/UserMenu.vue
@@ -1,44 +1,44 @@
<template>
<v-menu bottom left offset-y>
<v-menu class="user-menu" bottom left offset-y>
<v-avatar size="32px" slot="activator">
<img v-if="getAvatarUrl" :src="getAvatarUrl">
<v-icon v-else>account_circle</v-icon>
</v-avatar>
<v-list>
<v-list class="user-menu-items">
<v-list-tile>
<v-list-tile-content>
<v-list-tile-title class="title">{{getDisplayName}}</v-list-tile-title>
<v-list-tile-sub-title>{{getEmail}}</v-list-tile-sub-title>
<v-list-tile-sub-title class="sub-title">{{getEmail}}</v-list-tile-sub-title>
</v-list-tile-content>
</v-list-tile>
<v-divider/>
<v-list-tile @click.prevent="logout">
<v-list-tile class="logout" @click.prevent="logout">
<v-list-tile-title>Log out</v-list-tile-title>
</v-list-tile>
</v-list>
</v-menu>
</template>

<script>
import { mapGetters } from 'vuex';
import { mapGetters } from "vuex";
export default {
name: 'op-user-menu',
name: "op-user-menu",
methods: {
logout() {
this.$store.dispatch('session/logout').then(() => {
this.$router.push({name: 'Login'});
this.$store.dispatch("session/logout").then(() => {
this.$router.push({ name: "Login" });
});
}
},
computed: {
...mapGetters({
getAvatarUrl: 'user/getAvatarUrl',
getDisplayName: 'user/getDisplayName',
getEmail: 'user/getEmail'
getAvatarUrl: "user/getAvatarUrl",
getDisplayName: "user/getDisplayName",
getEmail: "user/getEmail"
})
}
}
};
</script>

<style lang="stylus" scoped>
Expand Down
4 changes: 3 additions & 1 deletion src/main.js
Expand Up @@ -19,8 +19,10 @@ Vue.use(Vuetify, { theme });

Vue.config.productionTip = false;

new Vue({
const Application = new Vue({
router,
store,
render: h => h(App)
}).$mount("#app");

window.Application = Application;
2 changes: 1 addition & 1 deletion src/store/modules/user.js
Expand Up @@ -52,7 +52,7 @@ const getters = {

configurations: state => configurationKey => {
return state.user && configurationRecursiveSearch(state.user.configurations.modules, configurationKey);
},
}
};

export default {
Expand Down
27 changes: 23 additions & 4 deletions src/views/Login.vue
Expand Up @@ -8,9 +8,26 @@
<v-toolbar-title class="white--text">OpenPaaS Login</v-toolbar-title>
</v-toolbar>
<v-card-text>
<v-form @keydown.native.enter="login">
<v-text-field prepend-icon="person" name="login" label="Login" type="text" v-model="email" autofocus></v-text-field>
<v-text-field prepend-icon="lock" name="password" label="Password" id="password" type="password" v-model="password" required></v-text-field>
<v-form class="login-form" @keydown.native.enter="login">
<v-text-field
class="login-user-input"
prepend-icon="person"
name="login"
label="Login"
type="text"
v-model="email"
autofocus
></v-text-field>
<v-text-field
class="login-password-input"
prepend-icon="lock"
name="password"
label="Password"
id="password"
type="password"
v-model="password"
required
></v-text-field>
</v-form>
</v-card-text>
<v-card-actions>
Expand Down Expand Up @@ -39,7 +56,9 @@ export default {
methods: {
login() {
const redirectHistory = this.$auth.redirect();
const redirect = redirectHistory ? { name: redirectHistory.from.name, params: redirectHistory.from.params } : { name: 'Home' };
const redirect = redirectHistory
? { name: redirectHistory.from.name, params: redirectHistory.from.params }
: { name: "Home" };
this.logMeIn = true;
this.$auth
Expand Down
2 changes: 1 addition & 1 deletion src/views/VideoConference.vue
Expand Up @@ -24,7 +24,7 @@ export default {
videoConference: null,
loaded: false,
roomName: "",
displayReopenRoomButton: false,
displayReopenRoomButton: false
};
},
props: { conferenceid: String },
Expand Down
157 changes: 157 additions & 0 deletions tests/e2e/fixtures/adminUser.json
@@ -0,0 +1,157 @@
{
"_id": "5bebeeae1931ee6d1cc1f32a",
"firstname": "admin",
"lastname": "admin",
"preferredEmail": "admin@open-paas.org",
"emails": [
"admin@open-paas.org"
],
"domains": [
{
"domain_id": "5bebeeae1931ee6d1cc1f32b",
"joined_at": "2018-11-14T09:45:18.499Z"
}
],
"states": [],
"avatars": [],
"accounts": [
{
"type": "email",
"timestamps": {
"creation": "2018-11-14T09:45:18.421Z"
},
"preferredEmailIndex": 0,
"emails": [
"admin@open-paas.org"
],
"hosted": false
}
],
"login": {
"failures": [],
"success": "2018-11-21T08:41:00.713Z"
},
"id": "5bebeeae1931ee6d1cc1f32a",
"followers": 0,
"followings": 0,
"isPlatformAdmin": true,
"configurations": {
"modules": [
{
"name": "linagora.esn.james",
"configurations": [
{
"name": "webadminApiFrontend",
"value": "http://localhost:8000"
}
]
},
{
"name": "core",
"configurations": [
{
"name": "davserver",
"value": {
"backend": {
"url": "http://localhost:8001"
}
}
},
{
"name": "features",
"value": {
"header:user-notification": true,
"control-center:password": true,
"control-center:appstore": false,
"application-menu:invitation": false,
"application-menu:jobqueue": false
}
},
{
"name": "homePage",
"value": "unifiedinbox"
},
{
"name": "datetime",
"value": {
"timeZone": "Europe/Berlin"
}
},
{
"name": "language",
"value": "en"
}
]
},
{
"name": "linagora.esn.videoconference",
"configurations": []
},
{
"name": "linagora.esn.unifiedinbox",
"configurations": [
{
"name": "api",
"value": "http://localhost:1080/jmap"
},
{
"name": "uploadUrl",
"value": "http://localhost:1080/upload"
},
{
"name": "downloadUrl",
"value": "http://localhost:1080/download/{blobId}/{name}"
},
{
"name": "isJmapSendingEnabled",
"value": true
},
{
"name": "isSaveDraftBeforeSendingEnabled",
"value": false
},
{
"name": "composer.attachments",
"value": true
},
{
"name": "maxSizeUpload",
"value": 20971520
},
{
"name": "numberItemsPerPageOnBulkReadOperations",
"value": 30
},
{
"name": "numberItemsPerPageOnBulkDeleteOperations",
"value": 30
},
{
"name": "numberItemsPerPageOnBulkUpdateOperations",
"value": 30
},
{
"name": "drafts",
"value": true
},
{
"name": "view",
"value": "messages"
},
{
"name": "swipeRightAction",
"value": "markAsRead"
},
{
"name": "forwarding",
"value": true
},
{
"name": "isLocalCopyEnabled",
"value": true
}
]
}
]
}
}
1 change: 1 addition & 0 deletions tests/e2e/fixtures/adminUserJwt.json
@@ -0,0 +1 @@
{}

0 comments on commit 2c82cbf

Please sign in to comment.