Skip to content

Commit

Permalink
test: passing test increased from 137 to 287
Browse files Browse the repository at this point in the history
  • Loading branch information
umaranis committed May 7, 2024
1 parent 3720379 commit cb3178f
Show file tree
Hide file tree
Showing 45 changed files with 8,950 additions and 6,020 deletions.
146 changes: 109 additions & 37 deletions demos/playground/src/__tests__/e2e/AutoLinks.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
moveToLineBeginning,
moveToLineEnd,
selectAll,
selectCharacters,
toggleBold,
} from '../keyboardShortcuts/index.mjs';
import {
assertHTML,
Expand Down Expand Up @@ -156,45 +158,43 @@ test.describe('Auto Links', () => {
);
});

test.fixme(
'Does not create redundant auto-link',
async ({page, isPlainText}) => {
test.skip(isPlainText);
await focusEditor(page);
await page.keyboard.type('hm');
test('Does not create redundant auto-link', async ({page, isPlainText}) => {
test.skip(isPlainText);
await focusEditor(page);
await page.keyboard.type('hm');

await selectAll(page);
await click(page, '.link');
await selectAll(page);
await click(page, '.link');
await click(page, '.link-confirm');

await assertHTML(
page,
html`
<p dir="ltr">
<a href="https://" dir="ltr" rel="noopener">
<span data-lexical-text="true">hm</span>
</a>
</p>
`,
undefined,
{ignoreClasses: true},
);
await moveLeft(page, 1);
await moveRight(page, 1);
await page.keyboard.type('ttps://facebook.co');
await assertHTML(
page,
html`
<p dir="ltr">
<a href="https://" dir="ltr" rel="noopener">
<span data-lexical-text="true">https://facebook.com</span>
</a>
</p>
`,
undefined,
{ignoreClasses: true},
);
},
);
await assertHTML(
page,
html`
<p dir="ltr">
<a href="https://" dir="ltr" rel="noreferrer">
<span data-lexical-text="true">hm</span>
</a>
</p>
`,
undefined,
{ignoreClasses: true},
);
await moveLeft(page, 1);
await moveRight(page, 1);
await page.keyboard.type('ttps://facebook.co');
await assertHTML(
page,
html`
<p dir="ltr">
<a href="https://" dir="ltr" rel="noreferrer">
<span data-lexical-text="true">https://facebook.com</span>
</a>
</p>
`,
undefined,
{ignoreClasses: true},
);
});

