n8n/packages/editor-ui/src/views/SigninView.vue
Alex Grozav 77644860c0
feat: Add cypress e2e tests for signup and signin (#3490)
* feat: Added cypress setup files.

* feat: Added server bootup and initial test run.

* feat: Added e2e tests for signin, signup, and personalization form.

* feat: Added e2e tests for adding a function node.

* feat: Added set node and workflow execution steps.

* feat: Added test id to main sidebar.

* feat: Added test for creating a new workflow.

* feat: Finished test for creating a blank workflow

* chore: Removed screenshots from e2e tests.

* refactor: change e2e tests to per page structure

* feat: add cypress type enchancements

* feat: add typescript for cypress tests

* fix: remove component after merge

* feat: update cypress definitions

* feat: add cypress cleanup task

* refactor: update cypress script names

* ci: add smoke tests to workflow

* chore: remove cypress example files

* feat: update signup flow to be reusable

* fix: fix signup route for cypress page object

* fix: remove cypress reset command

* fix: remove unused imports

* fix: Add unhandled error catcher
2022-11-08 14:21:10 +02:00

96 lines
2.2 KiB
Vue

<template>
<AuthView
:form="FORM_CONFIG"
:formLoading="loading"
data-test-id="signin-form"
@submit="onSubmit"
/>
</template>
<script lang="ts">
import AuthView from './AuthView.vue';
import { showMessage } from '@/components/mixins/showMessage';
import mixins from 'vue-typed-mixins';
import { IFormBoxConfig } from '@/Interface';
import { VIEWS } from '@/constants';
import { mapStores } from 'pinia';
import { useUsersStore } from '@/stores/users';
export default mixins(
showMessage,
).extend({
name: 'SigninView',
components: {
AuthView,
},
data() {
const FORM_CONFIG: IFormBoxConfig = {
title: this.$locale.baseText('auth.signin'),
buttonText: this.$locale.baseText('auth.signin'),
redirectText: this.$locale.baseText('forgotPassword'),
redirectLink: '/forgot-password',
inputs: [
{
name: 'email',
properties: {
label: this.$locale.baseText('auth.email'),
type: 'email',
required: true,
validationRules: [{ name: 'VALID_EMAIL' }],
showRequiredAsterisk: false,
validateOnBlur: false,
autocomplete: 'email',
capitalize: true,
},
},
{
name: 'password',
properties: {
label: this.$locale.baseText('auth.password'),
type: 'password',
required: true,
showRequiredAsterisk: false,
validateOnBlur: false,
autocomplete: 'current-password',
capitalize: true,
},
},
],
};
return {
FORM_CONFIG,
loading: false,
};
},
computed: {
...mapStores(useUsersStore),
},
methods: {
async onSubmit(values: {[key: string]: string}) {
try {
this.loading = true;
await this.usersStore.loginWithCreds(values as {email: string, password: string});
this.clearAllStickyNotifications();
this.loading = false;
if (typeof this.$route.query.redirect === 'string') {
const redirect = decodeURIComponent(this.$route.query.redirect);
if (redirect.startsWith('/')) { // protect against phishing
this.$router.push(redirect);
return;
}
}
this.$router.push({ name: VIEWS.HOMEPAGE });
} catch (error) {
this.$showError(error, this.$locale.baseText('auth.signin.error'));
this.loading = false;
}
},
},
});
</script>