web: improve real time sync test reliability

This commit is contained in:
Abdullah Atta
2023-08-05 16:27:42 +05:00
parent 59a66a63c5
commit 330b227027
23 changed files with 223 additions and 12 deletions

View File

@@ -0,0 +1,4 @@
Subtotal: ₹300
Sales tax: ₹200
Discount: -₹300
Total: ₹300

View File

@@ -0,0 +1,4 @@
Subtotal: ₹300
Sales tax: ₹200
Discount: ₹0
Total: ₹300/mo

View File

@@ -0,0 +1,4 @@
Subtotal: $100
Sales tax: $0
Discount: -$100
Total: $100

View File

@@ -0,0 +1,4 @@
Subtotal: $100
Sales tax: $0
Discount: $0
Total: $100/mo

View File

@@ -0,0 +1,4 @@
Subtotal: ₹400
Sales tax: ₹300
Discount: -₹400
Total: ₹400

View File

@@ -0,0 +1,4 @@
Subtotal: ₹400
Sales tax: ₹300
Discount: ₹0
Total: ₹400/yr

View File

@@ -0,0 +1,4 @@
Subtotal: $200
Sales tax: $0
Discount: -$200
Total: $200

View File

@@ -0,0 +1,4 @@
Subtotal: $200
Sales tax: $0
Discount: $0
Total: $200/yr

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

View File

@@ -0,0 +1 @@
Test note 1 (9) Test note 1 (8) Test note 1 (7) Test note 1 (6) Test note 1 (5) Test note 1 (4) Test note 1 (3) Test note 1 (2) Test note 1 (1) Test note 1 (0) 53ad8e4e40ebebd0f400498d

View File

@@ -0,0 +1 @@
Test note 2 (9)Test note 2 (8)Test note 2 (7)Test note 2 (6)Test note 2 (5)Test note 2 (4)Test note 2 (3)Test note 2 (2)Test note 2 (1)Test note 2 (0)f054d19e9a2f46eff7b9bb25

View File

@@ -0,0 +1 @@
Test note 1Test note 1 (0) Test note 1 (1) Test note 1 (2) Test note 1 (3) Test note 1 (4) Test note 1 (5) Test note 1 (6) Test note 1 (7) Test note 1 (8) Test note 1 (9)

View File

@@ -0,0 +1 @@
Test note 2Test note 2 (0)Test note 2 (1)Test note 2 (2)Test note 2 (3)Test note 2 (4)Test note 2 (5)Test note 2 (6)Test note 2 (7)Test note 2 (8)Test note 2 (9)

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

View File

@@ -0,0 +1 @@
An edit I madeThis is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1

View File

