diff --git a/webapp/components/Registration/CreateUserAccount.spec.js b/webapp/components/Registration/CreateUserAccount.spec.js deleted file mode 100644 index faa9319e7..000000000 --- a/webapp/components/Registration/CreateUserAccount.spec.js +++ /dev/null @@ -1,153 +0,0 @@ -import { config, mount } from '@vue/test-utils' -import Vue from 'vue' -import { VERSION } from '~/constants/terms-and-conditions-version.js' -import CreateUserAccount from './CreateUserAccount' -import { SignupVerificationMutation } from '~/graphql/Registration.js' -const localVue = global.localVue - -config.stubs['sweetalert-icon'] = '' -config.stubs['client-only'] = '' -config.stubs['nuxt-link'] = '' - -describe('CreateUserAccount', () => { - let wrapper, Wrapper, mocks, propsData, stubs - - beforeEach(() => { - mocks = { - $toast: { - success: jest.fn(), - error: jest.fn(), - }, - $t: jest.fn(), - $apollo: { - loading: false, - mutate: jest.fn(), - }, - $i18n: { - locale: () => 'en', - }, - } - propsData = {} - stubs = { - LocaleSwitch: "
", - } - }) - - describe('mount', () => { - Wrapper = () => { - return mount(CreateUserAccount, { - mocks, - propsData, - localVue, - stubs, - }) - } - - describe('given email and nonce', () => { - beforeEach(() => { - propsData.nonce = '666777' - propsData.email = 'sixseven@example.org' - }) - - it('renders a form to create a new user', () => { - wrapper = Wrapper() - expect(wrapper.find('.create-user-account').exists()).toBe(true) - }) - - describe('submit', () => { - let action - beforeEach(() => { - action = async () => { - wrapper = Wrapper() - wrapper.find('input#name').setValue('John Doe') - wrapper.find('input#password').setValue('hellopassword') - wrapper.find('textarea#about').setValue('Hello I am the `about` attribute') - wrapper.find('input#passwordConfirmation').setValue('hellopassword') - wrapper.find('input#checkbox0').setChecked() - wrapper.find('input#checkbox1').setChecked() - wrapper.find('input#checkbox2').setChecked() - wrapper.find('input#checkbox3').setChecked() - wrapper.find('input#checkbox4').setChecked() - await wrapper.find('form').trigger('submit') - await wrapper.html() - } - }) - - it('delivers data to backend', async () => { - await action() - const expected = expect.objectContaining({ - variables: { - about: 'Hello I am the `about` attribute', - name: 'John Doe', - email: 'sixseven@example.org', - nonce: '666777', - password: 'hellopassword', - termsAndConditionsAgreedVersion: VERSION, - locale: 'en', - }, - }) - expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected) - }) - - it('calls CreateUserAccount graphql mutation', async () => { - await action() - const expected = expect.objectContaining({ mutation: SignupVerificationMutation }) - expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected) - }) - - describe('in case mutation resolves', () => { - beforeEach(() => { - mocks.$apollo.mutate = jest.fn().mockResolvedValue({ - data: { - SignupVerification: { - id: 'u1', - name: 'John Doe', - slug: 'john-doe', - }, - }, - }) - }) - - it('displays success', async () => { - await action() - await Vue.nextTick() - expect(mocks.$t).toHaveBeenCalledWith( - 'components.registration.create-user-account.success', - ) - }) - - describe('after timeout', () => { - beforeEach(jest.useFakeTimers) - - it('emits `userCreated` with { password, email }', async () => { - await action() - jest.runAllTimers() - expect(wrapper.emitted('userCreated')).toEqual([ - [ - { - email: 'sixseven@example.org', - password: 'hellopassword', - }, - ], - ]) - }) - }) - }) - - describe('in case mutation rejects', () => { - beforeEach(() => { - mocks.$apollo.mutate = jest.fn().mockRejectedValue(new Error('Invalid nonce')) - }) - - it('displays form errors', async () => { - await action() - await Vue.nextTick() - expect(mocks.$t).toHaveBeenCalledWith( - 'components.registration.create-user-account.error', - ) - }) - }) - }) - }) - }) -}) diff --git a/webapp/components/Registration/CreateUserAccount.story.js b/webapp/components/Registration/CreateUserAccount.story.js deleted file mode 100644 index 054ee71b4..000000000 --- a/webapp/components/Registration/CreateUserAccount.story.js +++ /dev/null @@ -1,84 +0,0 @@ -import { storiesOf } from '@storybook/vue' -import { withA11y } from '@storybook/addon-a11y' -import { action } from '@storybook/addon-actions' -import Vuex from 'vuex' -import helpers from '~/storybook/helpers' -import links from '~/constants/links.js' -import metadata from '~/constants/metadata.js' -import LocaleSwitch from '~/components/LocaleSwitch/LocaleSwitch' -import CreateUserAccount from './CreateUserAccount.vue' - -helpers.init() - -const createStore = ({ loginSuccess }) => { - return new Vuex.Store({ - modules: { - auth: { - namespaced: true, - state: () => ({ - pending: false, - }), - mutations: { - SET_PENDING(state, pending) { - state.pending = pending - }, - }, - getters: { - pending(state) { - return !!state.pending - }, - }, - actions: { - async login({ commit, dispatch }, args) { - action('Vuex action `auth/login`')(args) - return new Promise((resolve, reject) => { - commit('SET_PENDING', true) - setTimeout(() => { - commit('SET_PENDING', false) - if (loginSuccess) { - resolve(loginSuccess) - } else { - reject(new Error('Login unsuccessful')) - } - }, 1000) - }) - }, - }, - }, - }, - }) -} - -storiesOf('CreateUserAccount', module) - .addDecorator(withA11y) - .addDecorator(helpers.layout) - .add('standard', () => ({ - components: { LocaleSwitch, CreateUserAccount }, - store: createStore({ loginSuccess: true }), - data: () => ({ - links, - metadata, - nonce: 'A34RB56', - email: 'user@example.org', - }), - methods: { - handleSuccess() { - action('You are logged in!')() - }, - }, - template: ` - - - - - - - - `, - })) diff --git a/webapp/components/Registration/CreateUserAccount.vue b/webapp/components/Registration/CreateUserAccount.vue deleted file mode 100644 index fb855017a..000000000 --- a/webapp/components/Registration/CreateUserAccount.vue +++ /dev/null @@ -1,222 +0,0 @@ - - - - - diff --git a/webapp/components/Registration/RegistrationSlideCreate.vue b/webapp/components/Registration/RegistrationSlideCreate.vue index d7013968d..532dc00b6 100644 --- a/webapp/components/Registration/RegistrationSlideCreate.vue +++ b/webapp/components/Registration/RegistrationSlideCreate.vue @@ -23,12 +23,6 @@
- - { // }) }) }) + +// Wolle templete from deleted webapp/components/Registration/CreateUserAccount.spec.js +// import { config, mount } from '@vue/test-utils' +// import Vue from 'vue' +// import { VERSION } from '~/constants/terms-and-conditions-version.js' +// import CreateUserAccount from './CreateUserAccount' +// import { SignupVerificationMutation } from '~/graphql/Registration.js' +// const localVue = global.localVue + +// config.stubs['sweetalert-icon'] = '' +// config.stubs['client-only'] = '' +// config.stubs['nuxt-link'] = '' + +// describe('CreateUserAccount', () => { +// let wrapper, Wrapper, mocks, propsData, stubs + +// beforeEach(() => { +// mocks = { +// $toast: { +// success: jest.fn(), +// error: jest.fn(), +// }, +// $t: jest.fn(), +// $apollo: { +// loading: false, +// mutate: jest.fn(), +// }, +// $i18n: { +// locale: () => 'en', +// }, +// } +// propsData = {} +// stubs = { +// LocaleSwitch: "
", +// } +// }) + +// describe('mount', () => { +// Wrapper = () => { +// return mount(CreateUserAccount, { +// mocks, +// propsData, +// localVue, +// stubs, +// }) +// } + +// describe('given email and nonce', () => { +// beforeEach(() => { +// propsData.nonce = '666777' +// propsData.email = 'sixseven@example.org' +// }) + +// it('renders a form to create a new user', () => { +// wrapper = Wrapper() +// expect(wrapper.find('.create-user-account').exists()).toBe(true) +// }) + +// describe('submit', () => { +// let action +// beforeEach(() => { +// action = async () => { +// wrapper = Wrapper() +// wrapper.find('input#name').setValue('John Doe') +// wrapper.find('input#password').setValue('hellopassword') +// wrapper.find('textarea#about').setValue('Hello I am the `about` attribute') +// wrapper.find('input#passwordConfirmation').setValue('hellopassword') +// wrapper.find('input#checkbox0').setChecked() +// wrapper.find('input#checkbox1').setChecked() +// wrapper.find('input#checkbox2').setChecked() +// wrapper.find('input#checkbox3').setChecked() +// wrapper.find('input#checkbox4').setChecked() +// await wrapper.find('form').trigger('submit') +// await wrapper.html() +// } +// }) + +// it('delivers data to backend', async () => { +// await action() +// const expected = expect.objectContaining({ +// variables: { +// about: 'Hello I am the `about` attribute', +// name: 'John Doe', +// email: 'sixseven@example.org', +// nonce: '666777', +// password: 'hellopassword', +// termsAndConditionsAgreedVersion: VERSION, +// locale: 'en', +// }, +// }) +// expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected) +// }) + +// it('calls CreateUserAccount graphql mutation', async () => { +// await action() +// const expected = expect.objectContaining({ mutation: SignupVerificationMutation }) +// expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected) +// }) + +// describe('in case mutation resolves', () => { +// beforeEach(() => { +// mocks.$apollo.mutate = jest.fn().mockResolvedValue({ +// data: { +// SignupVerification: { +// id: 'u1', +// name: 'John Doe', +// slug: 'john-doe', +// }, +// }, +// }) +// }) + +// it('displays success', async () => { +// await action() +// await Vue.nextTick() +// expect(mocks.$t).toHaveBeenCalledWith( +// 'components.registration.create-user-account.success', +// ) +// }) + +// describe('after timeout', () => { +// beforeEach(jest.useFakeTimers) + +// it('emits `userCreated` with { password, email }', async () => { +// await action() +// jest.runAllTimers() +// expect(wrapper.emitted('userCreated')).toEqual([ +// [ +// { +// email: 'sixseven@example.org', +// password: 'hellopassword', +// }, +// ], +// ]) +// }) +// }) +// }) + +// describe('in case mutation rejects', () => { +// beforeEach(() => { +// mocks.$apollo.mutate = jest.fn().mockRejectedValue(new Error('Invalid nonce')) +// }) + +// it('displays form errors', async () => { +// await action() +// await Vue.nextTick() +// expect(mocks.$t).toHaveBeenCalledWith( +// 'components.registration.create-user-account.error', +// ) +// }) +// }) +// }) +// }) +// }) +// }) diff --git a/webapp/pages/registration/create-user-account.vue b/webapp/pages/registration/create-user-account.vue deleted file mode 100644 index 677aea5eb..000000000 --- a/webapp/pages/registration/create-user-account.vue +++ /dev/null @@ -1,27 +0,0 @@ - - - diff --git a/webapp/pages/registration/enter-nonce.vue b/webapp/pages/registration/enter-nonce.vue deleted file mode 100644 index 022435b6e..000000000 --- a/webapp/pages/registration/enter-nonce.vue +++ /dev/null @@ -1,25 +0,0 @@ - - - diff --git a/webapp/pages/registration/signup.vue b/webapp/pages/registration/signup.vue deleted file mode 100644 index 18f9c9a70..000000000 --- a/webapp/pages/registration/signup.vue +++ /dev/null @@ -1,34 +0,0 @@ - - -