Skip to content

Commit e578746

Browse files
authored
Merge pull request #120 from JankariTech/test/change-slides
test: add test for changing slide using ui buttons and keyboard actions
2 parents abc9f02 + 8b4512e commit e578746

File tree

4 files changed

+47
-5
lines changed

4 files changed

+47
-5
lines changed

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 navigation 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 navigation 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: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,28 @@ 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 changeSlideUsingNavigationButton(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(direction) {
26+
const key = direction === 'next' ? 'ArrowRight' : 'ArrowLeft'
27+
await page.locator('body').press(key)
1028
}
1129
}
1230

tests/e2e/stepDefinitions/presentationViewerContext.js

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

35+
When(
36+
/^user "([^"]*)" navigates to the (previous|next) slide using navigation button$/,
37+
async function (user, direction) {
38+
await presentationViewer.changeSlideUsingNavigationButton(direction)
39+
}
40+
)
41+
42+
When(
43+
/^user "([^"]*)" navigates to the (previous|next) slide using keyboard$/,
44+
async function (user, direction) {
45+
await presentationViewer.changeSlideUsingKeyboard(direction)
46+
}
47+
)
48+
3549
Then(
3650
'markdown file {string} should be opened in the presentation viewer',
3751
async function (fileName) {

0 commit comments

Comments
 (0)