From b0b13c2d1ea4ca1a5568c06ec80c995cd6cea641 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 15 Sep 2023 01:53:46 +0530 Subject: [PATCH] Fix tests --- cypress/e2e/diagramUpdate.spec.ts | 2 +- cypress/e2e/util.ts | 16 +++++++++------- cypress/snapshots.js | 2 +- src/lib/components/History/history.test.ts | 1 + 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cypress/e2e/diagramUpdate.spec.ts b/cypress/e2e/diagramUpdate.spec.ts index 42a4780c..d2ca433c 100644 --- a/cypress/e2e/diagramUpdate.spec.ts +++ b/cypress/e2e/diagramUpdate.spec.ts @@ -52,7 +52,7 @@ describe('Auto sync tests', () => { it('supports commenting code out/in', () => { cy.get('#editor').contains('Car').click(); - cy.type(`${cmd}/`); + cy.get('#editor').get('textarea').type(`${cmd}/`, { force: true }); cy.get('#view').contains('Car').should('not.exist'); typeInEditor(`{uparrow}${cmd}/`); diff --git a/cypress/e2e/util.ts b/cypress/e2e/util.ts index 8a48e9cb..57a9f54b 100644 --- a/cypress/e2e/util.ts +++ b/cypress/e2e/util.ts @@ -11,13 +11,15 @@ export const typeInEditor = ( ) => { cy.window().should('have.property', 'editorLoaded', true); cy.get('#editor').click(); - if (bottom) { - cy.type('{pageDown}'); - } - if (newline) { - cy.type('{enter}'); - } - cy.type(text); + cy.get('#editor').within(($editor) => { + if (bottom) { + cy.get('textarea').type('{pageDown}', { force: true }); + } + if (newline) { + cy.get('textarea').type('{enter}', { force: true }); + } + cy.get('textarea').type(text, { force: true }); + }); }; const downloadsFolder = Cypress.config('downloadsFolder'); diff --git a/cypress/snapshots.js b/cypress/snapshots.js index fa9609e4..350eafa3 100644 --- a/cypress/snapshots.js +++ b/cypress/snapshots.js @@ -16,7 +16,7 @@ module.exports = { "1": "{\"code\":\"graph TD\\n A[Party] -->|Get money| B(Go shopping!!)\\n \",\"mermaid\":\"{\\n \\\"theme\\\": \\\"forest\\\",\\n \\\"test\\\": \\\"hello world\\\"\\n}\",\"autoSync\":true,\"updateDiagram\":true,\"loader\":{\"type\":\"files\",\"config\":{\"codeURL\":\"https://gist.githubusercontent.com/sidharthv96/6268a23e673a533dcb198f241fd7012a/raw/4eb03887e6a41397e80bdcdbf94017c498f8f1e2/code.mmd\",\"configURL\":\"https://gist.githubusercontent.com/sidharthv96/6268a23e673a533dcb198f241fd7012a/raw/4eb03887e6a41397e80bdcdbf94017c498f8f1e2/config.json\"}}}" } }, - "__version": "12.9.0", + "__version": "12.17.4", "Auto sync tests": { "should dim diagram when code is edited": { "1": "{\"code\":\"flowchart TD\\n A[Christmas] -->|Get money| B(Go shopping)\\n B --> C{Let me think}\\n C -->|One| D[Laptop]\\n C -->|Two| E[iPhone]\\n C -->|Three| F[fa:fa-car Car]\\n C --> Test\",\"mermaid\":\"{\\n \\\"theme\\\": \\\"default\\\"\\n}\",\"autoSync\":false,\"updateDiagram\":false}" diff --git a/src/lib/components/History/history.test.ts b/src/lib/components/History/history.test.ts index ec669738..7a3ead34 100644 --- a/src/lib/components/History/history.test.ts +++ b/src/lib/components/History/history.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ import type { HistoryEntry } from '$lib/types'; import { describe, it, expect } from 'vitest'; import {