Skip to content

Commit

Permalink
general improvements (#483)
Browse files Browse the repository at this point in the history
* changes

* add m/M shortcut for side menu

* add tests for shortcuts

---------

Co-authored-by: Andi Braimllari <>
  • Loading branch information
AndiBraimllari committed May 6, 2024
1 parent 6f0b26e commit 9d1dd3e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
10 changes: 5 additions & 5 deletions cypress/e2e/general-flows.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ describe("general flows", () => {

it("should mark typos in the editor", () => {
cy.get('[data-test="editor"]').type("gabmim ");
cy.get('[data-test="editor"] > p > .typo').should("be.visible");
cy.get('.typo').should("be.visible");
});

it("should mark loanwords in the editor", () => {
cy.get('[data-test="editor"]').type("lider ");
cy.get('[data-test="editor"] > p > .loanword').should("be.visible");
cy.get('.loanword').should("be.visible");
});

it("should open and close the side menu as expected", () => {
Expand Down Expand Up @@ -207,7 +207,7 @@ describe("general flows", () => {
.find('[data-test="blur-marking-button"]')
.click();
cy.get(".typo").first().click();
cy.get("#editor > p > .typo")
cy.get(".typo")
.should("have.length", 3)
.should("be.visible");

Expand All @@ -216,15 +216,15 @@ describe("general flows", () => {
.first()
.click();
cy.get(".typo").first().click();
cy.get("#editor > p > .typo")
cy.get(".typo")
.should("have.length", 2)
.should("be.visible");

cy.get('[data-test="marking-card"]')
.find('[data-test="suggestion"]')
.first()
.click();
cy.get("#editor > p > .typo")
cy.get(".typo")
.should("have.length", 1)
.should("be.visible");

Expand Down
12 changes: 12 additions & 0 deletions cypress/e2e/shortcuts.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ describe("Shortcuts", () => {
});
});

cy.get("#offcanvasStart").should("not.be.visible");
cy.get("body").type("m");
cy.get("#offcanvasStart").should("be.visible");
cy.get("body").type("M");
cy.get("#offcanvasStart").should("not.be.visible");

cy.get('[data-test="modal-dialog"]').should("not.be.visible");
cy.get("body").type("h");
cy.get('[data-test="modal-dialog"]').should("be.visible");
Expand Down Expand Up @@ -76,6 +82,12 @@ describe("Shortcuts", () => {
});
});

cy.get("#offcanvasStart").should("not.be.visible");
cy.get("body").type("M");
cy.get("#offcanvasStart").should("be.visible");
cy.get("body").type("m");
cy.get("#offcanvasStart").should("not.be.visible");

cy.get('[data-test="modal-dialog"]').should("not.be.visible");
cy.get("body").type("h");
cy.get('[data-test="modal-dialog"]').should("be.visible");
Expand Down
1 change: 1 addition & 0 deletions src/app/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
>
<div class="header-name-gear-icon">
<button
id='off-canvas-start-button'
class="off-canvas-start-button"
[ngClass]="{
'header-button-dark-mode': darkModeService.isDarkMode
Expand Down
2 changes: 1 addition & 1 deletion src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@
processedText?.markings?.[
highlightedMarkingIndex
]?.type
}}"
}}-marking-header"
data-test="highlighted-marking"
>{{
getTextOfMarking(highlightedMarkingIndex)
Expand Down
4 changes: 4 additions & 0 deletions src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,10 @@ export class HomeComponent implements AfterViewInit, OnDestroy {
this.copyToClipboard();
return;
}
case 'm':
case 'M': {
document.getElementById('off-canvas-start-button')!.click();
}
}
}

Expand Down

0 comments on commit 9d1dd3e

Please sign in to comment.