Skip to content

Commit 0a8f7ac

Browse files
committed
Add codeblock content wrapping test
1 parent a15826a commit 0a8f7ac

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

WebExample/__tests__/codeblock.spec.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,37 @@ import {test, expect} from '@playwright/test';
33
import * as TEST_CONST from '../../example/src/testConstants';
44
import {getElementValue, setCursorPosition, setupInput, testMarkdownContentStyle} from './utils';
55

6+
const CODEBLOCK_DEFAULT_STYLE = 'border-radius: 4px; padding: 0px; font-family: monospace; font-size: 20px; color: black;';
7+
68
test.beforeEach(async ({page}) => {
79
await page.goto(TEST_CONST.LOCAL_URL, {waitUntil: 'load'});
810
});
911

10-
test.describe('typing', () => {
12+
test.describe('modyfying codeblock content', () => {
13+
test('codeblock content wrapping', async ({page}) => {
14+
const LINE_TO_ADD = ' very long line of code that should be wrapped';
15+
const inputLocator = await setupInput(page, 'clear');
16+
await inputLocator.focus();
17+
await inputLocator.pressSequentially('```\nCodeblock\nSample code line\n```');
18+
19+
await setCursorPosition(page, 3);
20+
21+
await inputLocator.pressSequentially(LINE_TO_ADD);
22+
23+
expect(await getElementValue(inputLocator)).toEqual(`\`\`\`\nCodeblock${LINE_TO_ADD}\nSample code line\n\`\`\``);
24+
25+
// Verify if the codeblock style wasn't appleid
26+
await testMarkdownContentStyle({
27+
testContent: 'codeblock',
28+
style: CODEBLOCK_DEFAULT_STYLE,
29+
pseudoStyle: {
30+
height: '108px',
31+
width: '246px',
32+
},
33+
page,
34+
});
35+
});
36+
1137
test('typing after codeblock opening syntax', async ({page}) => {
1238
const inputLocator = await setupInput(page, 'clear');
1339
await inputLocator.focus();
@@ -40,7 +66,7 @@ test.describe('typing', () => {
4066
// Verify if the codeblock style is applied correctly after cahnges
4167
await testMarkdownContentStyle({
4268
testContent: 'codeblock',
43-
style: 'border-radius: 4px; padding: 0px; font-family: monospace; font-size: 20px; color: black;',
69+
style: CODEBLOCK_DEFAULT_STYLE,
4470
pseudoStyle: {
4571
height: '82px',
4672
width: '197px',
@@ -52,7 +78,7 @@ test.describe('typing', () => {
5278
test('typing after codeblock closing syntax', async ({page}) => {
5379
const styleProperties = {
5480
testContent: 'codeblock',
55-
style: 'border-radius: 4px; padding: 0px; font-family: monospace; font-size: 20px; color: black;',
81+
style: CODEBLOCK_DEFAULT_STYLE,
5682
pseudoStyle: {
5783
height: '56px',
5884
width: '197px',

example/src/testConstants.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
const LOCAL_URL = 'http://localhost:19006/';
22

3-
const EXAMPLE_CONTENT = [
4-
'Hello, *world*!',
5-
'😀🍕🍔',
6-
'https://expensify.com',
7-
'# header1',
8-
'> blockquote',
9-
'`inline code`',
10-
'```\ncodeblock\n```',
11-
'@here',
12-
13-
'#mention-report',
14-
'![demo image](https://picsum.photos/id/1067/200/300)',
15-
].join('\n');
3+
const EXAMPLE_CONTENT =
4+
'```\nCodeblock very long line of code that should be wrapped\nSample code line\n```';
165

176
const INPUT_ID = 'MarkdownInput_Example';
187
const INPUT_HISTORY_DEBOUNCE_TIME_MS = 150;

0 commit comments

Comments
 (0)