Skip to content

Commit 77144fc

Browse files
committed
test: add e2e tests for re-opening file in presentation viewer (#11)
1 parent e578746 commit 77144fc

File tree

6 files changed

+68
-4
lines changed

6 files changed

+68
-4
lines changed

tests/e2e/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const config = {
1010
minTimeout: parseInt(process.env.MIN_TIMEOUT) || 5,
1111
headless: process.env.HEADLESS === 'true',
1212
debug: process.env.DEBUG === 'true',
13-
targetServer: process.env.TARGET_SERVER.toLowerCase() || 'ocis'
13+
targetServer: (process.env.TARGET_SERVER || 'ocis').toLowerCase()
1414
}
1515

1616
module.exports = config

tests/e2e/features/presentationViewer.feature

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Feature: markdown presentation viewer
99

1010

1111
Scenario: preview markdown file in presentation viewer
12-
When user "admin" previews a markdown file "test-markdown.md" in presentation viewer
12+
When user "admin" previews markdown file "test-markdown.md" in presentation viewer
1313
Then markdown file "test-markdown.md" should be opened in the presentation viewer
1414
And the content of the current slide should be "PRESENTATION VIEWER"
1515
# change slide with button in UI
@@ -21,4 +21,14 @@ Feature: markdown presentation viewer
2121
When user "admin" navigates to the next slide using keyboard
2222
Then the content of the current slide should be "An extension for OpenCloud & ownCloud Infinite Scale (oCIS) that allows users to create slide presentations directly from markdown files."
2323
When user "admin" navigates to the previous slide using keyboard
24-
Then the content of the current slide should be "PRESENTATION VIEWER"
24+
Then the content of the current slide should be "PRESENTATION VIEWER"
25+
26+
Scenario: re-open markdown file in presentation viewer after opening in text editor
27+
When user "admin" previews markdown file "test-markdown.md" in presentation viewer
28+
Then markdown file "test-markdown.md" should be opened in the presentation viewer
29+
And the content of the current slide should be "PRESENTATION VIEWER"
30+
When user "admin" opens file "test-markdown.md" in text editor using sidebar panel
31+
Then file "test-markdown.md" should be opened in the text editor
32+
When user "admin" previews markdown file "test-markdown.md" in presentation viewer using sidebar panel
33+
Then markdown file "test-markdown.md" should be opened in the presentation viewer
34+
And the content of the current slide should be "PRESENTATION VIEWER"

tests/e2e/pageObjects/FilesPage.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
const Ocis = require('./OcisPage')
22
const config = require('../config')
3+
const { openActionFromSidebarPanel } = require('../utils/presentationViewer')
34

45
class Files {
56
constructor() {
67
this.contextMenuBtnSelector = '[class*=-btn-action-dropdown]'
78
this.openInPresentationViewerBtnSelector = '.oc-files-actions-presentation-viewer-trigger'
89
this.openWithBtnSelector = 'button[id^="oc-files-context-actions-open-with-toggle"]'
10+
this.openInTextEditorBtnSelector = '.oc-files-actions-text-editor-trigger'
911
}
1012

1113
async openMDFileInPresentationViewer() {
@@ -15,6 +17,16 @@ class Files {
1517
}
1618
await page.click(this.openInPresentationViewerBtnSelector)
1719
}
20+
21+
async openMDFileInTextEditorUsingSidebarPanel(fileName) {
22+
await openActionFromSidebarPanel()
23+
await page.click(this.openInTextEditorBtnSelector)
24+
}
25+
26+
async openMDFileInPresentationViewerUsingSidebarPanel(fileName) {
27+
await openActionFromSidebarPanel()
28+
await page.click(this.openInPresentationViewerBtnSelector)
29+
}
1830
}
1931

2032
module.exports = Files

tests/e2e/pageObjects/PresentationViewerPage.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ class PresentationViewer {
55
this.currentSlideSelector = '#presentation-viewer-main section.present'
66
this.navigateNextSlideSelector = 'button[aria-label="next slide"]'
77
this.navigatePreviousSlideSelector = 'button[aria-label="previous slide"]'
8+
this.textEditorContainerSelector = '#text-editor-container'
9+
this.sidebarPanelSelector = '#app-sidebar'
10+
this.sidebarToggleBtnSelector = '#files-toggle-sidebar'
11+
this.actionsMenuSelector = '#sidebar-panel-actions-select'
812
}
913

1014
async getCurrentSlideContent() {

tests/e2e/stepDefinitions/presentationViewerContext.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Given('user {string} has logged in', async function (user) {
2626
})
2727

2828
When(
29-
'user {string} previews a markdown file {string} in presentation viewer',
29+
'user {string} previews markdown file {string} in presentation viewer',
3030
async function (user, fileName) {
3131
await files.openMDFileInPresentationViewer()
3232
}
@@ -59,3 +59,21 @@ Then('the content of the current slide should be {string}', async function (cont
5959
const currentSlideContent = await presentationViewer.getCurrentSlideContent()
6060
await expect(currentSlideContent).toBe(content)
6161
})
62+
63+
When(
64+
'user {string} opens file {string} in text editor using sidebar panel',
65+
async function (user, fileName) {
66+
await files.openMDFileInTextEditorUsingSidebarPanel(fileName)
67+
}
68+
)
69+
70+
When(
71+
'user {string} previews markdown file {string} in presentation viewer using sidebar panel',
72+
async function (user, fileName) {
73+
await files.openMDFileInPresentationViewerUsingSidebarPanel(fileName)
74+
}
75+
)
76+
77+
Then('file {string} should be opened in the text editor', async function (fileName) {
78+
await expect(page.locator(presentationViewer.textEditorContainerSelector)).toBeVisible()
79+
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const PresentationViewer = require('../pageObjects/PresentationViewerPage')
2+
3+
const presentationViewerPage = new PresentationViewer()
4+
5+
const sidebarPanelOpen = async () => {
6+
return await page.locator(presentationViewerPage.sidebarPanelSelector).isVisible()
7+
}
8+
9+
const openSidebarPanel = async () => {
10+
if (!(await sidebarPanelOpen())) {
11+
await page.click(presentationViewerPage.sidebarToggleBtnSelector)
12+
}
13+
}
14+
15+
const openActionFromSidebarPanel = async () => {
16+
await openSidebarPanel()
17+
await page.click(presentationViewerPage.actionsMenuSelector)
18+
}
19+
20+
module.exports = { sidebarPanelOpen, openSidebarPanel, openActionFromSidebarPanel }

0 commit comments

Comments
 (0)