@@ -41,9 +41,7 @@ export class NoteItemModel extends BaseItemModel {
async openNote() {
await this.click();
const title = await this.getTitle();
const description = await this.getDescription();
await this.editor.waitForLoading(title, description);
await this.editor.waitForLoading(title);
}
async openLockedNote(password: string) {

View File

@@ -0,0 +1,163 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<meta
name="description"
content="This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1"
/>
<title>Test 1 - Notesnook</title>
<meta name="created-on" content="xxx" />
<meta name="last-edited-on" content="xxx" />
<link rel="stylesheet" href="https://app.notesnook.com/assets/editor-styles.css?d=0">
<style>
img {
max-width: 100% !important;
height: auto !important;
border-radius: 5px;
}
body {
background-color: transparent !important;
color: #202124;
font-family: "Open Sans", "Noto Sans", Frutiger, Calibri, Myriad, Arial, Ubuntu, Helvetica, -apple-system, BlinkMacSystemFont, sans-serif;
}
h1,
h2,
h3,
h4,
h5,
h6 {
color: #212121;
}
p {
margin-bottom: 0px;
}
p[data-spacing="double"] {
margin-top: 1em;
}
p[data-spacing="single"] {
margin-top: 0px;
}
p[data-spacing="single"]:empty {
margin-top: 1em;
}
pre.codeblock {
overflow-x: auto;
}
iframe {
max-width: 100% !important;
background-color: transparent !important;
}
li > p {
margin-top: 0px;
margin-bottom: 10px;
}
.checklist > li {
list-style: none;
margin: 0.25em 0;
}
.checklist > li::before {
content: url("data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2216%22%20height%3D%2216%22%20viewBox%3D%220%200%2016%2016%22%3E%3Cg%20id%3D%22checklist-unchecked%22%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Crect%20id%3D%22Rectangle%22%20width%3D%2215%22%20height%3D%2215%22%20x%3D%22.5%22%20y%3D%22.5%22%20fill-rule%3D%22nonzero%22%20stroke%3D%22%234C4C4C%22%20rx%3D%222%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E%0A");
cursor: pointer;
height: 1.1em;
margin-left: -2.5em;
margin-top: 0em;
position: absolute;
width: 1.5em;
padding-left: 1em;
}
.checklist li.checked::before {
content: url("data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2216%22%20height%3D%2216%22%20viewBox%3D%220%200%2016%2016%22%3E%3Cg%20id%3D%22checklist-checked%22%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Crect%20id%3D%22Rectangle%22%20width%3D%2216%22%20height%3D%2216%22%20fill%3D%22%23008837%22%20fill-rule%3D%22nonzero%22%20rx%3D%222%22%2F%3E%3Cpath%20id%3D%22Path%22%20fill%3D%22%23FFF%22%20fill-rule%3D%22nonzero%22%20d%3D%22M11.5703186%2C3.14417309%20C11.8516238%2C2.73724603%2012.4164781%2C2.62829933%2012.83558%2C2.89774797%20C13.260121%2C3.17069355%2013.3759736%2C3.72932262%2013.0909105%2C4.14168582%20L7.7580587%2C11.8560195%20C7.43776896%2C12.3193404%206.76483983%2C12.3852142%206.35607322%2C11.9948725%20L3.02491697%2C8.8138662%20C2.66090143%2C8.46625845%202.65798871%2C7.89594698%203.01850234%2C7.54483354%20C3.373942%2C7.19866177%203.94940006%2C7.19592841%204.30829608%2C7.5386474%20L6.85276923%2C9.9684299%20L11.5703186%2C3.14417309%20Z%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E%0A");
}
.checklist li.checked {
color: #505050;
}
[dir="rtl"] .checklist > li::before {
margin-left: 0;
margin-right: -1.5em;
}
blockquote {
border-left: 5px solid #e5e5e5;
padding-left: 10px;
margin-top: 0px;
}
code:not(pre code) {
background-color: #f7f7f7;
border: 1px solid #e5e5e5;
border-radius: 5px;
padding: 3px 5px 0px 5px;
font-family: Hack, Consolas, "Andale Mono", "Lucida Console", "Liberation Mono", "Courier New", Courier, monospace !important;
font-size: 10pt !important;
}
.ProseMirror code > span {
font-family: Hack, Consolas, "Andale Mono", "Lucida Console", "Liberation Mono", "Courier New", Courier, monospace !important;
}
pre {
padding: 10px;
background-color: #e5e5e5;
border-radius: 5px;
font-family: Hack, Consolas, "Andale Mono", "Lucida Console", "Liberation Mono", "Courier New", Courier, monospace !important;
margin-bottom: 16px !important;
}
table {
border-collapse: collapse;
margin: 0;
overflow: hidden;
table-layout: fixed;
}
table td,
table th {
border: 1px solid #e5e5e5;
box-sizing: border-box;
min-width: 1em;
padding: 3px 5px;
position: relative;
vertical-align: top;
}
table td > *,
table th > * {
margin-bottom: 0;
}
table th {
background-color: #f7f7f7;
font-weight: bold;
text-align: left;
}
table p {
margin: 0;
}
</style>
<style>
code[class*=language-],pre[class*=language-]{color:#f8f8f2;background:0 0;text-shadow:0 1px rgba(0,0,0,.3);font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto;border-radius:.3em}:not(pre)>code[class*=language-],pre[class*=language-]{background:#282a36}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#6272a4}.token.punctuation{color:#f8f8f2}.namespace{opacity:.7}.token.constant,.token.deleted,.token.property,.token.symbol,.token.tag{color:#ff79c6}.token.boolean,.token.number{color:#bd93f9}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#50fa7b}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url,.token.variable{color:#f8f8f2}.token.atrule,.token.attr-value,.token.class-name,.token.function{color:#f1fa8c}.token.keyword{color:#8be9fd}.token.important,.token.regex{color:#ffb86c}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}
</style>
</head>
<body>
<h1>Test 1</h1>
<p data-spacing="double">This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1</p>
</body>
</html>

View File

@@ -0,0 +1,7 @@
# Test 1
This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1
---

View File

@@ -0,0 +1,7 @@
Test 1
----------
This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1
----------
Tags:

View File

@@ -50,10 +50,10 @@ const NOTE = {
title: "Real-time sync test note 1"
};
test("edits in a note opened on 2 devices should sync in real-time", async ({
test(`edits in a note opened on 2 devices should sync in real-time`, async ({
browser
}, info) => {
info.setTimeout(60 * 1000);
info.setTimeout(70 * 1000);
const newContent = makeid(24).repeat(2);
const [deviceA, deviceB] = await Promise.all([
@@ -69,16 +69,15 @@ test("edits in a note opened on 2 devices should sync in real-time", async ({
const noteA = await notesA.findNote(NOTE);
await Promise.all([noteA, noteB].map((note) => note?.openNote()));
await notesB.editor.clear();
await actAndSync([deviceA, deviceB], notesB.editor.clear());
expect(await notesA.editor.getContent("text")).toBe("");
expect(await notesB.editor.getContent("text")).toBe("");
await actAndSync([deviceA, deviceB], notesB.editor.setContent(newContent));
const [afterContentA, afterContentB] = await Promise.all(
[notesA, notesB].map((notes) => notes?.editor.getContent("text"))
);
expect(noteA).toBeDefined();
expect(noteB).toBeDefined();
expect(afterContentA).toBe(newContent);
expect(afterContentB).toBe(newContent);
expect(await notesA.editor.getContent("text")).toBe(newContent);
expect(await notesB.editor.getContent("text")).toBe(newContent);
});
function makeid(length: number) {

View File

@@ -431,7 +431,7 @@ function toIEditor(editor: Editor): IEditor {
tr.setMeta("preventSave", true);
return true;
})
.setContent(content, true, { preserveWhitespace: true })
.setContent(content, false, { preserveWhitespace: true })
.setTextSelection({
from,
to