|
| 1 | +// platform-ui/cypress/e2e/add-content.cy.js |
| 2 | +describe('Content Authoring', () => { |
| 3 | + let username; |
| 4 | + const courseName = `Content Test Course ${Math.floor(Math.random() * 10000)}`; |
| 5 | + const courseDescription = 'This course is for testing content creation functionality'; |
| 6 | + |
| 7 | + Cypress.on('uncaught:exception', (err, runnable) => { |
| 8 | + // returning false here prevents Cypress from |
| 9 | + // failing the test |
| 10 | + return false; |
| 11 | + }); |
| 12 | + |
| 13 | + it('should allow a user to create and navigate to a course for adding content', () => { |
| 14 | + // Register a new user |
| 15 | + cy.registerUser().then((user) => { |
| 16 | + username = user; |
| 17 | + // Wait for registration to complete and redirect |
| 18 | + cy.url().should('include', `/u/${username}/new`); |
| 19 | + |
| 20 | + // Navigate to the quilts (courses) page |
| 21 | + cy.visit('/quilts'); |
| 22 | + |
| 23 | + // Create a new course |
| 24 | + cy.get('[data-cy="create-course-fab"]').click(); |
| 25 | + cy.get('[data-cy="course-name-input"]').type(courseName); |
| 26 | + cy.get('[data-cy="course-description-input"]').type(courseDescription); |
| 27 | + cy.get('[data-cy="private-radio"]').click(); // Create as private course initially |
| 28 | + cy.get('[data-cy="save-course-button"]').click(); |
| 29 | + |
| 30 | + // Wait for creation to complete and dialog to close |
| 31 | + cy.wait(1000); |
| 32 | + |
| 33 | + cy.visit(`/quilts/${courseName.replaceAll(' ', '_')}`); |
| 34 | + |
| 35 | + // Register via `register` button, then wait |
| 36 | + cy.get('[data-cy="register-btn"]').click(); |
| 37 | + cy.wait(1000); |
| 38 | + |
| 39 | + // click `add content` button |
| 40 | + cy.get('[data-cy="add-content-btn"]').click(); |
| 41 | + cy.wait(1000); |
| 42 | + |
| 43 | + cy.get('[data-cy="markdown-input"] textarea') |
| 44 | + .should('be.visible') |
| 45 | + .type('This {{ is || is not }} a question.', { |
| 46 | + parseSpecialCharSequences: false, |
| 47 | + }); |
| 48 | + cy.get('[data-cy="add-card-btn"').click(); |
| 49 | + }); |
| 50 | + }); |
| 51 | +}); |
0 commit comments