-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from breakthestatic/main
Add option to prevent swipe navigation within subviews
- Loading branch information
Showing
6 changed files
with
134 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
swipe_nav: | ||
logger_level: verbose | ||
enable_on_subviews: false | ||
|
||
views: | ||
|
||
- title: View 1 | ||
cards: | ||
- type: markdown | ||
title: View 1 | ||
content: Content... | ||
- type: button | ||
name: Go to subview | ||
icon: mdi:chevron-right | ||
icon_height: 32px | ||
show_name: true | ||
show_icon: true | ||
tap_action: | ||
action: navigate | ||
navigation_path: /subview-noswipe/1 | ||
|
||
|
||
- title: Subview | ||
subview: true | ||
cards: | ||
- type: markdown | ||
title: Subview | ||
content: Content... | ||
- type: button | ||
name: Go to subview | ||
icon: mdi:subdirectory-arrow-right | ||
icon_height: 32px | ||
show_name: true | ||
show_icon: true | ||
tap_action: | ||
action: navigate | ||
navigation_path: /subview-noswipe/1 | ||
|
||
- title: View 3 | ||
cards: | ||
- type: markdown | ||
title: View 3 | ||
content: Content... | ||
- type: button | ||
name: Go to subview | ||
icon: mdi:chevron-right | ||
icon_height: 32px | ||
show_name: true | ||
show_icon: true | ||
tap_action: | ||
action: navigate | ||
navigation_path: /subview-noswipe/1 | ||
|
||
- title: View 4 | ||
cards: | ||
- type: markdown | ||
title: View 4 | ||
content: Content... | ||
- type: button | ||
name: Go to subview | ||
icon: mdi:chevron-right | ||
icon_height: 32px | ||
show_name: true | ||
show_icon: true | ||
tap_action: | ||
action: navigate | ||
navigation_path: /subview-noswipe/1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tests/dashboards/individual-dashboards/subview-noswipe.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import { SwipeHelper } from "../../helpers/touchHelpers"; | ||
|
||
test("shouldn't change, no swipe on subview", async ({ page }) => { | ||
const dashboardPath = "/subview-noswipe" | ||
await page.goto(dashboardPath + "/1"); | ||
await expect(page).toHaveURL(dashboardPath + "/1"); | ||
|
||
const haAppLayout = page.locator("[id='view']"); | ||
|
||
const consoleLogs: string[] = []; | ||
page.on("console", (message) => { | ||
consoleLogs.push(message.text()); | ||
}); | ||
|
||
await SwipeHelper.swipeLeft(haAppLayout); | ||
await expect(page).toHaveURL(dashboardPath + "/1"); | ||
|
||
await SwipeHelper.swipeRight(haAppLayout); | ||
await expect(page).toHaveURL(dashboardPath + "/1"); | ||
|
||
let matches = 0; | ||
const regexp = /.*Ignoring touch: Swipe navigation on subviews is disabled in the config.*/; | ||
for (const log of consoleLogs) { | ||
if (regexp.test(log)) { matches++; } | ||
} | ||
expect(matches).toBe(2); | ||
}); |