Fix test and handle errors better
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
3e4bd76f29
commit
14369e61e9
@ -7,7 +7,7 @@ export const defaultError: IError = {
|
||||
value: i18n.t('An error has occurred.') as string,
|
||||
};
|
||||
|
||||
export interface IError { match: RegExp; value: string; suggestRefresh?: boolean; }
|
||||
export interface IError { match: RegExp; value: string|null; suggestRefresh?: boolean; }
|
||||
|
||||
export const errors: IError[] = [
|
||||
{
|
||||
@ -48,4 +48,28 @@ export const errors: IError[] = [
|
||||
value: i18n.t("The current identity doesn't have any permission on this event. You should probably change it.") as string,
|
||||
suggestRefresh: false,
|
||||
},
|
||||
{
|
||||
match: /^User with email not found$/,
|
||||
value: null,
|
||||
},
|
||||
{
|
||||
match: /^Username is already taken$/,
|
||||
value: null,
|
||||
},
|
||||
{
|
||||
match: /^No user with this email was found$/,
|
||||
value: null,
|
||||
},
|
||||
{
|
||||
match: /^Impossible to authenticate, either your email or password are invalid.$/,
|
||||
value: null,
|
||||
},
|
||||
{
|
||||
match: /^No user to validate with this email was found$/,
|
||||
value: null,
|
||||
},
|
||||
{
|
||||
match: /^This email is already used.$/,
|
||||
value: null,
|
||||
},
|
||||
];
|
||||
|
@ -152,7 +152,6 @@ export default class Register extends Vue {
|
||||
acc[error.details] = error.message;
|
||||
return acc;
|
||||
}, {});
|
||||
console.log(this.errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
<b-input aria-required="true" required type="email" v-model="credentials.email"/>
|
||||
</b-field>
|
||||
<p class="control has-text-centered">
|
||||
<b-button type="is-primary">
|
||||
<b-button type="is-primary" native-type="submit">
|
||||
{{ $t('Send me the confirmation email once again') }}
|
||||
</b-button>
|
||||
</p>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<b-input aria-required="true" required type="email" v-model="credentials.email"/>
|
||||
</b-field>
|
||||
<p class="control has-text-centered">
|
||||
<b-button type="is-primary">
|
||||
<b-button type="is-primary" native-type="submit">
|
||||
{{ $t('Send me an email to reset my password') }}
|
||||
</b-button>
|
||||
</p>
|
||||
|
@ -92,7 +92,11 @@ const errorLink = onError(({ graphQLErrors, networkError, forward, operation })
|
||||
const messages: Set<string> = new Set();
|
||||
|
||||
graphQLErrors.forEach(({ message, locations, path }) => {
|
||||
messages.add(computeErrorMessage(message));
|
||||
const computedMessage = computeErrorMessage(message);
|
||||
if (computedMessage) {
|
||||
console.log('computed message', computedMessage);
|
||||
messages.add(computedMessage);
|
||||
}
|
||||
console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);
|
||||
});
|
||||
|
||||
@ -103,7 +107,10 @@ const errorLink = onError(({ graphQLErrors, networkError, forward, operation })
|
||||
|
||||
if (networkError) {
|
||||
console.log(`[Network error]: ${networkError}`);
|
||||
Snackbar.open({ message: computeErrorMessage(networkError), type: 'is-danger', position: 'is-bottom' });
|
||||
const computedMessage = computeErrorMessage(networkError);
|
||||
if (computedMessage) {
|
||||
Snackbar.open({ message: computedMessage, type: 'is-danger', position: 'is-bottom' });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -115,6 +122,7 @@ const computeErrorMessage = (message) => {
|
||||
return acc;
|
||||
}, defaultError);
|
||||
|
||||
if (error.value === null) return null;
|
||||
return error.suggestRefresh === false ? error.value : `${error.value}<br>${refreshSuggestion}`;
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,7 @@ describe('Events', () => {
|
||||
|
||||
cy.contains('.navbar-item', 'My events').click();
|
||||
cy.contains('.title', EVENT.title);
|
||||
cy.contains('.content.column', 'You\'re organizing this event');
|
||||
cy.contains('.content.column', 'Organized by I\'m a test user');
|
||||
cy.contains('.title-wrapper .date-component .datetime-container .month', 'Sep');
|
||||
cy.contains('.title-wrapper .date-component .datetime-container .day', '15');
|
||||
});
|
||||
|
@ -44,9 +44,9 @@ describe('Login', () => {
|
||||
cy.get('input[type=email]').type('user@email.com');
|
||||
cy.get('input[type=password]').type('some password');
|
||||
cy.get('form').submit();
|
||||
cy.contains('.navbar-link', 'test_user');
|
||||
cy.get('.navbar-link span.icon i').should('have.class', 'mdi-account-circle');
|
||||
cy.contains('article.message.is-info', 'Welcome back I\'m a test user');
|
||||
cy.contains('.navbar-item.has-dropdown', 'test_user').click();
|
||||
cy.get('.navbar-item.has-dropdown').click();
|
||||
cy.get('.navbar-item').last().contains('Log out').click();
|
||||
});
|
||||
|
||||
@ -77,7 +77,7 @@ describe('Login', () => {
|
||||
cy.get('form').submit();
|
||||
cy.wait(1000);
|
||||
|
||||
cy.contains('.navbar-link', 'test_user_2');
|
||||
cy.get('.navbar-link span.icon i').should('have.class', 'mdi-account-circle');
|
||||
cy.contains('article.message.is-info', 'Welcome back DuplicateNot');
|
||||
});
|
||||
});
|
||||
|
@ -65,7 +65,7 @@ describe('Registration', () => {
|
||||
expect(loc.pathname).to.eq('/');
|
||||
});
|
||||
|
||||
cy.contains('.navbar-link', 'tester');
|
||||
cy.get('.navbar-link span.icon i').should('have.class', 'mdi-account-circle');
|
||||
cy.contains('article.message.is-info', 'Welcome back tester account');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user