-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add e2e test for comparing rendered markdown
- Loading branch information
1 parent
03d57b0
commit 1aa5579
Showing
7 changed files
with
43 additions
and
130 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,56 +1,38 @@ | ||
const { Given, When, Then } = require('@cucumber/cucumber') | ||
const { expect } = require('@playwright/test') | ||
const { getUserCredentials } = require('../utils/userHelper') | ||
const { uploadFile } = require('../utils/fileHelper') | ||
const parseLocalFile = require('../utils/markdown') | ||
const { uploadFileWithContent } = require('../utils/fileHelper') | ||
const PresentationViewer = require('../pageObjects/PresentationViewerPage') | ||
const Ocis = require('../pageObjects/OcisPage') | ||
|
||
const presentationViewer = new PresentationViewer() | ||
const ocis = new Ocis() | ||
|
||
Given( | ||
'user {string} has uploaded the markdown file {string} using API', | ||
async function (user, fileName) { | ||
await uploadFile(fileName, user) | ||
'user {string} has uploaded the markdown file {string} with content {string}', | ||
async function (user, fileName, markdownContent) { | ||
await uploadFileWithContent(fileName, user, markdownContent) | ||
} | ||
) | ||
|
||
Given('user {string} has logged in', async function (user) { | ||
Given('user {string} has logged in to the web UI', async function (user) { | ||
await ocis.navigateToLoginPage() | ||
const { username, password } = getUserCredentials(user) | ||
await ocis.login(username, password) | ||
await expect(page.locator(ocis.filesContainerSelector)).toBeVisible() | ||
}) | ||
|
||
When( | ||
'user {string} previews a markdown file {string} in presentation viewer', | ||
async function (user, fileName) { | ||
await ocis.openMDFileInPresentationViewer() | ||
} | ||
) | ||
|
||
Then( | ||
'markdown file {string} should be opened in the presentation viewer', | ||
async function (fileName) { | ||
await expect(page.locator(presentationViewer.presentationViewerHomepageSelector)).toBeVisible() | ||
await expect(page.locator(presentationViewer.slidesContainerSelector)).toBeVisible() | ||
} | ||
) | ||
|
||
Then('content of file {string} should be correctly rendered', async function (fileName) { | ||
await compareRenderedContent(fileName, presentationViewer) | ||
When('the user previews the markdown file', async function () { | ||
await ocis.openMDFileInPresentationViewer() | ||
await expect(page.locator(presentationViewer.presentationViewerHomepageSelector)).toBeVisible() | ||
await expect(page.locator(presentationViewer.slidesContainerSelector)).toBeVisible() | ||
}) | ||
|
||
const compareRenderedContent = async (fileName, presentationViewer) => { | ||
const localParsedSlides = parseLocalFile(fileName) | ||
for (let i = 1; i <= localParsedSlides.length; i++) { | ||
let serverParsedSlide = await presentationViewer.getServerParsedSlide() | ||
if (localParsedSlides[i - 1].toString() !== serverParsedSlide.toString()) { | ||
throw new Error(`Content did not match for slide: ${i}`) | ||
} | ||
if (i !== localParsedSlides.length) { | ||
await presentationViewer.goToNextSlide() | ||
} | ||
} | ||
} | ||
Then('the rendered HTML should be {string}', async function (htmlContent) { | ||
const expectedHTMLContent = htmlContent.replace(/\s+/g, '') // Removing all whitespace | ||
const serverRenderedHTMLContent = (await presentationViewer.getServerParsedSlide())[0].replace( | ||
/\s+/g, | ||
'' | ||
) // Removing all whitespace | ||
expect(expectedHTMLContent).toEqual(serverRenderedHTMLContent) | ||
}) |
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 was deleted.
Oops, something went wrong.