-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
822 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
image: node:20 | ||
|
||
before_script: | ||
- yarn | ||
|
||
stages: | ||
- build | ||
- ui-tests | ||
|
||
build: | ||
stage: build | ||
script: | ||
- yarn build | ||
|
||
ui-tests: | ||
stage: ui-tests | ||
script: | ||
- apt-get -qqy update > /dev/null 2> /dev/null | ||
- apt-get -qqy install --no-install-recommends chromium > /dev/null 2> /dev/null | ||
- npm run dev& | ||
- node bin/server.js& | ||
- npm run ui-test | ||
artifacts: | ||
when: always | ||
paths: | ||
- ui-tests/*.png |
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,3 +1,4 @@ | ||
dist | ||
node_modules | ||
.env | ||
ui-tests/*.png |
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,82 @@ | ||
import { describe, it } from 'vitest'; | ||
import { Builder, until, By, Key } from 'selenium-webdriver'; | ||
import chrome from 'selenium-webdriver/chrome'; | ||
import fs from "fs"; | ||
|
||
const ADDR = 'http://localhost:5173'; | ||
|
||
const saveScreenshot = name => ss => { | ||
fs.writeFile("ui-tests/" + name + ".png", ss, 'base64', console.error) | ||
} | ||
|
||
const mkDriver = () => new Builder() | ||
.forBrowser('chrome') | ||
.setChromeOptions(new chrome.Options() | ||
.headless() | ||
.addArguments([ | ||
"--no-sandbox", | ||
"--disable-dev-shm-usage" | ||
]) | ||
.windowSize({ width: 1200, height: 1000 })) | ||
.build(); | ||
|
||
const openMyst = (driver) => driver.get(ADDR) | ||
.then(() => driver.wait(until.titleContains('MyST'), 1000)) | ||
|
||
|
||
describe('UI Screenshots', () => { | ||
it('Check "Both" view', async () => { | ||
const driver = await mkDriver(); | ||
try { | ||
await openMyst(driver) | ||
await driver.takeScreenshot().then(saveScreenshot("both")) | ||
} finally { | ||
await driver.quit(); | ||
} | ||
}) | ||
|
||
it('Check "Source" view', async () => { | ||
const driver = await mkDriver(); | ||
try { | ||
await openMyst(driver); | ||
const elem = await driver.findElement(By.name("Source")) | ||
await elem.click() | ||
await driver.takeScreenshot().then(saveScreenshot("source")) | ||
} finally { | ||
await driver.quit(); | ||
} | ||
}) | ||
|
||
it('Check "Preview" view', async () => { | ||
const driver = await mkDriver(); | ||
try { | ||
await openMyst(driver); | ||
const elem = await driver.findElement(By.name("Preview")) | ||
await elem.click() | ||
await driver.takeScreenshot().then(saveScreenshot("preview")) | ||
} finally { | ||
await driver.quit(); | ||
} | ||
}) | ||
|
||
it('Check "Diff" view', async () => { | ||
const driver = await mkDriver(); | ||
try { | ||
await openMyst(driver); | ||
|
||
// Make some changes | ||
const lines = await driver.findElements(By.className("cm-line")); | ||
await lines[0].sendKeys('\n# Some Section\n\nSome text some text some text some text some text'); | ||
for (let i = 23; i < 30; i++) { | ||
await lines[i].clear(); | ||
await lines[i].sendKeys(Key.BACK_SPACE); | ||
} | ||
|
||
const elem = await driver.findElement(By.name("Diff")) | ||
await elem.click() | ||
await driver.takeScreenshot().then(saveScreenshot("diff")) | ||
} finally { | ||
await driver.quit(); | ||
} | ||
}) | ||
}) |
Oops, something went wrong.