Skip to content

Commit

Permalink
fix: Tests fail
Browse files Browse the repository at this point in the history
  • Loading branch information
liuweiGL committed Jan 22, 2025
1 parent df9a29a commit 1a59c67
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,18 @@ test.describe('HTML Tables CopyAndPaste', () => {
<col style="width: 92px" />
</colgroup>
<tr>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">a</span>
</p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
Expand All @@ -70,7 +74,9 @@ test.describe('HTML Tables CopyAndPaste', () => {
<span data-lexical-text="true">b</span>
</p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
Expand All @@ -79,21 +85,27 @@ test.describe('HTML Tables CopyAndPaste', () => {
</td>
</tr>
<tr>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">d</span>
</p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">e</span>
</p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
Expand Down Expand Up @@ -127,21 +139,27 @@ test.describe('HTML Tables CopyAndPaste', () => {
<col style="width: 233px;" />
</colgroup>
<tr>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">short</span>
</p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">wide</span>
</p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
Expand All @@ -150,21 +168,27 @@ test.describe('HTML Tables CopyAndPaste', () => {
</td>
</tr>
<tr>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">a</span>
</p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">b</span>
</p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
Expand Down Expand Up @@ -281,14 +305,18 @@ test.describe('HTML Tables CopyAndPaste', () => {
<col style="width: 100px" />
</colgroup>
<tr style="height: 21px">
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: bottom">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">a</span>
</p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: bottom">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
Expand All @@ -300,7 +328,9 @@ test.describe('HTML Tables CopyAndPaste', () => {
<span data-lexical-text="true">b</span>
</p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: bottom">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
Expand All @@ -309,21 +339,27 @@ test.describe('HTML Tables CopyAndPaste', () => {
</td>
</tr>
<tr style="height: 21px">
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: bottom">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">d</span>
</p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: bottom">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">e</span>
</p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: bottom">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
Expand Down Expand Up @@ -508,17 +544,23 @@ test.describe('HTML Tables CopyAndPaste', () => {
<span data-lexical-text="true">c</span>
</p>
</th>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">d</span>
</p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</td>
</tr>
Expand All @@ -527,13 +569,19 @@ test.describe('HTML Tables CopyAndPaste', () => {
class="PlaygroundEditorTheme__tableCell PlaygroundEditorTheme__tableCellHeader">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</th>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</td>
</tr>
Expand All @@ -542,13 +590,19 @@ test.describe('HTML Tables CopyAndPaste', () => {
class="PlaygroundEditorTheme__tableCell PlaygroundEditorTheme__tableCellHeader">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</th>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</td>
<td class="PlaygroundEditorTheme__tableCell">
<td
class="PlaygroundEditorTheme__tableCell"
style="vertical-align: top">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2946,7 +2946,7 @@ describe('LexicalSelection tests', () => {
return $createHeadingNode('h1');
});
expect(JSON.stringify(testEditor._pendingEditorState?.toJSON())).toBe(
'{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1},{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1},{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[{"children":[{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"}],"direction":null,"format":"","indent":0,"type":"tablecell","version":1,"backgroundColor":null,"colSpan":1,"headerState":3,"rowSpan":1},{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"}],"direction":null,"format":"","indent":0,"type":"tablecell","version":1,"backgroundColor":null,"colSpan":1,"headerState":1,"rowSpan":1}],"direction":null,"format":"","indent":0,"type":"tablerow","version":1}],"direction":null,"format":"","indent":0,"type":"table","version":1},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"}],"direction":null,"format":"","indent":0,"type":"root","version":1}}',
'{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1},{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1},{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[{"children":[{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"}],"direction":null,"format":"","indent":0,"type":"tablecell","version":1,"backgroundColor":null,"colSpan":1,"headerState":3,"rowSpan":1,"verticalAlign":null},{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"}],"direction":null,"format":"","indent":0,"type":"tablecell","version":1,"backgroundColor":null,"colSpan":1,"headerState":1,"rowSpan":1,"verticalAlign":null}],"direction":null,"format":"","indent":0,"type":"tablerow","version":1}],"direction":null,"format":"","indent":0,"type":"table","version":1},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"}],"direction":null,"format":"","indent":0,"type":"root","version":1}}',
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ describe('LexicalTableCellNode tests', () => {
expect(cellWithCustomWidthNode.createDOM(editorConfig).outerHTML).toBe(
`<td style="width: ${cellWidth}px;" class="${editorConfig.theme.tableCell}"></td>`,
);
const verticalAlign = 'top';
const cellWithVerticalAlignNode = $createTableCellNode(
TableCellHeaderStates.NO_STATUS,
);
cellWithVerticalAlignNode.setVerticalAlign(verticalAlign);
expect(
cellWithVerticalAlignNode.createDOM(editorConfig).outerHTML,
).toBe(
`<td style="vertical-align: ${verticalAlign};" class="${editorConfig.theme.tableCell}"></td>`,
);
});
});
});
Expand Down
21 changes: 11 additions & 10 deletions packages/lexical-table/src/__tests__/unit/LexicalTableNode.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ describe('LexicalTableNode tests', () => {
$insertDataTransferForRichText(dataTransfer, selection, editor);
});
// Make sure paragraph is inserted inside empty cells
const emptyCell = '<td><p><br></p></td>';
const emptyCell =
'<td style="vertical-align: top"><p><br></p></td>';
expectTableHtmlToBeEqual(
testEnv.innerHTML,
html`
Expand All @@ -297,19 +298,19 @@ describe('LexicalTableNode tests', () => {
<col style="width: 200px;" />
</colgroup>
<tr>
<td>
<td style="vertical-align: top">
<p dir="ltr">
<span data-lexical-text="true">Hello there</span>
</p>
</td>
<td>
<td style="vertical-align: top">
<p dir="ltr">
<span data-lexical-text="true">General Kenobi!</span>
</p>
</td>
</tr>
<tr>
<td>
<td style="vertical-align: top">
<p dir="ltr">
<span data-lexical-text="true">Lexical is nice</span>
</p>
Expand Down Expand Up @@ -659,34 +660,34 @@ describe('LexicalTableNode tests', () => {
<col style="width: 171px" />
</colgroup>
<tr style="height: 21px;">
<td>
<td style="vertical-align: bottom">
<p dir="ltr">
<strong data-lexical-text="true">Surface</strong>
</p>
</td>
<td>
<td style="vertical-align: bottom">
<p dir="ltr">
<em data-lexical-text="true">MWP_WORK_LS_COMPOSER</em>
</p>
</td>
<td>
<td style="vertical-align: bottom">
<p style="text-align: right;">
<span data-lexical-text="true">77349</span>
</p>
</td>
</tr>
<tr style="height: 21px;">
<td>
<td style="vertical-align: bottom">
<p dir="ltr">
<span data-lexical-text="true">Lexical</span>
</p>
</td>
<td>
<td style="vertical-align: bottom">
<p dir="ltr">
<span data-lexical-text="true">XDS_RICH_TEXT_AREA</span>
</p>
</td>
<td>
<td style="vertical-align: bottom">
<p dir="ltr">
<span data-lexical-text="true">sdvd</span>
<strong data-lexical-text="true">sdfvsfs</strong>
Expand Down
Loading

0 comments on commit 1a59c67

Please sign in to comment.