|
| 1 | +/** |
| 2 | + * Smoke test for docs site embedded course functionality |
| 3 | + * |
| 4 | + * Ensures that: |
| 5 | + * - The embedded course loads without "not found" errors |
| 6 | + * - The data layer initializes correctly |
| 7 | + * - Study sessions can be started |
| 8 | + * - Cards load successfully |
| 9 | + */ |
| 10 | + |
| 11 | +describe('Docs Site - Embedded Course', () => { |
| 12 | + beforeEach(() => { |
| 13 | + // Visit the embedded course test page |
| 14 | + cy.visit('/vue-skuilder/dbg/embedded-course-test.html'); |
| 15 | + }); |
| 16 | + |
| 17 | + it('should load the embedded course without "not found" errors', () => { |
| 18 | + // Capture console errors |
| 19 | + const consoleErrors: string[] = []; |
| 20 | + |
| 21 | + cy.window().then((win) => { |
| 22 | + cy.stub(win.console, 'error').callsFake((...args) => { |
| 23 | + const message = args.join(' '); |
| 24 | + consoleErrors.push(message); |
| 25 | + }); |
| 26 | + }); |
| 27 | + |
| 28 | + // Wait for the data layer to initialize |
| 29 | + cy.contains('Interactive study session', { timeout: 10000 }).should('be.visible'); |
| 30 | + |
| 31 | + // Check for "not found" errors in console |
| 32 | + cy.window().then(() => { |
| 33 | + const notFoundErrors = consoleErrors.filter(msg => |
| 34 | + msg.toLowerCase().includes('not found') |
| 35 | + ); |
| 36 | + |
| 37 | + if (notFoundErrors.length > 0) { |
| 38 | + throw new Error(`Found "not found" errors in console:\n${notFoundErrors.join('\n')}`); |
| 39 | + } |
| 40 | + }); |
| 41 | + }); |
| 42 | + |
| 43 | + it('should start a study session and load cards without errors', () => { |
| 44 | + // Capture console errors |
| 45 | + const consoleErrors: string[] = []; |
| 46 | + |
| 47 | + cy.window().then((win) => { |
| 48 | + cy.stub(win.console, 'error').callsFake((...args) => { |
| 49 | + const message = args.join(' '); |
| 50 | + consoleErrors.push(message); |
| 51 | + }); |
| 52 | + }); |
| 53 | + |
| 54 | + // Wait for initialization |
| 55 | + cy.contains('Interactive study session', { timeout: 10000 }).should('be.visible'); |
| 56 | + |
| 57 | + // Wait for the "Start Session" button to appear and click it |
| 58 | + cy.contains('button', 'Start Session', { timeout: 10000 }) |
| 59 | + .should('be.visible') |
| 60 | + .click(); |
| 61 | + |
| 62 | + // Wait for the init state to disappear (button should be gone) |
| 63 | + cy.contains('button', 'Start Session').should('not.exist'); |
| 64 | + |
| 65 | + // Verify we're not in loading state |
| 66 | + cy.contains('Loading course').should('not.exist'); |
| 67 | + |
| 68 | + // Give it a moment for card hydration |
| 69 | + cy.wait(2000); |
| 70 | + |
| 71 | + // Check for "not found" errors in console after session start |
| 72 | + cy.window().then(() => { |
| 73 | + const notFoundErrors = consoleErrors.filter(msg => |
| 74 | + msg.toLowerCase().includes('not found') |
| 75 | + ); |
| 76 | + |
| 77 | + if (notFoundErrors.length > 0) { |
| 78 | + throw new Error(`Found "not found" errors in console after session start:\n${notFoundErrors.join('\n')}`); |
| 79 | + } |
| 80 | + }); |
| 81 | + |
| 82 | + // Verify no error state is shown |
| 83 | + cy.contains('Initialization failed').should('not.exist'); |
| 84 | + cy.contains('Error:').should('not.exist'); |
| 85 | + }); |
| 86 | + |
| 87 | + it('should load the remote course test page', () => { |
| 88 | + // Test the remote course embedding as well |
| 89 | + cy.visit('/vue-skuilder/dbg/remote-crs-embedding.html'); |
| 90 | + |
| 91 | + const consoleErrors: string[] = []; |
| 92 | + |
| 93 | + cy.window().then((win) => { |
| 94 | + cy.stub(win.console, 'error').callsFake((...args) => { |
| 95 | + const message = args.join(' '); |
| 96 | + consoleErrors.push(message); |
| 97 | + }); |
| 98 | + }); |
| 99 | + |
| 100 | + // Wait for initialization |
| 101 | + cy.contains('Interactive study session', { timeout: 10000 }).should('be.visible'); |
| 102 | + |
| 103 | + // Check for "not found" errors |
| 104 | + cy.window().then(() => { |
| 105 | + const notFoundErrors = consoleErrors.filter(msg => |
| 106 | + msg.toLowerCase().includes('not found') |
| 107 | + ); |
| 108 | + |
| 109 | + if (notFoundErrors.length > 0) { |
| 110 | + throw new Error(`Found "not found" errors in remote course test:\n${notFoundErrors.join('\n')}`); |
| 111 | + } |
| 112 | + }); |
| 113 | + }); |
| 114 | +}); |
0 commit comments