From 394469d773d54d8f85595b7f0f5a2e7243071629 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Tue, 10 Mar 2020 10:16:30 +0100 Subject: [PATCH] Add new cypress test and fix old ones --- client/cypress/fixtures/me.join-class.json | 1 + client/cypress/fixtures/schema.json | 131 +++++++++++++----- .../fixtures/selected-school-class.json | 2 +- client/cypress/integration/join-class.spec.js | 55 +++++++- client/src/components/profile/ClassList.vue | 6 +- client/src/pages/oldClasses.vue | 3 +- 6 files changed, 152 insertions(+), 46 deletions(-) diff --git a/client/cypress/fixtures/me.join-class.json b/client/cypress/fixtures/me.join-class.json index 0ab8c2b0..7774e6f0 100644 --- a/client/cypress/fixtures/me.join-class.json +++ b/client/cypress/fixtures/me.join-class.json @@ -7,6 +7,7 @@ "firstName": "Rahel", "lastName": "Cueni", "avatarUrl": "", + "isTeacher": false, "lastModule": { "id": "TW9kdWxlTm9kZToxNw==", "slug": "lohn-und-budget", diff --git a/client/cypress/fixtures/schema.json b/client/cypress/fixtures/schema.json index df2ae845..421118e4 100644 --- a/client/cypress/fixtures/schema.json +++ b/client/cypress/fixtures/schema.json @@ -408,6 +408,33 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "node", + "description": "The ID of the object", + "args": [ + { + "name": "id", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null + } + ], + "type": { + "kind": "INTERFACE", + "name": "Node", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "book", "description": "The ID of the object", @@ -437,19 +464,15 @@ }, { "name": "topic", - "description": "The ID of the object", + "description": null, "args": [ { - "name": "id", + "name": "slug", "description": null, "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } + "kind": "SCALAR", + "name": "String", + "ofType": null }, "defaultValue": null } @@ -1517,33 +1540,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "node", - "description": "The ID of the object", - "args": [ - { - "name": "id", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "_debug", "description": null, @@ -3081,6 +3077,69 @@ }, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "oldClasses", + "description": null, + "args": [ + { + "name": "before", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null + }, + { + "name": "after", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null + }, + { + "name": "first", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "defaultValue": null + }, + { + "name": "last", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "defaultValue": null + }, + { + "name": "name", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null + } + ], + "type": { + "kind": "OBJECT", + "name": "SchoolClassNodeConnection", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null } ], "inputFields": null, diff --git a/client/cypress/fixtures/selected-school-class.json b/client/cypress/fixtures/selected-school-class.json index b905ec95..d7b3233c 100644 --- a/client/cypress/fixtures/selected-school-class.json +++ b/client/cypress/fixtures/selected-school-class.json @@ -1,7 +1,7 @@ { "me": { "id": "VXNlck5vZGU6Mg==", - "isTeacher": true, + "isTeacher": false, "selectedClass": { "id": "U2Nob29sQ2xhc3NOb2RlOjE=", "name": "Moordale", diff --git a/client/cypress/integration/join-class.spec.js b/client/cypress/integration/join-class.spec.js index 9e1f8cdf..e022e56a 100644 --- a/client/cypress/integration/join-class.spec.js +++ b/client/cypress/integration/join-class.spec.js @@ -37,8 +37,10 @@ describe('Class Management', () => { cy.get('[data-cy=header-user-widget]').within(() => { cy.get('[data-cy=user-widget-avatar]').click(); }); + cy.get('[data-cy=class-selection]').click(); cy.get('[data-cy=class-selection-entry]').should('have.length', 1); + cy.get('[data-cy=class-selection]').click(); cy.get('[data-cy=join-class-link]').click(); @@ -53,10 +55,32 @@ describe('Class Management', () => { cy.get('[data-cy=class-selection-entry]').should('have.length', 2); }); - it.only('should leave and re-join class', () => { + it('should not be able to leave class', () => { + cy.mockGraphqlOps({ + operations: { + MeQuery: me, + MySchoolClassQuery: selectedClass + } + }); + + cy.visit('/me/my-class'); + cy.get('[data-cy=school-class-member]').should('have.length', 2); + cy.get('[data-cy=remove-from-class]').should('have.length', 0); + cy.get('[data-cy=add-to-class]').should('have.length', 0); + }); + + it('should leave and re-join class', () => { const teacher = { - ...me, - permissions: ['users.can_manage_school_class_content'] + me: { + ...me.me, + isTeacher: true + } + }; + const teacherSelectedClass = { + me: { + ...selectedClass.me, + isTeacher: true + } }; cy.mockGraphqlOps({ operations: { @@ -66,7 +90,7 @@ describe('Class Management', () => { success: true } }, - MySchoolClassQuery: selectedClass + MySchoolClassQuery: teacherSelectedClass } }); @@ -96,4 +120,27 @@ describe('Class Management', () => { cy.get('[data-cy=school-class-member]').should('have.length', 0) }); }); + + it.only('should display old classes', () => { + let oldClasses = me.me.schoolClasses; + let OldClassesQuery = { + me: { + ...me.me, + oldClasses + }, + }; + + debugger; + cy.mockGraphqlOps({ + operations: { + MeQuery: me, + OldClassesQuery + } + }); + + cy.visit('/me/old-classes'); + + cy.get('[data-cy=old-class-item]').should('have.length', 1); + + }); }); diff --git a/client/src/components/profile/ClassList.vue b/client/src/components/profile/ClassList.vue index 63580796..d1951e61 100644 --- a/client/src/components/profile/ClassList.vue +++ b/client/src/components/profile/ClassList.vue @@ -2,7 +2,7 @@

{{name}}

-
    +

    Deaktivierte Benutzer

    -
      +
      • Alte Klassen

          -
        • {{schoolClass.name}} Anzeigen
        • @@ -40,7 +40,6 @@ data: () => ({ me: { oldClasses: [] - } }) }