From 38335175e7ff26a616cbd530aa994dce89e402b4 Mon Sep 17 00:00:00 2001
From: Mikhail Abramov <unsortedhashsets@gmail.com>
Date: Fri, 11 Aug 2023 12:09:13 +0200
Subject: [PATCH] Add multipple breakpoints to editor

---
 page-objects/src/components/editor/TextEditor.ts | 12 ++++++++----
 test/test-project/src/test/debug/debug-test.ts   | 14 ++++++++++++--
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/page-objects/src/components/editor/TextEditor.ts b/page-objects/src/components/editor/TextEditor.ts
index f8e460e3f..6a66358fd 100644
--- a/page-objects/src/components/editor/TextEditor.ts
+++ b/page-objects/src/components/editor/TextEditor.ts
@@ -13,6 +13,7 @@ export class BreakpointError extends Error { }
  * Page object representing the active text editor
  */
 export class TextEditor extends Editor {
+    breakPoints: number[] = [];
 
     /**
      * Find whether the active editor has unsaved changes
@@ -433,15 +434,18 @@ export class TextEditor extends Editor {
         const breakpointContainer = TextEditor.versionInfo.version >= '1.80.0' ? await this.findElement(By.className('glyph-margin-widgets')) : lineOverlay;
         const breakPoint = await breakpointContainer.findElements(TextEditor.locators.TextEditor.breakpoint.generalSelector);
         if (breakPoint.length > 0) {
-            await breakPoint[0].click();
-            await new Promise(res => setTimeout(res, 200));
-            return false;
+            if (this.breakPoints.indexOf(line) != -1) {
+                await breakPoint[this.breakPoints.indexOf(line)].click();
+                await new Promise(res => setTimeout(res, 200));
+                this.breakPoints.splice(this.breakPoints.indexOf(line), 1);
+                return false;
+            }
         }
-
         const noBreak = await breakpointContainer.findElements(TextEditor.locators.TextEditor.debugHint);
         if (noBreak.length > 0) {
             await noBreak[0].click();
             await new Promise(res => setTimeout(res, 200));
+            this.breakPoints.push(line);
             return true;
         }
         return false;
diff --git a/test/test-project/src/test/debug/debug-test.ts b/test/test-project/src/test/debug/debug-test.ts
index 6cbbf985e..5ed2ce8ce 100644
--- a/test/test-project/src/test/debug/debug-test.ts
+++ b/test/test-project/src/test/debug/debug-test.ts
@@ -68,7 +68,12 @@ describe('Debugging', function () {
             await new Promise(res => setTimeout(res, 5000));
         });
 
-        it('set a breakpoint', async function () {
+        it('set first breakpoint', async function () {
+            const result = await editor.toggleBreakpoint(line + 1);
+            expect(result).to.be.true;
+        });
+
+        it('set second breakpoint', async function () {
             const result = await editor.toggleBreakpoint(line);
             expect(result).to.be.true;
         });
@@ -221,7 +226,12 @@ describe('Debugging', function () {
             await editor.getDriver().wait(until.elementIsNotVisible(debugBar));
         });
 
-        it('remove the breakpoint', async function () {
+        it('remove the second breakpoint', async function () {
+            const result = await editor.toggleBreakpoint(line + 1);
+            expect(result).to.be.false;
+        });
+
+        it('remove the first breakpoint', async function () {
             const result = await editor.toggleBreakpoint(line);
             expect(result).to.be.false;
         });