Fix cypress tests

This commit is contained in:
Ramon Wenger 2020-07-10 15:15:56 +02:00
parent e9d8fdad24
commit 2c0039be42
5 changed files with 37 additions and 50 deletions

View File

@ -4,7 +4,7 @@ describe('The Login Page', () => {
const password = 'test'; const password = 'test';
cy.visit('/beta-login'); cy.visit('/beta-login');
cy.login(username, password, true); cy.login(username, password, true);
cy.assertStartPage(true); cy.assertStartPage();
}); });
it('user sees error message if username is omitted', () => { it('user sees error message if username is omitted', () => {

View File

@ -1,32 +1,6 @@
const schema = require('../fixtures/schema.json');
const me = require('../fixtures/me.join-class.json');
describe('The Rooms Page', () => { describe('The Rooms Page', () => {
beforeEach(() => {
cy.server();
cy.mockGraphql({
schema: schema,
});
});
// todo: mock all the graphql queries and mutations // todo: mock all the graphql queries and mutations
it('goes to the rooms page', () => { it('goes to the rooms page', () => {
let teacher = Object.assign({}, {
...me
},
{
me: {
permissions: ['users.can_manage_school_class_content']
}
});
cy.mockGraphqlOps({
schema: schema,
operations: {
MeQuery: teacher
}
});
cy.apolloLogin('nico.zickgraf', 'test'); cy.apolloLogin('nico.zickgraf', 'test');
cy.visit('/rooms'); cy.visit('/rooms');
@ -34,13 +8,6 @@ describe('The Rooms Page', () => {
}); });
it('add room should not exist for student', () => { it('add room should not exist for student', () => {
cy.mockGraphqlOps({
schema: schema,
operations: {
MeQuery: me
}
});
cy.apolloLogin('rahel.cueni', 'test'); cy.apolloLogin('rahel.cueni', 'test');
cy.visit('/rooms'); cy.visit('/rooms');

View File

@ -11673,7 +11673,8 @@
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
@ -11701,6 +11702,7 @@
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -11715,7 +11717,8 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
@ -11726,7 +11729,8 @@
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -11843,7 +11847,8 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -11855,6 +11860,7 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -11869,6 +11875,7 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@ -11876,12 +11883,14 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.3.5", "version": "2.3.5",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.2", "safe-buffer": "^5.1.2",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -11900,6 +11909,7 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -11980,7 +11990,8 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -11992,6 +12003,7 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -12077,7 +12089,8 @@
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"safer-buffer": { "safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
@ -12113,6 +12126,7 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -12132,6 +12146,7 @@
"version": "3.0.1", "version": "3.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
@ -12175,12 +12190,14 @@
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"yallist": { "yallist": {
"version": "3.0.3", "version": "3.0.3",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
} }
} }
}, },

View File

@ -53,7 +53,8 @@ class Command(BaseCommand):
is_staff=True, is_staff=True,
is_superuser=True, is_superuser=True,
first_name='Nicol', first_name='Nicol',
last_name='Bolas' last_name='Bolas',
onboarding_visited=True
) )
create_users(user_data) create_users(user_data)

View File

@ -23,11 +23,11 @@ def create_users(data=None):
if data is None: if data is None:
teacher = UserFactory(username='teacher') teacher = UserFactory(username='teacher')
UserRole.objects.create(user=teacher, role=teacher_role) UserRole.objects.create(user=teacher, role=teacher_role, onboarding_visited=True)
students = [] students = []
for i in range(1, 7): for i in range(1, 7):
student = create_student(username='student{}'.format(i)) student = create_student(username='student{}'.format(i), onboarding_visited=True)
students.append(student) students.append(student)
SchoolClassFactory( SchoolClassFactory(
@ -35,9 +35,9 @@ def create_users(data=None):
name='skillbox', name='skillbox',
) )
teacher2 = UserFactory(username='teacher2') teacher2 = UserFactory(username='teacher2')
UserRole.objects.create(user=teacher2, role=teacher_role) UserRole.objects.create(user=teacher2, role=teacher_role, onboarding_visited=True)
student_second_class = create_student(username='student_second_class') student_second_class = create_student(username='student_second_class', onboarding_visited=True)
SchoolClassFactory( SchoolClassFactory(
users=[teacher2, student_second_class], users=[teacher2, student_second_class],
name='second_class' name='second_class'
@ -50,7 +50,8 @@ def create_users(data=None):
username='{}.{}'.format(first, last).lower(), username='{}.{}'.format(first, last).lower(),
first_name=first, first_name=first,
last_name=last, last_name=last,
email='{}.{}@skillbox.example'.format(first, last).lower() email='{}.{}@skillbox.example'.format(first, last).lower(),
onboarding_visited=True
) )
UserRole.objects.create(user=teacher, role=teacher_role) UserRole.objects.create(user=teacher, role=teacher_role)
students = [] students = []
@ -60,7 +61,8 @@ def create_users(data=None):
username='{}.{}'.format(first, last).lower(), username='{}.{}'.format(first, last).lower(),
first_name=first, first_name=first,
last_name=last, last_name=last,
email='{}.{}@skillbox.example'.format(first, last).lower() email='{}.{}@skillbox.example'.format(first, last).lower(),
onboarding_visited=True
) )
students.append(student) students.append(student)