Add email verification tests
This commit is contained in:
parent
6509b31ab5
commit
f5ddff12e3
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,119 @@
|
|||
const schema = require('../fixtures/schema_public.json');
|
||||
|
||||
describe('Email Verifcation', () => {
|
||||
beforeEach(() => {
|
||||
cy.server();
|
||||
});
|
||||
|
||||
it('forwards to homepage if confirmation key is correct', () => {
|
||||
cy.viewport('macbook-15');
|
||||
cy.mockGraphql({
|
||||
schema: schema,
|
||||
// endpoint: '/api/graphql'
|
||||
operations: {
|
||||
Registration: variables => {
|
||||
return {
|
||||
registration: {
|
||||
errors: [],
|
||||
message: "success",
|
||||
success: true
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
cy.visit('/verify-email?confirmation=abcd1234');
|
||||
|
||||
// user should be logged in at that stage. As the cookie cannot be set at the right time
|
||||
// we just check if the user gets redirected to the login page as we can't log her in
|
||||
cy.url().should('include', 'login?redirect=%2F');
|
||||
|
||||
});
|
||||
|
||||
it('displays error if key is incorrect', () => {
|
||||
cy.viewport('macbook-15');
|
||||
cy.mockGraphql({
|
||||
schema: schema,
|
||||
// endpoint: '/api/graphql'
|
||||
operations: {
|
||||
Registration: variables => {
|
||||
return {
|
||||
registration: {
|
||||
errors: [
|
||||
{
|
||||
field: "invalid_key"
|
||||
}
|
||||
],
|
||||
message: "",
|
||||
success: false
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
cy.visit('/verify-email?confirmation=abcd1234');
|
||||
cy.get('[data-cy="code-nok-msg"]').contains('Der angegebene Verifizierungscode ist falsch oder abgelaufen.');
|
||||
cy.get('[data-cy="code-ok-msg"]').should('not.exist');
|
||||
|
||||
});
|
||||
|
||||
it('displays error if an error occured', () => {
|
||||
cy.viewport('macbook-15');
|
||||
cy.mockGraphql({
|
||||
schema: schema,
|
||||
// endpoint: '/api/graphql'
|
||||
operations: {
|
||||
Registration: variables => {
|
||||
return {
|
||||
registration: {
|
||||
errors: [
|
||||
{
|
||||
field: "unkown_error"
|
||||
}
|
||||
],
|
||||
message: "",
|
||||
success: false
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
cy.visit('/verify-email?confirmation=abcd1234');
|
||||
cy.get('[data-cy="code-nok-msg"]').contains('Ein Fehler ist aufgetreten. Bitte kontaktieren Sie den Administrator.');
|
||||
|
||||
});
|
||||
|
||||
it('forwards to coupon page if user has no valid license', () => {
|
||||
cy.viewport('macbook-15');
|
||||
cy.mockGraphql({
|
||||
schema: schema,
|
||||
// endpoint: '/api/graphql'
|
||||
operations: {
|
||||
Registration: variables => {
|
||||
return {
|
||||
registration: {
|
||||
errors: [
|
||||
{
|
||||
field: "no_valid_license"
|
||||
}
|
||||
],
|
||||
message: "",
|
||||
success: false
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
cy.visit('/verify-email?confirmation=abcd1234');
|
||||
|
||||
// user should be logged in at that stage. As the cookie cannot be set at the right time
|
||||
// we just check if the user gets redirected to the coupon page as we can't log her in
|
||||
cy.url().should('include', 'login?redirect=%2Flicense-activation');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
const schema = require('../fixtures/schema.json');
|
||||
|
||||
const isEmailAvailableUrl = 'https://stage.hep-verlag.ch/rest/deutsch/V1/customers/isEmailAvailable';
|
||||
const checkPasswordUrl = 'https://stage.hep-verlag.ch/rest/deutsch/V1/customers';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
const schema = require('../fixtures/schema.json');
|
||||
|
||||
const isEmailAvailableUrl = 'https://stage.hep-verlag.ch/rest/deutsch/V1/customers/isEmailAvailable';
|
||||
const registerUrl = 'https://stage.hep-verlag.ch/rest/deutsch/V1/customers';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
<template>
|
||||
<div class="emailconfirmation public-page">
|
||||
<h1 class="emailconfirmation__title public-page__title">Überprüfung</h1>
|
||||
<h1 class="emailconfirmation__title public-page__title">Überprüfung der E-Mail Adresse</h1>
|
||||
<p v-if="loading">Der Verifikationscode wird überprüft.</p>
|
||||
<p v-if="showOkMessage" data-cy="code-ok-msg">Der Verifikationscode ist gültig. Sie werden weitergeleitet.</p>
|
||||
<p v-if="showErrorMessage" data-cy="code-nok-msg">{{errorMessage}}</p>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -17,12 +21,21 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
keyValid: false
|
||||
keyValid: false,
|
||||
errorMessage: ''
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
showOkMessage() {
|
||||
return !this.loading && this.keyValid;
|
||||
},
|
||||
showErrorMessage() {
|
||||
return !this.loading && !this.keyValid;
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
console.log('register')
|
||||
this.$apollo.mutate({
|
||||
mutation: REGISTRATION_MUTATION,
|
||||
variables: {
|
||||
|
|
@ -31,7 +44,25 @@ export default {
|
|||
}
|
||||
},
|
||||
fetchPolicy: 'no-cache'
|
||||
}).then(result => console.log(result))
|
||||
}).then(({data: {registration}}) => {
|
||||
|
||||
this.loading = false;
|
||||
|
||||
if (registration.success) {
|
||||
this.keyValid = true;
|
||||
this.$router.push('/');
|
||||
} else {
|
||||
switch (registration.errors[0].field) {
|
||||
case 'invalid_key':
|
||||
this.errorMessage = 'Der angegebene Verifizierungscode ist falsch oder abgelaufen.';
|
||||
break;
|
||||
case 'no_valid_license':
|
||||
this.$router.push({name: 'licenseActivation'})
|
||||
default:
|
||||
this.errorMessage = 'Ein Fehler ist aufgetreten. Bitte kontaktieren Sie den Administrator.';
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,4 +12,16 @@ class Mutation(UserMutations, RegistrationMutations, graphene.ObjectType):
|
|||
debug = graphene.Field(DjangoDebug, name='__debug')
|
||||
|
||||
|
||||
schema = graphene.Schema(mutation=Mutation)
|
||||
# graphene neets some kind of schema in order to create a schema
|
||||
class DummyQuery(object):
|
||||
meaning_of_life = graphene.Int()
|
||||
|
||||
def resolve_meaning_of_life(self, info, **kwargs):
|
||||
return 42
|
||||
|
||||
|
||||
class Query(DummyQuery, graphene.ObjectType):
|
||||
pass
|
||||
|
||||
|
||||
schema = graphene.Schema(mutation=Mutation, query=Query)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ def handle_user_and_verify_products(user_data):
|
|||
user = User.objects.create_user_from_hep(user_data)
|
||||
|
||||
# todo check if email has changed, any impact on our system?
|
||||
# todo handle local logins that are not local anymore
|
||||
|
||||
try:
|
||||
if not hep_client.is_email_verified(user_data):
|
||||
|
|
|
|||
Loading…
Reference in New Issue