const schema = require('../fixtures/schema.json'); describe('Spellcheck', () => { beforeEach(() => { cy.server(); cy.mockGraphql({ schema: schema, // endpoint: '/api/graphql' }); }); it('should highlight three errors', () => { let module = { id: 'TW9kdWxlTm9kZToxNw==', title: 'Whatevs', metaTitle: 'Modul 1', teaser: 'Die Berufsbildung ist ein neuer Lebensabschnit', intro: '\n

Sie stehen am Anfang eines neuen Lebensabschnitts. In Ihrer Rolle als Berufslernende oder Berufslernender haben Sie Verantwortung \u00fcbernommen.

\n

Wie erging es Ihnen am ersten Arbeits- und Schultag?

\n ', slug: 'lohn-und-budget', heroImage: 'https://hep-skillbox-files-prod.s3-eu-central-1.amazonaws.com/original_images/dummy_7bzqodY.jpg', solutionsEnabled: false, bookmark: {note: null, '__typename': 'ModuleBookmarkNode'}, __typename: 'ModuleNode', assignments: { 'edges': [{ 'node': { 'id': 'QXNzaWdubWVudE5vZGU6MQ==', 'title': 'Ein Auftragstitel', 'assignment': 'Ein Auftrag', 'solution': null, 'submission': { 'id': 'U3R1ZGVudFN1Ym1pc3Npb25Ob2RlOjE=', 'text': 'Hir ist ein Feler gewesen', 'final': false, 'document': '', 'submissionFeedback': { 'id': 'U3VibWlzc2lvbkZlZWRiYWNrTm9kZTox', 'text': '\ud83d\ude42\ud83d\ude10\ud83e\udd2c\ud83d\udc4d\ud83e\udd22\ud83e\udd22\ud83e\udd22\ud83e\udd22\ud83d\ude2e\ud83e\udd17', 'teacher': {'firstName': 'Nico', 'lastName': 'Zickgraf', '__typename': 'UserNode'}, '__typename': 'SubmissionFeedbackNode' }, '__typename': 'StudentSubmissionNode' }, '__typename': 'AssignmentNode' }, '__typename': 'AssignmentNodeEdge' }], '__typename': 'AssignmentNodeConnection' }, 'objectiveGroups': { 'edges': [], '__typename': 'ObjectiveGroupNodeConnection' }, 'chapters': { 'edges': [{ 'node': { 'id': 'Q2hhcHRlck5vZGU6MTg=', 'title': '1.1 Lehrbeginn', 'description': 'Wie sieht Ihr Konsumverhalten aus?', 'bookmark': { 'note': {'id': 'Tm90ZU5vZGU6Mg==', 'text': 'Chapter Chapter', '__typename': 'NoteNode'}, '__typename': 'ChapterBookmarkNode' }, 'contentBlocks': { 'edges': [{ 'node': { 'id': 'Q29udGVudEJsb2NrTm9kZToxOQ==', 'slug': 'assignment', 'title': 'Assignment', 'type': 'NORMAL', 'contents': [{ 'type': 'assignment', 'value': { 'title': 'Ein Auftragstitel', 'assignment': 'Ein Auftrag', 'id': 'QXNzaWdubWVudE5vZGU6MQ==' }, 'id': 'df8212ee-3e82-49fa-977e-c4b60789163e' }], 'userCreated': false, 'mine': false, 'bookmarks': [{ 'uuid': 'df8212ee-3e82-49fa-977e-c4b60789163e', 'note': {'id': 'Tm90ZU5vZGU6Mw==', 'text': 'Noch eine Notiz', '__typename': 'NoteNode'}, '__typename': 'ContentBlockBookmarkNode' }], 'hiddenFor': {'edges': [], '__typename': 'SchoolClassNodeConnection'}, 'visibleFor': {'edges': [], '__typename': 'SchoolClassNodeConnection'}, '__typename': 'ContentBlockNode' }, '__typename': 'ContentBlockNodeEdge' }], '__typename': 'ContentBlockNodeConnection' }, '__typename': 'ChapterNode' }, '__typename': 'ChapterNodeEdge' }], '__typename': 'ChapterNodeConnection' } }; cy.mockGraphqlOps({ // endpoint: '/api/graphql', operations: { MeQuery: { me: { permissions: [] } }, ModulesQuery: { module }, SpellCheck: { spellCheck: { correct: false, results: [{ sentence: 'Hir ist ein Feler gewesen', offset: 0, length: 3, affected: 'Hir', corrected: 'Dir', __typename: 'SpellCheckStepNode' }, { sentence: 'Hir ist ein Feler gewesen', offset: 12, length: 5, affected: 'Feler', corrected: 'Fehler', __typename: 'SpellCheckStepNode' }, { sentence: 'Hir ist ein Feler gewesen', offset: 18, length: 7, affected: 'gewesen', corrected: 'gewesen.', __typename: 'SpellCheckStepNode' }], __typename: 'SpellCheckPayload' } } } }); cy.apolloLogin('rahel.cueni', 'test'); cy.visit('/module/lohn-und-budget/'); cy.get('.spellcheck__correction').should('have.length', 0); cy.get('.submission-form-container__spellcheck').click(); cy.get('.spellcheck__correction').should('have.length', 3); }); });