Skip to content

Commit 3ea4454

Browse files
committed
test: add test for changing slide using ui buttons and keyborad actions
1 parent abc9f02 commit 3ea4454

File tree

5 files changed

+51
-6
lines changed

5 files changed

+51
-6
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: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@ Feature: markdown presentation viewer
1111
Scenario: preview markdown file in presentation viewer
1212
When user "admin" previews a markdown file "test-markdown.md" in presentation viewer
1313
Then markdown file "test-markdown.md" should be opened in the presentation viewer
14-
15-
16-
Scenario: check content of a slide
17-
When user "admin" previews a markdown file "test-markdown.md" in presentation viewer
14+
And the content of the current slide should be "PRESENTATION VIEWER"
15+
# change slide with button in UI
16+
When user "admin" navigates to the next slide using next slide button
17+
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."
18+
When user "admin" navigates to the previous slide using previous slide button
1819
Then the content of the current slide should be "PRESENTATION VIEWER"
20+
# change slide with keyboard
21+
When user "admin" navigates to the next slide using keyboard
22+
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."
23+
When user "admin" navigates to the previous slide using keyboard
24+
Then the content of the current slide should be "PRESENTATION VIEWER"

tests/e2e/filesForUpload/test-markdown.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Presentation Viewer
2+
---
3+
4+
An extension for OpenCloud & ownCloud Infinite Scale (oCIS) that allows users to create slide presentations directly from markdown files.
5+
26
---
37
## Table of Contents
48
1. Introduction

tests/e2e/pageObjects/PresentationViewerPage.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,27 @@ class PresentationViewer {
33
this.slidesContainerSelector = '#presentation-viewer-main .slides'
44
this.presentationViewerHomepageSelector = '#presentation-viewer-main'
55
this.currentSlideSelector = '#presentation-viewer-main section.present'
6+
this.navigateNextSlideSelector = 'button[aria-label="next slide"]'
7+
this.navigatePreviousSlideSelector = 'button[aria-label="previous slide"]'
68
}
79

810
async getCurrentSlideContent() {
9-
return await page.locator(this.currentSlideSelector).innerText()
11+
return await page
12+
.locator(this.currentSlideSelector)
13+
.innerText()
14+
.then((text) => text.trim())
15+
}
16+
17+
async changeSlideUsingButton(direction) {
18+
if (direction === 'next') {
19+
await page.click(this.navigateNextSlideSelector)
20+
} else if (direction === 'previous') {
21+
await page.click(this.navigatePreviousSlideSelector)
22+
}
23+
}
24+
25+
async changeSlideUsingKeyboard(action) {
26+
await page.locator('body').press(action)
1027
}
1128
}
1229

tests/e2e/stepDefinitions/presentationViewerContext.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ When(
3232
}
3333
)
3434

35+
When('user {string} navigates to the next slide using next slide button', async function (user) {
36+
await presentationViewer.changeSlideUsingButton('next')
37+
})
38+
When(
39+
'user {string} navigates to the previous slide using previous slide button',
40+
async function (user) {
41+
await presentationViewer.changeSlideUsingButton('previous')
42+
}
43+
)
44+
45+
When('user {string} navigates to the next slide using keyboard', async function (user) {
46+
await presentationViewer.changeSlideUsingKeyboard('ArrowRight')
47+
})
48+
49+
When('user {string} navigates to the previous slide using keyboard', async function (user) {
50+
await presentationViewer.changeSlideUsingKeyboard('ArrowLeft')
51+
})
52+
3553
Then(
3654
'markdown file {string} should be opened in the presentation viewer',
3755
async function (fileName) {

0 commit comments

Comments
 (0)