Skip to content

Commit dca20e3

Browse files
committed
NEX-127: Fix cypress tests
1 parent 173300a commit dca20e3

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

next/cypress/e2e/template.cy.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,40 @@
22

33
describe("Frontend test for Login and Sending Message", () => {
44
it("Logs in and is able to fill the webform", () => {
5-
cy.visit("https://frontend.lndo.site/auth/login?callbackUrl=%2Fen%2F");
6-
cy.get("input#username").type("testuser1");
7-
cy.get("input#password").type("test").type("{enter}");
5+
cy.visit("https://frontend.lndo.site/auth/login?callbackUrl=%2F");
6+
cy.get('input[name="username"]').type("testuser1");
7+
cy.get('input[name="password"]').type("test").type("{enter}");
88
cy.wait(3000);
9-
cy.get("input#name").type("Mario");
10-
cy.get("input#email").type("[email protected]");
11-
cy.get("textarea#message").type("hello hello!");
12-
cy.get("input#subject").type("cypress testing 101").type("{enter}");
9+
cy.get('input[name="name"]').type("Mario");
10+
cy.get('input[name="email"]').type("[email protected]");
11+
cy.get('textarea[name="message"]').type("hello from Cypress!");
12+
cy.get('input[name="subject"]').type("cypress testing 101").type("{enter}");
1313
cy.wait(1000);
1414
});
1515
});
1616

17-
// describe("Frontend Test for Search Functionality", () => {
18-
// it("Opens the page, performs search, and verifies search results", () => {
19-
// // Navigating to the main page and clicking on Search button
20-
// cy.visit("https://frontend.lndo.site");
21-
// cy.get('a[href="/search"]').click();
22-
// cy.wait(500);
23-
// // Searching for string "Drupal"
24-
// cy.get("[data-transaction-name='search input']").type("Drupal");
25-
// cy.get("[data-transaction-name='search submit']").click();
26-
// // Waiting for the search results to load
27-
// cy.wait(1000);
28-
// // Verifying results
29-
// cy.get(".sui-results-container").should("be.visible");
30-
// cy.contains("Drupal and Next.js can be used together").should("be.visible");
31-
// });
32-
// });
17+
describe("Frontend Test for Search Functionality", () => {
18+
it("Opens the page, performs search, and verifies search results", () => {
19+
// Navigating to the main page and clicking on Search button
20+
cy.visit("https://frontend.lndo.site/search");
21+
cy.wait(1000);
22+
// Searching for an article:
23+
cy.get("input[type=search]").type("Example article");
24+
// Waiting for the search results to load
25+
cy.wait(1000);
26+
// Verifying results
27+
cy.get(".ais-Hits-item").should("be.visible");
28+
cy.contains("Example Article: A Step-by-Step Guide to [Topic]").should(
29+
"be.visible",
30+
);
31+
});
32+
});
3333

3434
describe("Frontend Test for Language Switching", () => {
3535
it("Opens the page, switches language and verifies it", () => {
3636
// Navigating to the main page and clicking on Language button
3737
cy.visit("https://frontend.lndo.site");
38-
cy.contains("English").click({ force: true });
38+
cy.get('[data-language-name="English"]').click({ force: true });
3939
cy.wait(500);
4040
// Clicking through the language options and checking translations
4141
cy.contains("Suomi").click({ force: true });

next/src/components/header/language-switcher.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ export function LanguageSwitcher() {
2121
const activeLocale = useLocale();
2222
const params = useParams();
2323

24+
console.log(languageLinks[activeLocale]);
25+
2426
return (
2527
<DropdownMenu>
2628
<span className="sr-only">{t("language-switcher")}</span>
27-
<DropdownMenuTrigger asChild>
29+
<DropdownMenuTrigger
30+
asChild
31+
data-language-name={languageLinks[activeLocale].name}
32+
>
2833
<div className="capitalize cursor-pointer hover:underline">
2934
<span className="sr-only sm:not-sr-only sm:mr-2 sm:inline">
3035
{languageLinks[activeLocale].name}

0 commit comments

Comments
 (0)