Skip to content

Commit

Permalink
Merge pull request #207 from OpenCovenant/settings_cypress_tests
Browse files Browse the repository at this point in the history
All tests passed without any issues.
  • Loading branch information
AndersonCeci committed Jul 31, 2023
2 parents 1866a05 + 8131573 commit b62f9d6
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cypress/e2e/check-if-page-settings-opens-from-offcanvas.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe("Settings page should open from offcanvas page", () => {
beforeEach(() => {
cy.visit("/");
});

it("will click on the \"cilesimet\" located on offcanvas and check if it loaded the /settings page ", () => {
cy.get('[data-test="navbar-toggler-icon"]').click();
cy.get('[data-test="settings-button"]').click();
cy.url().should("include", "/settings");
});
});
19 changes: 19 additions & 0 deletions cypress/e2e/disabling-a-marking-persisted-after-reloading.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
describe("Enabling/disabling a marking is persisted after reloading.", () => {
beforeEach(() => {
cy.visit("/settings");
});

it("will uncheck all the switch on the /settings page reload the page and check if they are still disabled ", () => {
cy.get('[data-test="switch-check-testing"]').should('be.checked');
cy.get('[data-test="switch-check-testing"]').click({ multiple: true, force:true });
cy.get('[data-test="switch-check-testing"]').should('not.be.checked');
cy.reload();
cy.get('[data-test="switch-check-testing"]').should('not.be.checked');
cy.get('[data-test="switch-check-testing"]').click({ multiple: true, force:true });
cy.get('[data-test="switch-check-testing"]').should('be.checked');
cy.reload();
cy.get('[data-test="switch-check-testing"]').should('be.checked');

});
});

10 changes: 10 additions & 0 deletions cypress/e2e/gear-icon-takes-to-settings.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
describe("Clicking on the gear icon takes you to /settings page", () => {
beforeEach(() => {
cy.visit("/");
});

it("will click on gear icon and check if it goes to /settings", () => {
cy.get('[data-test="gear-button-testing"]').click();
cy.url().should("include", "/settings");
});
});
45 changes: 45 additions & 0 deletions cypress/e2e/no-markings-after-disable.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
describe("A marking type does not appear after being disabled.", () => {
beforeEach(() => {
cy.visit("/settings");
});

it("will disable all the marking types and check if they appeared on the main page", () => {
cy.get('[data-test="switch-check-testing"]').should('be.checked');
cy.get('[data-test="switch-check-testing"]').click({ multiple: true, force:true });
cy.get('[data-test="switch-check-testing"]').should('not.be.checked');
cy.visit("/");
cy.get('[data-test="editor"]').type("Pra shkoi tek zyra. ");
cy.get("span.typo").contains("gabime shkrimi").should("exist");
cy.get(".list-group-item b")
.contains("shkrim pa gabime")
.should("exist");
cy.get(".list-group-item span")
.contains(
"shenjime për fjalë të shkruara gabim, gabime fonetikore, shenja pikësimi"
)
.should("exist");
cy.get('[data-test="editor"]').type('{enter}');
cy.get('[data-test="editor"]').type("Pra kaq.");
cy.get("span.typo").contains("gabime shkrimi").should("exist");
cy.get(".list-group-item b")
.contains("shkrim pa gabime")
.should("exist");
cy.get(".list-group-item span")
.contains(
"shenjime për fjalë të shkruara gabim, gabime fonetikore, shenja pikësimi"
)
.should("exist");
cy.get('[data-test="editor"]').clear();
cy.visit("/settings");
cy.get('[data-test="switch-check-testing"]').should('not.be.checked');
cy.get('[data-test="switch-check-testing"]').click({ multiple: true, force:true });
cy.get('[data-test="switch-check-testing"]').should('be.checked');
cy.visit("/");
cy.get('[data-test="editor"]').type("Pra shkoi tek zyra. ");
cy.get('[data-test="text-marking-span"]').contains("tek").should("exist");
cy.get('[data-test="editor"]').type('{enter}');


});
});

46 changes: 46 additions & 0 deletions mock-server/data/generateMarkingsForParagraphs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,52 @@
}
]
}
},
{
"request": "<p>Pra shkoi tek zyra.&nbsp;</p>",
"response": {
"text": "<p>Pra shkoi tek zyra.&nbsp;</p>",
"textMarkings": [
{
"id": "te-dhe-tek",
"from": 10,
"to": 13,
"type": "typo",
"subtype": "gabim gramatikor, p\u00ebrdorimi i parafjal\u00ebve \"te\" dhe \"tek\"",
"description": "parafjala \"te\" p\u00ebrdoret kur fjala vijuese fillon me bashk\u00ebtingellore, nd\u00ebrsa parafjala \"tek\" p\u00ebrdoret kur fjala vijuese fillon me zanore ",
"suggestions": [
{
"display": "te zyra",
"action": "te"
}
],
"paragraph": 0
}
]
}
},
{
"request": "<p>Kishte buk\\u00eb, sallam, etj.</p>",
"response": {
"text": "<p>Kishte buk\u00eb, sallam, etj.</p>",
"textMarkings": [
{
"id": "pa-presje-para-etj",
"from": 19,
"to": 20,
"type": "typo",
"subtype": "gabim gramatikor, shenja pik\u00ebsimi",
"description": "nuk vendoset presje para \"etj\" kur ajo mbyll nj\u00eb varg gjymtyr\u00ebsh homogjen\u00eb",
"suggestions": [
{
"display": " ",
"action": ""
}
],
"paragraph": 0
}
]
}
}
]

2 changes: 2 additions & 0 deletions src/app/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'settings-gear-dark-mode': darkModeService.isDarkMode
}"
routerLink="/settings"
data-test="gear-button-testing"
></i>
</div>
</nav>
Expand Down Expand Up @@ -79,6 +80,7 @@ <h5 id="offcanvasStartLabel">penda</h5>
<!-- </div>-->
<div>
<a
data-test="settings-button"
routerLink="/settings"
class="list-group-item list-group-item-action mb-3"
role="button"
Expand Down
1 change: 1 addition & 0 deletions src/app/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ <h5 class="card-title">Cilësimet</h5>
(ngModelChange)="
onMarkingTypeSelection(markingType[0], $event)
"
data-test="switch-check-testing"
/><span class="slider round cursor-pointer"></span>
</label>
<span>{{ markingType[1].description }}</span>
Expand Down

0 comments on commit b62f9d6

Please sign in to comment.