Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: navigate to page from athena when result is for a block #2025

Merged
merged 9 commits into from
Feb 21, 2022
18 changes: 12 additions & 6 deletions src/cljs/athens/views/athena.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@
;; else open in main view
:else
(do (dispatch [:athena/toggle])
(router/navigate-page (:node/title item))
(if (:node/title item)
(router/navigate-page (:node/title item))
(router/navigate-uid (:block/uid item)))
(dispatch [:editing/uid (:block/uid item)])))

(= key KeyCodes.UP)
Expand Down Expand Up @@ -298,10 +300,11 @@
[:div (use-style results-list-style)
(doall
(for [[i x] (map-indexed list results)
:let [parent (:block/parent x)
title (or (:node/title parent) (:node/title x))
uid (or (:block/uid parent) (:block/uid x))
string (:block/string x)]]
:let [block-uid (:block/uid x)
parent (:block/parent x)
title (or (:node/title parent) (:node/title x))
uid (or (:block/uid parent) (:block/uid x))
string (:block/string x)]]
(if (nil? x)
^{:key i}
[:div (use-style result-style {:on-click (fn [_]
Expand All @@ -325,7 +328,10 @@
:query query}]
(dispatch [:athena/toggle])
(dispatch [:athena/update-recent-items selected-page])
(router/navigate-page title e)))
(if parent
(router/navigate-uid block-uid)
(router/navigate-page title e))))

:class (when (= i index) "selected")})
[:div (use-style result-body-style)

Expand Down
54 changes: 54 additions & 0 deletions test/e2e/athena-navigation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { expect } from '@playwright/test';
import { test } from './electron-test';

test('athena create new page then enter', async ({ page }) => {

// Click button:has-text("Find or create a page")
await page.click('button:has-text("Find or create a page")');
// Fill [placeholder="Find or Create Page"]
await page.fill('[placeholder="Find or Create Page"]', 'arst');
// Press Enter
await Promise.all([
page.press('[placeholder="Find or Create Page"]', 'Enter')]);
await expect(page.locator(".node-page > header > h1 > textarea")).toHaveValue('arst');

});

test('athena create new page then click create page', async ({ page }) => {

// Click button:has-text("Find or create a page")
await page.click('button:has-text("Find or create a page")');
// Fill [placeholder="Find or Create Page"]
await page.fill('[placeholder="Find or Create Page"]', 'arst');
// Click text=Create Page: arst
await Promise.all([
page.click('text=Create Page: arst')]);
await expect(page.locator(".node-page > header > h1 > textarea")).toHaveValue('arst');
});

test('athena search block then enter on result', async ({ page }) => {
// Click button:has-text("Find or create a page")
await page.click('button:has-text("Find or create a page")');
// Fill [placeholder="Find or Create Page"]
await page.fill('[placeholder="Find or Create Page"]', 'welcome');
// Press ArrowDown
await page.press('[placeholder="Find or Create Page"]', 'ArrowDown');
// Press ArrowDown
await page.press('[placeholder="Find or Create Page"]', 'ArrowDown');
// Press Enter
await page.press('[placeholder="Find or Create Page"]', 'Enter');
Comment on lines +33 to +39
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like common operations, good place to create util functions.


await expect(page.locator(".block-page > h1 > textarea")).toHaveValue('Welcome to Athens, Open-Source Networked Thought!');
});

test('athena search block then click on result', async ({ page }) => {
// Click button:has-text("Find or create a page")
await page.click('button:has-text("Find or create a page")');
// Fill [placeholder="Find or Create Page"]
await page.fill('[placeholder="Find or Create Page"]', 'welcome');
// Click text=WelcomeWelcome to Athens, Open-Source Networked Thought!
await page.click('text=WelcomeWelcome to Athens, Open-Source Networked Thought!');
await expect(page.locator(".block-page > h1 > textarea")).toHaveValue('Welcome to Athens, Open-Source Networked Thought!');

});