-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #230 from stakater/add-tests
- Loading branch information
Showing
5 changed files
with
3,294 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM node:22-alpine | ||
WORKDIR testcafe | ||
|
||
ARG CURRENT_BRANCH | ||
|
||
ENV CURRENT_BRANCH=$CURRENT_BRANCH | ||
ENV XDG_DOWNLOAD_DIR=/opt/JDownloader/Downloads | ||
|
||
COPY src src | ||
COPY package.json package.json | ||
|
||
RUN echo "Install build deps.." \ | ||
&& apk --update --no-cache add \ | ||
chromium \ | ||
tzdata | ||
|
||
RUN yarn | ||
|
||
CMD ["yarn", "start"] |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "mto-docs-testcafe-tests", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"testcafe": "^3.3.0", | ||
"dotenv": "^16.3.1" | ||
}, | ||
"scripts": { | ||
"local": "testcafe chrome src/**.ts", | ||
"start": "testcafe chromium:headless src/**.ts" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { fixture, Selector } from "testcafe"; | ||
|
||
const consentControlsDiv = Selector('.md-consent__controls'); | ||
const acceptButton = consentControlsDiv.find('button').withText('Accept'); | ||
const searchInput = Selector('input.md-search__input').withAttribute('placeholder', 'Search'); | ||
const searchResultItem = Selector('li.md-search-result__item'); | ||
const searchLabel = Selector('label.md-header__button.md-icon').withAttribute('for', '__search'); | ||
const currentBranch = <string>process.env.CURRENT_BRANCH; | ||
|
||
fixture("Verify site") | ||
.page`${'http://127.0.0.1:8080/'.concat(currentBranch, '/#')}` | ||
.skipJsErrors(); | ||
|
||
test('Verify index file exists', async t => { | ||
await t | ||
.navigateTo(`${'http://127.0.0.1:8080/'.concat(currentBranch, '/index.html')}`); | ||
}) | ||
|
||
test('Search for existence of incorrectly rendered fenced code blocks', async (t) => { | ||
await t.maximizeWindow(); | ||
|
||
const acceptButtonExists = await acceptButton.exists; | ||
|
||
if (acceptButtonExists) { | ||
await t.click(acceptButton); | ||
} | ||
|
||
const searchLabelExists = await searchLabel.exists; | ||
const searchLabelVisible = await searchLabel.visible; | ||
|
||
if (searchLabelExists && searchLabelVisible) { | ||
await t.click(searchLabel); | ||
} | ||
|
||
await t.expect(searchInput.visible).ok(); | ||
await t.click(searchInput); | ||
await t.typeText(searchInput, "```") | ||
|
||
const searchResultItemExists = await searchResultItem.exists; | ||
await t.expect(searchResultItemExists).notOk('Fenced code blocks exist in the search result and are therefore incorrectly rendered, failing the test'); | ||
}) | ||
|
||
test('Search for existence of incorrectly rendered admonitions', async (t) => { | ||
await t.maximizeWindow(); | ||
|
||
const acceptButtonExists = await acceptButton.exists; | ||
|
||
if (acceptButtonExists) { | ||
await t.click(acceptButton); | ||
} | ||
|
||
const searchLabelExists = await searchLabel.exists; | ||
const searchLabelVisible = await searchLabel.visible; | ||
|
||
if (searchLabelExists && searchLabelVisible) { | ||
await t.click(searchLabel); | ||
} | ||
|
||
await t.expect(searchInput.visible).ok(); | ||
await t.click(searchInput); | ||
await t.typeText(searchInput, "!!!") | ||
|
||
const searchResultItemExists = await searchResultItem.exists; | ||
await t.expect(searchResultItemExists).notOk('Admonitions exist in the search result and are therefore incorrectly rendered, failing the test'); | ||
}) |
Oops, something went wrong.