Add e2e seed and test event creation

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-10-12 13:16:36 +02:00
parent 6afde20b96
commit 5e75daa732
16 changed files with 237 additions and 30 deletions

View File

@@ -20,7 +20,7 @@
<template>
<span v-if="!endsOn">{{ beginsOn | formatDateTimeString }}</span>
<span v-else-if="isSameDay()">
{{ $t('The {date} from {startTime} to {endTime}', {date: formatDate(beginsOn), startTime: formatTime(beginsOn), endTime: formatTime(endsOn)}) }}
{{ $t('On {date} from {startTime} to {endTime}', {date: formatDate(beginsOn), startTime: formatTime(beginsOn), endTime: formatTime(endsOn)}) }}
</span>
<span v-else-if="endsOn">
{{ $t('From the {startDate} at {startTime} to the {endDate} at {endTime}',

View File

@@ -137,8 +137,8 @@ export default class NavBar extends Vue {
}
}
async handleErrors(errors: GraphQLError) {
if (errors[0].message === 'You need to be logged-in to view your list of identities') {
async handleErrors(errors: GraphQLError[]) {
if (errors.length > 0 && errors[0].message === 'You need to be logged-in to view your list of identities') {
await this.logout();
}
}

View File

@@ -143,6 +143,7 @@
"No results for \"{queryText}\"": "No results for \"{queryText}\"",
"Number of places": "Number of places",
"Old password": "Old password",
"On {date} from {startTime} to {endTime}": "On {date} from {startTime} to {endTime}",
"One person is going": "No one is going | One person is going | {approved} persons are going",
"Only accessible through link and search (private)": "Only accessible through link and search (private)",
"Opened reports": "Opened reports",
@@ -216,13 +217,13 @@
"The page you're looking for doesn't exist.": "The page you're looking for doesn't exist.",
"The password was successfully changed": "The password was successfully changed",
"The report will be sent to the moderators of your instance. You can explain why you report this content below.": "The report will be sent to the moderators of your instance. You can explain why you report this content below.",
"The {date} from {startTime} to {endTime}": "The {date} from {startTime} to {endTime}",
"These events may interest you": "These events may interest you",
"This installation (called “instance“) can easily {interconnect}, thanks to {protocol}.": "This installation (called “instance“) can easily {interconnect}, thanks to {protocol}.",
"This instance isn't opened to registrations, but you can register on other instances.": "This instance isn't opened to registrations, but you can register on other instances.",
"This is a demonstration site to test the beta version of Mobilizon.": "This is a demonstration site to test the beta version of Mobilizon.",
"This will delete / anonymize all content (events, comments, messages, participations…) created from this identity.": "This will delete / anonymize all content (events, comments, messages, participations…) created from this identity.",
"Title": "Title",
"To achieve your registration, please create a first identity profile.": "To achieve your registration, please create a first identity profile.",
"To change the world, change the software": "To change the world, change the software",
"To confirm, type your identity username \"{preferredUsername}\"": "To confirm, type your identity username \"{preferredUsername}\"",
"Transfer to {outsideDomain}": "Transfer to {outsideDomain}",

View File

@@ -168,6 +168,7 @@
"No results for \"{queryText}\"": "Pas de résultats pour « {queryText} »",
"Number of places": "Nombre de places",
"Old password": "Ancien mot de passe",
"On {date} from {startTime} to {endTime}": "On {date} de {startTime} à {endTime}",
"One person is going": "Personne n'y va | Une personne y va | {approved} personnes y vont",
"Only accessible through link and search (private)": "Uniquement accessibles par lien et la recherche (privé)",
"Opened reports": "Signalements ouverts",
@@ -248,7 +249,6 @@
"The password was successfully changed": "Le mot de passe a été changé avec succès",
"The report will be sent to the moderators of your instance. You can explain why you report this content below.": "Le signalement sera envoyé aux modérateur⋅ices de votre instance. Vous pouvez expliquer pourquoi vous signalez ce contenu ci-dessous.",
"The {date} at {time}": "Le {date} à {time}",
"The {date} from {startTime} to {endTime}": "Le {date} de {startTime} à {endTime}",
"There are {participants} participants.": "Il n'y a qu'un⋅e participant⋅e. | Il y a {participants} participants.",
"These events may interest you": "Ces événements peuvent vous intéresser",
"This installation (called “instance“) can easily {interconnect}, thanks to {protocol}.": "Cette installation (appelée “instance“) peut facilement {interconnect}, grâce à {protocol}.",
@@ -256,6 +256,7 @@
"This is a demonstration site to test the beta version of Mobilizon.": "Ceci est un site de démonstration permettant de tester la version bêta de Mobilizon.",
"This will delete / anonymize all content (events, comments, messages, participations…) created from this identity.": "Cela supprimera / anonymisera tout le contenu (événements, commentaires, messages, participations…) créés avec cette identité.",
"Title": "Titre",
"To achieve your registration, please create a first identity profile.": "Pour finir votre inscription, veuillez créer un premier profil.",
"To change the world, change the software": "Changer de logiciel pour changer le monde",
"To confirm, type your event title \"{eventTitle}\"": "Pour confirmer, entrez le titre de l'événement « {eventTitle} »",
"To confirm, type your identity username \"{preferredUsername}\"": "Pour confirmer, entrez le nom de lidentité « {preferredUsername} »",

View File

@@ -37,6 +37,8 @@ export function deleteUserData() {
}
}
export class NoIdentitiesException extends Error {}
/**
* We fetch from localStorage the latest actor ID used,
* then fetch the current identities to set in cache
@@ -50,7 +52,10 @@ export async function initializeCurrentActor(apollo: ApolloClient<any>) {
fetchPolicy: 'network-only',
});
const identities = result.data.identities;
if (identities.length < 1) return;
if (identities.length < 1) {
console.warn('Logged user has no identities!');
throw new NoIdentitiesException;
}
const activeIdentity = identities.find(identity => identity.id === actorId) || identities[0] as IPerson;
if (activeIdentity) {

View File

@@ -5,7 +5,10 @@
<h1 class="title">
{{ $t('Register an account on Mobilizon!') }}
</h1>
<form v-if="!validationSent">
<b-message v-if="userAlreadyActivated">
{{ $t('To achieve your registration, please create a first identity profile.')}}
</b-message>
<form v-if="!validationSent" @submit.prevent="submit">
<b-field
:label="$t('Username')"
:type="errors.preferred_username ? 'is-danger' : null"
@@ -33,7 +36,7 @@
</b-field>
<p class="control has-text-centered">
<b-button type="is-primary" size="is-large" @click="submit()">
<b-button type="is-primary" size="is-large" native-type="submit">
{{ $t('Create my profile') }}
</b-button>
</p>
@@ -117,8 +120,8 @@ export default class Register extends Vue {
acc[error.details] = error.message;
return acc;
}, {});
console.error(error);
console.error(this.errors);
console.error('Error while registering person', error);
console.error('Errors while registering person', this.errors);
}
}
}

View File

@@ -62,7 +62,7 @@
import { Component, Prop, Vue } from 'vue-property-decorator';
import { LOGIN } from '@/graphql/auth';
import { validateEmailField, validateRequiredField } from '@/utils/validators';
import { initializeCurrentActor, saveUserData } from '@/utils/auth';
import { initializeCurrentActor, NoIdentitiesException, saveUserData } from '@/utils/auth';
import { ILogin } from '@/types/login.model';
import { CURRENT_USER_CLIENT, UPDATE_CURRENT_USER_CLIENT } from '@/graphql/user';
import { onLogin } from '@/vue-apollo';
@@ -153,7 +153,16 @@ export default class Login extends Vue {
role: data.login.user.role,
},
});
await initializeCurrentActor(this.$apollo.provider.defaultClient);
try {
await initializeCurrentActor(this.$apollo.provider.defaultClient);
} catch (e) {
if (e instanceof NoIdentitiesException) {
return await this.$router.push({
name: RouteName.REGISTER_PROFILE,
params: { email: this.currentUser.email, userAlreadyActivated: 'true' },
});
}
}
onLogin(this.$apollo);