test('Can create links when pasting text with multiple autolinks in a row separated by non-alphanumeric characters, but not whitespaces', async ({
page,
Expand Down Expand Up @@ -259,4 +259,76 @@ test.describe('Auto Links', () => {
{ignoreClasses: true},
);
});

test('Handles autolink following an invalid autolink', async ({
page,
isPlainText,
}) => {
test.skip(isPlainText);
await focusEditor(page);
await page.keyboard.type('Hellohttps://example.com https://example.com');

await assertHTML(
page,
html`
<p dir="ltr">
<span data-lexical-text="true">Hellohttps://example.com</span>
<a href="https://example.com" dir="ltr">
<span data-lexical-text="true">https://example.com</span>
</a>
</p>
`,
undefined,
{ignoreClasses: true},
);
});

test('Can convert url-like text with formatting into links', async ({
page,
isPlainText,
}) => {
test.skip(isPlainText);
await focusEditor(page);
await page.keyboard.type('Hellohttp://example.com and more');

// Add bold formatting to com
await moveToLineBeginning(page);
await moveRight(page, 20);
await selectCharacters(page, 'right', 3);
await toggleBold(page);

await assertHTML(
page,
html`
<p dir="ltr">
<span data-lexical-text="true">Hellohttp://example.</span>
<strong data-lexical-text="true">com</strong>
<span data-lexical-text="true">and more</span>
</p>
`,
undefined,
{ignoreClasses: true},
);

// Add space before formatted link text
await moveToLineBeginning(page);
await moveRight(page, 5);
await page.keyboard.type(' ');

await assertHTML(
page,
html`
<p dir="ltr">
<span data-lexical-text="true">Hello</span>
<a href="http://example.com" dir="ltr">
<span data-lexical-text="true">http://example.</span>
<strong data-lexical-text="true">com</strong>
</a>
<span data-lexical-text="true">and more</span>
</p>
`,
undefined,
{ignoreClasses: true},
);
});
});
2 changes: 1 addition & 1 deletion demos/playground/src/__tests__/e2e/Autocomplete.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test.describe('Autocomplete', () => {
test.beforeEach(({isCollab, page}) =>
initialize({isAutocomplete: true, isCollab, page}),
);
test.fixme('Can autocomplete a word', async ({page, isPlainText}) => {
test('Can autocomplete a word', async ({page, isPlainText}) => {
await focusEditor(page);
await page.keyboard.type('Sort by alpha');
await sleep(500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
insertYouTubeEmbed,
selectFromAlignDropdown,
test,
YOUTUBE_SAMPLE_URL,
} from '../utils/index.mjs';

const TEST_URL = 'https://www.youtube-nocookie.com/embed/jNQXAC9IVRw';
test.describe('BlockWithAlignableContents', () => {
test.fixme();
test.beforeEach(({isCollab, page}) => initialize({isCollab, page}));
Expand All @@ -39,7 +39,7 @@ test.describe('BlockWithAlignableContents', () => {
</p>
`,
);
await insertYouTubeEmbed(page, TEST_URL);
await insertYouTubeEmbed(page, YOUTUBE_SAMPLE_URL);
await assertHTML(
page,
html`
Expand All @@ -55,7 +55,7 @@ test.describe('BlockWithAlignableContents', () => {
allowfullscreen=""
frameborder="0"
height="315"
src="${TEST_URL}"
src="${YOUTUBE_SAMPLE_URL}"
title="YouTube video"
width="560"></iframe>
</div>
Expand All @@ -72,7 +72,7 @@ test.describe('BlockWithAlignableContents', () => {
test.skip(isPlainText);
await focusEditor(page);
await page.keyboard.type('Hello world');
await insertYouTubeEmbed(page, TEST_URL);
await insertYouTubeEmbed(page, YOUTUBE_SAMPLE_URL);
await assertHTML(
page,
html`
Expand All @@ -88,7 +88,7 @@ test.describe('BlockWithAlignableContents', () => {
allowfullscreen=""
frameborder="0"
height="315"
src="${TEST_URL}"
src="${YOUTUBE_SAMPLE_URL}"
title="YouTube video"
width="560"></iframe>
</div>
Expand Down Expand Up @@ -116,7 +116,7 @@ test.describe('BlockWithAlignableContents', () => {
allowfullscreen=""
frameborder="0"
height="315"
src="${TEST_URL}"
src="${YOUTUBE_SAMPLE_URL}"
title="YouTube video"
width="560"></iframe>
</div>
Expand Down
6 changes: 3 additions & 3 deletions demos/playground/src/__tests__/e2e/ClearFormatting.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test.describe('Clear All Formatting', () => {
test.fixme();
test.beforeEach(({isPlainText, isCollab, page}) => {
test.skip(isPlainText);
initialize({isCollab, page});
return initialize({isCollab, page});
});
test(`Can clear BIU formatting`, async ({page}) => {
await focusEditor(page);
Expand Down Expand Up @@ -134,7 +134,7 @@ test.describe('Clear All Formatting', () => {

await clearEditor(page);

await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');

await waitForSelector(page, '#typeahead-menu ul li');
await assertHTML(
Expand All @@ -143,7 +143,7 @@ test.describe('Clear All Formatting', () => {
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Luke</span>
<span data-lexical-text="true">@Luke</span>
</p>
`,
);
Expand Down
66 changes: 34 additions & 32 deletions demos/playground/src/__tests__/e2e/CodeActionMenu.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*
*/

/* eslint-disable no-useless-escape */

import {paste} from '../keyboardShortcuts/index.mjs';
import {
assertHTML,
Expand All @@ -21,15 +23,16 @@ import {
} from '../utils/index.mjs';

test.describe('CodeActionMenu', () => {
test.fixme();
//test.fixme();
test.beforeEach(({isCollab, page}) => initialize({isCollab, page}));
test('Can copy code, when click `Copy` button', async ({
page,
context,
isPlainText,
browserName,
}) => {
test.skip(isPlainText);
test.skip(true);

await focusEditor(page);
await page.keyboard.type('``` ');
await page.keyboard.press('Space');
Expand Down Expand Up @@ -251,21 +254,19 @@ test.describe('CodeActionMenu', () => {
);
});

test('If the code syntax is incorrect, an error message should be displayed', async ({
page,
isCollab,
isPlainText,
}) => {
test.skip(isCollab);
test.skip(isPlainText);
await focusEditor(page);
await page.keyboard.type('``` ');
await page.keyboard.press('Space');
await page.keyboard.type(`cons luci = 'Hello World'`);
test.fixme(
'If the code syntax is incorrect, an error message should be displayed',
async ({page, isCollab, isPlainText}) => {
test.skip(isCollab);
test.skip(isPlainText);
await focusEditor(page);
await page.keyboard.type('``` ');
await page.keyboard.press('Space');
await page.keyboard.type(`cons luci = 'Hello World'`);

await assertHTML(
page,
`
await assertHTML(
page,
`
<code
class="PlaygroundEditorTheme__code PlaygroundEditorTheme__ltr"
dir="ltr"
Expand All @@ -282,27 +283,28 @@ test.describe('CodeActionMenu', () => {
</span>
</code>
`,
);
);

await mouseMoveToSelector(page, 'code.PlaygroundEditorTheme__code');
await click(page, 'button[aria-label=prettier]');
await mouseMoveToSelector(page, 'code.PlaygroundEditorTheme__code');
await click(page, 'button[aria-label=prettier]');

await page.waitForTimeout(3000);
await page.waitForTimeout(3000);

expect(await page.$('i.format.prettier-error')).toBeTruthy();
expect(await page.$('i.format.prettier-error')).toBeTruthy();

const errorTips = await page.$('pre.code-error-tips');
const errorTips = await page.$('pre.code-error-tips');

expect(errorTips).toBeTruthy();
expect(errorTips).toBeTruthy();

const tips = await evaluate(page, () => {
return document.querySelector('pre.code-error-tips').innerText;
});
const tips = await evaluate(page, () => {
return document.querySelector('pre.code-error-tips').innerText;
});

expect(tips).toBe(
'Missing semicolon. (1:6)\n' +
"> 1 | cons luci = 'Hello World'\n" +
' | ^',
);
});
expect(tips).toBe(
'Missing semicolon. (1:6)\n' +
"> 1 | cons luci = 'Hello World'\n" +
' | ^',
);
},
);
});
Loading

0 comments on commit cb3178f

Please sign in to comment.