mirror of https://github.com/logseq/logseq
test: add some tests
parent
f0af0f05dd
commit
69fa58ff9c
|
@ -1 +1 @@
|
||||||
{}
|
{"defaultCommandTimeout": 10000}
|
||||||
|
|
|
@ -1,10 +1,52 @@
|
||||||
(ns app.window
|
(ns app.window
|
||||||
(:require-macros [latte.core :refer [describe beforeEach it]]))
|
(:require-macros [latte.core :refer [describe beforeEach before it]])
|
||||||
|
(:require [latte.chai :refer (expect)])
|
||||||
|
(:refer-clojure :exclude [first get]))
|
||||||
|
|
||||||
(def cy js/cy)
|
(def cy js/cy)
|
||||||
|
|
||||||
|
(defn back-to-home
|
||||||
|
[]
|
||||||
|
(.. cy (get ".cp__header-logo")
|
||||||
|
(first)
|
||||||
|
(click)))
|
||||||
|
|
||||||
|
(defn edit-block
|
||||||
|
[content]
|
||||||
|
(.. cy (get "textarea")
|
||||||
|
(first)
|
||||||
|
(click)
|
||||||
|
(type content)))
|
||||||
|
|
||||||
|
|
||||||
(describe "Window"
|
(describe "Window"
|
||||||
(beforeEach []
|
(beforeEach []
|
||||||
(.visit cy "https://example.cypress.io/commands/window"))
|
(.clearIndexedDB cy))
|
||||||
(it "cy.window() - get the global window object" []
|
(before []
|
||||||
(.should (.window cy) "have.property" "top")))
|
(.visit cy "http://localhost:3001"))
|
||||||
|
|
||||||
|
(it "Search" []
|
||||||
|
(.. cy
|
||||||
|
(get "#search-field")
|
||||||
|
(click)
|
||||||
|
(type "welcome to Logseq"))
|
||||||
|
(.. cy (get "#ui__ac-inner")
|
||||||
|
(should (fn [result]
|
||||||
|
(expect result :to.have.length 1))))
|
||||||
|
(back-to-home)
|
||||||
|
|
||||||
|
;; create new page
|
||||||
|
(.. cy
|
||||||
|
(get "#search-field")
|
||||||
|
(click)
|
||||||
|
(type "new page"))
|
||||||
|
|
||||||
|
(.wait cy 1000)
|
||||||
|
|
||||||
|
(.. cy
|
||||||
|
(get "#search-field")
|
||||||
|
(type "{enter}"))
|
||||||
|
|
||||||
|
;; edit bullet
|
||||||
|
(edit-block "this is my first bullet {enter}")
|
||||||
|
(edit-block "this is my second bullet {enter}")))
|
||||||
|
|
|
@ -23,3 +23,22 @@
|
||||||
//
|
//
|
||||||
// -- This will overwrite an existing command --
|
// -- This will overwrite an existing command --
|
||||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||||
|
|
||||||
|
Cypress.Commands.add('clearIndexedDB', async () => {
|
||||||
|
const databases = await window.indexedDB.databases();
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
databases.map(
|
||||||
|
({ name }) =>
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
const request = window.indexedDB.deleteDatabase(name);
|
||||||
|
|
||||||
|
request.addEventListener('success', resolve);
|
||||||
|
// Note: we need to also listen to the "blocked" event
|
||||||
|
// (and resolve the promise) due to https://stackoverflow.com/a/35141818
|
||||||
|
request.addEventListener('blocked', resolve);
|
||||||
|
request.addEventListener('error', reject);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue