Add and update tests, add dummy data
This commit is contained in:
parent
981b99ced7
commit
bceb01c5f4
|
|
@ -43,52 +43,5 @@ describe('The Login Page', () => {
|
|||
cy.login(username, password);
|
||||
cy.get('body').contains('Berufliche Grundbildung');
|
||||
});
|
||||
// it('logs in programmatically without using the UI', () => {
|
||||
// cy.visit('/accounts/login/'); // have to get a csrf token by getting the base page first
|
||||
//
|
||||
// const username = 'test';
|
||||
// const password = 'test';
|
||||
//
|
||||
// cy.getCookie('csrftoken').then(token => {
|
||||
// const options = {
|
||||
// url: '/accounts/login/',
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'X-CSRFToken': token.value,
|
||||
// 'content-type': 'multipart/form-data'
|
||||
// },
|
||||
// from: true,
|
||||
// body: {
|
||||
// username: username,
|
||||
// password: password,
|
||||
// // csrfmiddlewaretoken: token.value
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// cy.request(options);
|
||||
// cy.getCookie('sessionid').should('exist');
|
||||
// cy.visit('/');
|
||||
//
|
||||
// cy.get('.start-page__title').should('contain', 'skillbox')
|
||||
//
|
||||
//
|
||||
// // cy.visit('/');
|
||||
// // cy.getCookie('csrftoken')
|
||||
// // .then((csrftoken) => {
|
||||
// // const response = cy.request({
|
||||
// // method: 'POST',
|
||||
// // url: '/login/',
|
||||
// // form: true,
|
||||
// // body: {
|
||||
// // identification: username,
|
||||
// // password: password,
|
||||
// // csrfmiddlewaretoken: csrftoken.value
|
||||
// // }
|
||||
// // });
|
||||
// // });
|
||||
//
|
||||
// });
|
||||
|
||||
|
||||
// })
|
||||
})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,76 @@
|
|||
describe('The Regstration Page', () => {
|
||||
it('register user', () => {
|
||||
|
||||
let timestamp = Math.round((new Date()).getTime() / 1000);
|
||||
|
||||
const firstname = 'pesche';
|
||||
const lastname = 'peschemann';
|
||||
const email = `skillboxtest${timestamp}@iterativ.ch`;
|
||||
const licenseKey = 'c1fa2e2a-2e27-480d-8469-2e88414c4ad8';
|
||||
|
||||
cy.visit('/register');
|
||||
cy.register(firstname, lastname, email, licenseKey);
|
||||
cy.get('.reset__heading').contains('Schauen Sie in Ihr Postfach');
|
||||
});
|
||||
|
||||
it('user sees error message if firstname is omitted', () => {
|
||||
let timestamp = Math.round((new Date()).getTime() / 1000);
|
||||
const firstname = '';
|
||||
const lastname = 'peschemann';
|
||||
const email = `skillboxtest${timestamp}@iterativ.ch`;
|
||||
const licenseKey = 'c1fa2e2a-2e27-480d-8469-2e88414c4ad8';
|
||||
|
||||
cy.visit('/register');
|
||||
cy.register(firstname, lastname, email, licenseKey);
|
||||
cy.get('[data-cy="firstname-local-errors"]').contains('Vorname ist ein Pflichtfeld.');
|
||||
});
|
||||
|
||||
it('user sees error message if lastname is omitted', () => {
|
||||
let timestamp = Math.round((new Date()).getTime() / 1000);
|
||||
const firstname = 'pesche';
|
||||
const lastname = '';
|
||||
const email = `skillboxtest${timestamp}@iterativ.ch`;
|
||||
const licenseKey = 'c1fa2e2a-2e27-480d-8469-2e88414c4ad8';
|
||||
|
||||
cy.visit('/register');
|
||||
cy.register(firstname, lastname, email, licenseKey);
|
||||
cy.get('[data-cy="lastname-local-errors"]').contains('Nachname ist ein Pflichtfeld.');
|
||||
});
|
||||
|
||||
it('user sees error message if email is omitted', () => {
|
||||
let timestamp = Math.round((new Date()).getTime() / 1000);
|
||||
const firstname = 'pesche';
|
||||
const lastname = 'peschemann';
|
||||
const email = ``;
|
||||
const licenseKey = 'c1fa2e2a-2e27-480d-8469-2e88414c4ad8';
|
||||
|
||||
cy.visit('/register');
|
||||
cy.register(firstname, lastname, email, licenseKey);
|
||||
cy.get('[data-cy="email-local-errors"]').contains('E-Mail ist ein Pflichtfeld.');
|
||||
});
|
||||
|
||||
it('user sees error message if license is omitted', () => {
|
||||
let timestamp = Math.round((new Date()).getTime() / 1000);
|
||||
const firstname = 'pesche';
|
||||
const lastname = 'peschemann';
|
||||
const email = `skillboxtest${timestamp}@iterativ.ch`;
|
||||
const licenseKey = '';
|
||||
|
||||
cy.visit('/register');
|
||||
cy.register(firstname, lastname, email, licenseKey);
|
||||
cy.get('[data-cy="licenseKey-local-errors"]').contains('Lizenz ist ein Pflichtfeld.');
|
||||
});
|
||||
|
||||
it('user sees error message if license key is wrong', () => {
|
||||
let timestamp = Math.round((new Date()).getTime() / 1000);
|
||||
const firstname = 'pesche';
|
||||
const lastname = 'peschemann';
|
||||
const email = `skillboxtest${timestamp}@iterativ.ch`;
|
||||
const licenseKey = 'asdsafsadfsadfasdf';
|
||||
|
||||
cy.visit('/register');
|
||||
cy.register(firstname, lastname, email, licenseKey);
|
||||
cy.get('[data-cy="licenseKey-remote-errors"]').contains('Die angegebenen Lizenz ist unglültig');
|
||||
});
|
||||
|
||||
})
|
||||
|
|
@ -82,3 +82,23 @@ Cypress.Commands.add('changePassword', (oldPassword, newPassword) => {
|
|||
}
|
||||
cy.get('[data-cy=change-password-button]').click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('register', (firstname, lastname, email, licenseKey) => {
|
||||
if (firstname != '') {
|
||||
cy.get('[data-cy=firstname-input]').type(firstname);
|
||||
}
|
||||
|
||||
if (lastname != '') {
|
||||
cy.get('[data-cy=lastname-input]').type(lastname);
|
||||
}
|
||||
|
||||
if (email != '') {
|
||||
cy.get('[data-cy=email-input]').type(email);
|
||||
}
|
||||
|
||||
if (licenseKey != '') {
|
||||
cy.get('[data-cy=licenseKey-input]').type(licenseKey);
|
||||
}
|
||||
|
||||
cy.get('[data-cy=register-button]').click();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@
|
|||
<small class="skillboxform-input__error" data-cy="registration-error" v-if="registrationError">{{registrationError}}</small>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="button button--primary button--big actions__submit" data-cy="registration-button">Jetzt registration</button>
|
||||
<button class="button button--primary button--big actions__submit" data-cy="register-button">Jetzt registration</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -149,7 +149,7 @@ export default {
|
|||
) {
|
||||
try {
|
||||
if (success) {
|
||||
that.$router.push('/set-password/done/');
|
||||
window.location.href = '/set-password/done/';
|
||||
} else {
|
||||
errors.forEach(function(error) {
|
||||
switch (error.field) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ from django.core.management import BaseCommand
|
|||
from django.db import connection
|
||||
from wagtail.core.models import Page
|
||||
|
||||
from assignments.factories import AssignmentFactory
|
||||
from books.factories import BookFactory, TopicFactory, ModuleFactory, ChapterFactory, ContentBlockFactory
|
||||
from core.factories import UserFactory
|
||||
from objectives.factories import ObjectiveGroupFactory, ObjectiveFactory
|
||||
|
|
@ -103,5 +102,10 @@ class Command(BaseCommand):
|
|||
# ContentBlockFactory.create(parent=chapter, **self.filter_data(content_block_data, 'contents'))
|
||||
ContentBlockFactory.create(parent=chapter, module=module, **content_block_data)
|
||||
|
||||
|
||||
|
||||
# now create all and rooms
|
||||
management.call_command('dummy_rooms', verbosity=0)
|
||||
|
||||
# create license
|
||||
management.call_command('create_dummy_license', verbosity=0)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
import json
|
||||
|
||||
from django.test import TestCase, Client
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from core import settings
|
||||
from core.factories import UserFactory
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# ITerativ GmbH
|
||||
# http://www.iterativ.ch/
|
||||
#
|
||||
# Copyright (c) 2019 ITerativ GmbH. All rights reserved.
|
||||
#
|
||||
# Created on 2019-10-23
|
||||
# @author: chrigu <christian.cueni@iterativ.ch>
|
||||
from django.conf import settings
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# ITerativ GmbH
|
||||
# http://www.iterativ.ch/
|
||||
#
|
||||
# Copyright (c) 2019 ITerativ GmbH. All rights reserved.
|
||||
#
|
||||
# Created on 2019-10-23
|
||||
# @author: chrigu <christian.cueni@iterativ.ch>
|
||||
from django.conf import settings
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# ITerativ GmbH
|
||||
# http://www.iterativ.ch/
|
||||
#
|
||||
# Copyright (c) 2019 ITerativ GmbH. All rights reserved.
|
||||
#
|
||||
# Created on 2019-10-23
|
||||
# @author: chrigu <christian.cueni@iterativ.ch>
|
||||
from django.conf import settings
|
||||
from django.core.management import BaseCommand
|
||||
|
||||
from registration.models import LicenseType
|
||||
from users.models import Role
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
||||
try:
|
||||
role = Role.objects.get(key=Role.objects.TEACHER_KEY)
|
||||
except Role.DoesNotExist:
|
||||
print("LicenseType requires that a Teacher Role exsits")
|
||||
|
||||
LicenseType.objects.create(name='dummy_license',
|
||||
for_role=role,
|
||||
active=True,
|
||||
key='c1fa2e2a-2e27-480d-8469-2e88414c4ad8',
|
||||
description='dummy license')
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
#
|
||||
# Created on 2019-10-08
|
||||
# @author: chrigu <christian.cueni@iterativ.ch>
|
||||
from django.core import mail
|
||||
from django.contrib.sessions.middleware import SessionMiddleware
|
||||
from django.test import TestCase, RequestFactory
|
||||
from graphene.test import Client
|
||||
|
|
@ -82,6 +83,8 @@ class RegistrationTests(TestCase):
|
|||
self.assertEqual(len(school_classes), 1)
|
||||
user = User.objects.get(email=self.email)
|
||||
self.assertTrue(school_classes[0].is_user_in_schoolclass(user))
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
self.assertEqual(mail.outbox[0].subject, 'Myskillbox: E-Mail bestätigen und Passwort setzen')
|
||||
|
||||
def test_user_can_register_as_student(self):
|
||||
self._assert_user_registration(0, self.email, RoleManager.STUDENT_KEY)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class SchoolClass(models.Model):
|
|||
prefix = 'Meine Gruppe'
|
||||
prefix_regex = r'Meine Gruppe (\d+)'
|
||||
initial_default_group = '{} 1'.format(prefix)
|
||||
my_group_filter = cls.objects.filter(name__startswith=prefix).order_by('-name')
|
||||
my_group_filter = cls.objects.filter(name__startswith=prefix).order_by('-pk')
|
||||
|
||||
if len(my_group_filter) == 0:
|
||||
return initial_default_group
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#
|
||||
# Created on 2019-10-01
|
||||
# @author: chrigu <christian.cueni@iterativ.ch>
|
||||
import re
|
||||
|
||||
import graphene
|
||||
from django.contrib.auth import authenticate, login
|
||||
|
|
|
|||
Loading…
Reference in New Issue