浏览代码

fix(test): do not prompt filename change

Andelf 2 年之前
父节点
当前提交
7b7c766260
共有 4 个文件被更改,包括 17 次插入1 次删除
  1. 10 0
      e2e-tests/fixtures.ts
  2. 1 1
      e2e-tests/page-search.spec.ts
  3. 1 0
      src/main/frontend/handler/events.cljs
  4. 5 0
      src/main/frontend/util.cljc

+ 10 - 0
e2e-tests/fixtures.ts

@@ -70,6 +70,16 @@ base.beforeAll(async () => {
   console.log("Test start with:", info)
 
   page = await electronApp.firstWindow()
+
+  // inject testing flags
+  await page.evaluate(
+    () => {
+      Object.assign(window, {
+        __E2E_TESTING__: true,
+      })
+    },
+  )
+
   // Direct Electron console to watcher
   page.on('console', consoleLogWatcher)
   page.on('crash', () => {

+ 1 - 1
e2e-tests/page-search.spec.ts

@@ -41,8 +41,8 @@ import { IsMac, createRandomPage, newBlock, newInnerBlock, randomString, lastBlo
   const results = await page.$$('#ui__ac-inner>div')
   expect(results.length).toBeGreaterThan(3) // 2 blocks + 1 page + 2 page content
   await page.keyboard.press("Escape")
-  await page.keyboard.press("Escape")
   await page.waitForTimeout(1000) // wait for modal disappear
+  await page.keyboard.press("Escape")
 })
 
 async function alias_test(page: Page, page_name: string, search_kws: string[]) {

+ 1 - 0
src/main/frontend/handler/events.cljs

@@ -369,6 +369,7 @@
      (fn []
        (let [filename-format (state/get-filename-format repo)]
          (when (and (util/electron?)
+                    (not (util/ci?))
                     (not (config/demo-graph?))
                     (not= filename-format :triple-lowbar))
            (state/pub-event! [:ui/notify-outdated-filename-format []]))))

+ 5 - 0
src/main/frontend/util.cljc

@@ -113,6 +113,11 @@
      []
      (when (electron?) (. js/window -__MOCKED_OPEN_DIR_PATH__))))
 
+#?(:cljs
+   (defn ci?
+     []
+     (boolean (. js/window -__E2E_TESTING__))))
+
 #?(:cljs
    (do
      (def nfs? (and (not (electron?))