|
| 1 | +describe('The Editor', () => { |
| 2 | + it('displays the version selection', () => { |
| 3 | + cy.visit('/') |
| 4 | + cy.get("nav>*>select[name='leanVersion']").select('mathlib-demo') |
| 5 | + cy.iframe().contains('mathlib-demo.lean').should('exist') |
| 6 | + cy.get('.dropdown>.nav-link>.fa-bars').click() |
| 7 | + cy.contains('.nav-link', 'Lean Info').click() |
| 8 | + cy.containsAll('.modal', [ |
| 9 | + 'mathlibLatest', |
| 10 | + 'leanprover/lean4', |
| 11 | + 'mathlib', |
| 12 | + 'aesop' |
| 13 | + ]).find('.modal-close').click() |
| 14 | + |
| 15 | + cy.get("nav>*>select[name='leanVersion']").select('stable') |
| 16 | + cy.iframe().contains('stable.lean').should('exist') |
| 17 | + cy.get('.dropdown>.nav-link>.fa-bars').click() |
| 18 | + cy.contains('.nav-link', 'Lean Info').click() |
| 19 | + cy.containsAll('.modal', [ |
| 20 | + 'leanprover/lean4:stable', |
| 21 | + '(no dependencies)' |
| 22 | + ]).find('.modal-close').click() |
| 23 | + }) |
| 24 | + |
| 25 | + it('handles unicode correctly', () => { |
| 26 | + cy.visit('/') |
| 27 | + cy.get('div.view-lines').type('\\Omega = \\sum') |
| 28 | + cy.contains('div.view-lines', 'Ω = ∑').should('have.attr', 'style').and('include', 'JuliaMono') |
| 29 | + cy.get('.squiggly-error').should('exist') |
| 30 | + cy.iframe().contains('unexpected identifier; expected command').should('exist') |
| 31 | + }) |
| 32 | + |
| 33 | + it('handles input from url', () => { |
| 34 | + cy.visit('/#codez=pXAAILwoiERA') |
| 35 | + cy.contains('div.view-line', 'Ω = ∑').should('exist') |
| 36 | + cy.get('.squiggly-error').should('exist') |
| 37 | + cy.iframe().contains('unexpected identifier; expected command').should('exist') |
| 38 | + }) |
| 39 | + |
| 40 | + it('loads example correctly on mobile', () => { |
| 41 | + cy.viewport(550, 750) |
| 42 | + cy.visit('/') |
| 43 | + cy.get('.dropdown>.nav-link>.fa-bars').click() |
| 44 | + cy.contains('.dropdown .dropdown', 'Examples').click() |
| 45 | + cy.contains('.nav-link', 'Logic').click() |
| 46 | + cy.containsAll(['import Mathlib.Logic.Basic', 'variable (P Q : Prop)']).should('exist') |
| 47 | + }) |
| 48 | + |
| 49 | + it('loads example correctly on desktop', () => { |
| 50 | + cy.visit('/') |
| 51 | + cy.contains('.nav-link', 'Examples').click() |
| 52 | + cy.contains('.nav-link', 'Logic').click() |
| 53 | + cy.containsAll(['import Mathlib.Logic.Basic', 'variable (P Q : Prop)']).should('exist') |
| 54 | + }) |
| 55 | + |
| 56 | + it('displays correct infoview state', () => { |
| 57 | + cy.visit('/') |
| 58 | + cy.get('div.view-lines').type('example (P: Prop) : P \\or \\not P := by ') |
| 59 | + |
| 60 | + cy.iframe().containsAll([ |
| 61 | + 'Tactic state', |
| 62 | + '1 goal', |
| 63 | + 'P : Prop', |
| 64 | + '⊢ P ∨ ¬P', |
| 65 | + 'unexpected end of input' |
| 66 | + ]).should('exist') |
| 67 | + |
| 68 | + cy.contains('div.view-lines', 'P := by').type('exact Classical.em P') |
| 69 | + cy.iframe().containsAll('details', ['Tactic state', 'No goals']).should('exist') |
| 70 | + cy.iframe().contains('details', 'Expected type').should('not.be.open').click() |
| 71 | + cy.iframe().containsAll('details', ['P : Prop', '⊢ Prop']).should('be.open') |
| 72 | + }) |
| 73 | + |
| 74 | + it('displays correct hover tooltips', () => { |
| 75 | + cy.visit('/#codez=KYDwhgtgDgNsAEAKACgLnsgTgeygSnnWXkAoieAGo0IF54AjAT3lDAGMAXeAYRjAGc+AS1ZgYAOmAQMQA') |
| 76 | + cy.iframe().contains('Expected type').should('exist') |
| 77 | + cy.get('.cgmr.codicon').should('not.exist') |
| 78 | + cy.get('div.view-lines').realClick() |
| 79 | + cy.iframe().contains('No goals').should('exist') |
| 80 | + |
| 81 | + cy.contains('div.view-line span', 'example').should('exist').then(($el) => cy.wrap($el).realHover()) |
| 82 | + cy.contains('div.monaco-hover-content', '_example (P : Prop) : P ∨ ¬P').should('be.visible') |
| 83 | + |
| 84 | + cy.contains('div.view-line span', 'by').should('exist').then(($el) => cy.wrap($el).realHover()) |
| 85 | + cy.contains( |
| 86 | + 'div.monaco-hover-content', |
| 87 | + 'by tac constructs a term of the expected type by running the tactic(s) tac.' |
| 88 | + ).should('be.visible') |
| 89 | + }) |
| 90 | + |
| 91 | + it('displays and handles code completion', () => { |
| 92 | + cy.visit('/') |
| 93 | + cy.iframe().contains('All Messages (0)').should('exist') |
| 94 | + cy.get('.cgmr.codicon').should('not.exist') |
| 95 | + cy.get('div.view-line').type('example (P: Prop) : P \\or \\not P := by appl', { delay: 100 }) |
| 96 | + cy.containsAll('div.monaco-editor', ['by appl', 'apply?']).should('exist') |
| 97 | + .then(() => { |
| 98 | + cy.contains('div.view-line', 'by appl').type('{downArrow}{shift+enter}', { delay: 100 }) |
| 99 | + cy.contains('div.view-line', 'apply?').should('exist') |
| 100 | + }) |
| 101 | + cy.get('.squiggly-info').should('exist') |
| 102 | + }) |
| 103 | + |
| 104 | + it('displays and accetps quickfixes inline', () => { |
| 105 | + const modBtn = Cypress.platform === 'darwin' ? 'Meta' : 'Control' |
| 106 | + cy.visit('/') |
| 107 | + cy.get('div.view-line').type('example (P: Prop) : P \\or \\not P := by apply?') |
| 108 | + cy.contains('div.view-line', 'apply?').should('exist') |
| 109 | + cy.get('.squiggly-info').should('exist') |
| 110 | + cy.realPress([modBtn, '.']) |
| 111 | + cy.contains('.action-widget', 'Try this: exact Classical.em P').should('exist') |
| 112 | + cy.realPress([modBtn, '.']) |
| 113 | + cy.contains('div.view-line', 'exact Classical.em P').should('exist') |
| 114 | + }) |
| 115 | + |
| 116 | + it('displays and accetps suggestions from infoview', () => { |
| 117 | + cy.visit('/') |
| 118 | + cy.get('div.view-line').type('example (P: Prop) : P \\or \\not P := by apply?') |
| 119 | + cy.iframe().contains("span[title='Apply suggestion']", 'exact Classical.em P').click() |
| 120 | + cy.contains('div.view-line', 'exact Classical.em P').should('exist') |
| 121 | + }) |
| 122 | + |
| 123 | + it('loads from Zulip message on desktop', () => { |
| 124 | + cy.fixture('zulip-msg-1.txt').as('zulipMsg') |
| 125 | + cy.visit('/') |
| 126 | + cy.frameLoaded() |
| 127 | + cy.contains('.nav-link', 'Load').click() |
| 128 | + cy.contains('.nav-link', 'Load Zulip Message').click() |
| 129 | + cy.get('@zulipMsg').should('include', 'An example snippet').then(($msg) => { |
| 130 | + cy.get('.modal>form>textarea').invoke('val', $msg).then(() => { |
| 131 | + cy.get(".modal>form>input[value='Parse message']").should('exist').click() |
| 132 | + }) |
| 133 | + }) |
| 134 | + cy.containsAll('.view-lines', ['#eval Lean.toolchain', '#check Classical.em']).should('exist') |
| 135 | + cy.iframe().contains('Restart File').should('exist').click() |
| 136 | + cy.iframe().contains('details', 'All Messages (2)').should('exist').click() |
| 137 | + cy.iframe().containsAll('body', [ |
| 138 | + 'All Messages (2)', |
| 139 | + 'leanprover/lean4', |
| 140 | + 'Classical.em (p : Prop) : p ∨ ¬p' |
| 141 | + ]).should('exist') |
| 142 | + }) |
| 143 | + |
| 144 | + it('handles custom lead character', () => { |
| 145 | + cy.visit('/') |
| 146 | + cy.iframe().contains('All Messages (0)').should('exist') |
| 147 | + cy.get('.cgmr.codicon').should('not.exist') |
| 148 | + cy.get('.dropdown>.nav-link>.fa-bars').click() |
| 149 | + cy.contains('.nav-link', 'Settings').click() |
| 150 | + cy.get('input#abbreviationCharacter').type(`{backspace}\${enter}`) |
| 151 | + cy.iframe().contains('All Messages (0)').should('exist') |
| 152 | + cy.get('.cgmr.codicon').should('not.exist') |
| 153 | + cy.get('div.view-line').type('example ($tau) : $tau $or $not $tau := by exact Classical.em $tau ') |
| 154 | + cy.contains('div.view-line', 'example (τ) : τ ∨ ¬ τ := by exact Classical.em τ').should('exist') |
| 155 | + cy.iframe().contains('No goals').should('exist').then(() => { |
| 156 | + cy.contains('div.view-line span', 'τ').realHover({ position: "center" }) |
| 157 | + cy.contains( |
| 158 | + 'div.monaco-hover-content', |
| 159 | + 'Type τ using $ta or $tau' |
| 160 | + ).should('be.visible') |
| 161 | + }) |
| 162 | + }) |
| 163 | + |
| 164 | + it('can switch themes', () => { |
| 165 | + cy.visit('/') |
| 166 | + cy.iframe().contains('All Messages (0)').should('exist') |
| 167 | + cy.get('.monaco-editor').should('exist').then(($editor) => { |
| 168 | + const oldBg = $editor.css('background-color') |
| 169 | + cy.get('.dropdown>.nav-link>.fa-bars').click() |
| 170 | + cy.contains('.nav-link', 'Settings').click() |
| 171 | + cy.get("select#theme option").not(':selected').first().invoke('val').then(($newVal) => { |
| 172 | + cy.get("select#theme").select($newVal).should(() => { |
| 173 | + const newBg = $editor.css('background-color') |
| 174 | + expect(newBg).to.not.eq(oldBg) |
| 175 | + }) |
| 176 | + }) |
| 177 | + }) |
| 178 | + }) |
| 179 | + |
| 180 | + it('shows correct go-to definitions', () => { |
| 181 | + const isOnDarwin = Cypress.platform === 'darwin' |
| 182 | + const alertShown = cy.stub().as("alertShown") |
| 183 | + cy.on('window:confirm', alertShown) |
| 184 | + cy.visit('/') |
| 185 | + cy.get('div.view-line').type('#check Classical.em') |
| 186 | + cy.contains('div.view-line span', 'Classical.em').as('defToCheck').should('exist') |
| 187 | + cy.get('@defToCheck').realClick({ ctrlKey: !isOnDarwin, metaKey: isOnDarwin }) |
| 188 | + cy.get("@alertShown").should("have.been.calledOnce") |
| 189 | + .and('have.been.calledWithMatch', /Do you want to open the docs\?\s+\/Init\/Classical/gm) |
| 190 | + }) |
| 191 | +}) |
0 commit comments