From 17886c07a98dec2850a13eae1efa6b53d9f16c68 Mon Sep 17 00:00:00 2001 From: pradip Date: Wed, 21 Jan 2026 12:05:46 +0545 Subject: [PATCH] test: add test for changing slide using ui buttons and keyborad actions --- tests/e2e/config.js | 2 +- tests/e2e/features/presentationViewer.feature | 14 +++++++++---- tests/e2e/filesForUpload/test-markdown.md | 4 ++++ .../e2e/pageObjects/PresentationViewerPage.js | 20 ++++++++++++++++++- .../presentationViewerContext.js | 14 +++++++++++++ 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/tests/e2e/config.js b/tests/e2e/config.js index 4389ef1..36b1665 100644 --- a/tests/e2e/config.js +++ b/tests/e2e/config.js @@ -10,7 +10,7 @@ const config = { minTimeout: parseInt(process.env.MIN_TIMEOUT) || 5, headless: process.env.HEADLESS === 'true', debug: process.env.DEBUG === 'true', - targetServer: process.env.TARGET_SERVER.toLowerCase() || 'ocis' + targetServer: (process.env.TARGET_SERVER || 'ocis').toLowerCase() } module.exports = config diff --git a/tests/e2e/features/presentationViewer.feature b/tests/e2e/features/presentationViewer.feature index dcde76f..59c5ecd 100644 --- a/tests/e2e/features/presentationViewer.feature +++ b/tests/e2e/features/presentationViewer.feature @@ -11,8 +11,14 @@ Feature: markdown presentation viewer Scenario: preview markdown file in presentation viewer When user "admin" previews a markdown file "test-markdown.md" in presentation viewer Then markdown file "test-markdown.md" should be opened in the presentation viewer - - - Scenario: check content of a slide - When user "admin" previews a markdown file "test-markdown.md" in presentation viewer + And the content of the current slide should be "PRESENTATION VIEWER" + # change slide with button in UI + When user "admin" navigates to the next slide using navigation button + 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." + When user "admin" navigates to the previous slide using navigation button Then the content of the current slide should be "PRESENTATION VIEWER" + # change slide with keyboard + When user "admin" navigates to the next slide using keyboard + 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." + When user "admin" navigates to the previous slide using keyboard + Then the content of the current slide should be "PRESENTATION VIEWER" diff --git a/tests/e2e/filesForUpload/test-markdown.md b/tests/e2e/filesForUpload/test-markdown.md index 1cd543e..8130e19 100644 --- a/tests/e2e/filesForUpload/test-markdown.md +++ b/tests/e2e/filesForUpload/test-markdown.md @@ -1,4 +1,8 @@ # Presentation Viewer +--- + +An extension for OpenCloud & ownCloud Infinite Scale (oCIS) that allows users to create slide presentations directly from markdown files. + --- ## Table of Contents 1. Introduction diff --git a/tests/e2e/pageObjects/PresentationViewerPage.js b/tests/e2e/pageObjects/PresentationViewerPage.js index 81e7075..bdfcfe0 100644 --- a/tests/e2e/pageObjects/PresentationViewerPage.js +++ b/tests/e2e/pageObjects/PresentationViewerPage.js @@ -3,10 +3,28 @@ class PresentationViewer { this.slidesContainerSelector = '#presentation-viewer-main .slides' this.presentationViewerHomepageSelector = '#presentation-viewer-main' this.currentSlideSelector = '#presentation-viewer-main section.present' + this.navigateNextSlideSelector = 'button[aria-label="next slide"]' + this.navigatePreviousSlideSelector = 'button[aria-label="previous slide"]' } async getCurrentSlideContent() { - return await page.locator(this.currentSlideSelector).innerText() + return await page + .locator(this.currentSlideSelector) + .innerText() + .then((text) => text.trim()) + } + + async changeSlideUsingNavigationButton(direction) { + if (direction === 'next') { + await page.click(this.navigateNextSlideSelector) + } else if (direction === 'previous') { + await page.click(this.navigatePreviousSlideSelector) + } + } + + async changeSlideUsingKeyboard(direction) { + const key = direction === 'next' ? 'ArrowRight' : 'ArrowLeft' + await page.locator('body').press(key) } } diff --git a/tests/e2e/stepDefinitions/presentationViewerContext.js b/tests/e2e/stepDefinitions/presentationViewerContext.js index 4dda1dc..a4b7f62 100644 --- a/tests/e2e/stepDefinitions/presentationViewerContext.js +++ b/tests/e2e/stepDefinitions/presentationViewerContext.js @@ -32,6 +32,20 @@ When( } ) +When( + /^user "([^"]*)" navigates to the (previous|next) slide using navigation button$/, + async function (user, direction) { + await presentationViewer.changeSlideUsingNavigationButton(direction) + } +) + +When( + /^user "([^"]*)" navigates to the (previous|next) slide using keyboard$/, + async function (user, direction) { + await presentationViewer.changeSlideUsingKeyboard(direction) + } +) + Then( 'markdown file {string} should be opened in the presentation viewer', async function (fileName) {