Skip to content

Commit

Permalink
test: 💍 Add pw test for input markdown heading
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul-Mirone committed Jul 28, 2021
1 parent 184be52 commit 7343c01
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
4 changes: 3 additions & 1 deletion integration-test/package.json
Expand Up @@ -5,7 +5,9 @@
"scripts": {
"start": "vite",
"test": "playwright test",
"start:test": "start-server-and-test start http-get://localhost:7000 test"
"test:verbose": "playwright test --headed",
"start:test": "start-server-and-test start http-get://localhost:7000 test",
"start:test:verbose": "start-server-and-test start http-get://localhost:7000 test:verbose"
},
"files": [
"style"
Expand Down
9 changes: 4 additions & 5 deletions integration-test/src/main.ts
@@ -1,13 +1,12 @@
const url = new URL(location.href);

const main = async () => {
if (url.pathname === '/') {
const url = new URL(location.href);
if (!url.hash) {
return;
}

const name = '.' + url.pathname;
const name = '.' + url.hash.slice(1);
const module = await import(/* @vite-ignore */ name);
return module.setup();
module.setup();
};

main();
16 changes: 14 additions & 2 deletions integration-test/tests/editor.spec.ts
@@ -1,9 +1,21 @@
import { test, expect } from '@playwright/test';

test('has editor', async ({ page }) => {
await page.goto('/preset-commonmark');
await page.goto('/#/preset-commonmark');
const milkdown = await page.waitForSelector('.milkdown');
const editor = await milkdown.waitForSelector('.editor');
expect(await editor.getAttribute('contenteditable')).toBe('true');
// expect(await editor.waitForSelector('.h1 >> text=Milkdown')).toBeTruthy();
});

test('input markdown heading', async ({ page }) => {
await page.goto('/#/preset-commonmark');
const editor = await page.waitForSelector('.editor');

await editor.type('# Heading1');
expect(await editor.waitForSelector('.h1 >> text=Heading1')).toBeTruthy();

await editor.type('\n');

await editor.type('## Heading2');
expect(await editor.waitForSelector('.h2 >> text=Heading2')).toBeTruthy();
});
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -95,6 +95,6 @@
"rimraf": "^3.0.2",
"ts-jest": "^26.5.4",
"typescript": "^4.3.5",
"vite": "^2.4.3"
"vite": "^2.4.4"
}
}
15 changes: 9 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7343c01

Please sign in to comment.