Skip to content

Commit

Permalink
test(cypress): add e2e for i18n-nextjs and i18n-react (#6218)
Browse files Browse the repository at this point in the history
Co-authored-by: Batuhan Wilhelm <[email protected]>
  • Loading branch information
alicanerdurmaz and BatuhanW authored Aug 5, 2024
1 parent 029cc80 commit bc03bff
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- "packages/**"
- "examples/**"
- "cypress/e2e/**"
types:
- labeled
- synchronize
Expand Down
75 changes: 75 additions & 0 deletions cypress/e2e/i18n-nextjs/all.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/// <reference types="cypress" />
/// <reference types="../../cypress/support" />

Cypress.on("uncaught:exception", () => {
return false;
});

describe("i18n-nextjs", () => {
beforeEach(() => {
cy.clearAllCookies();
cy.clearAllLocalStorage();
cy.clearAllSessionStorage();

cy.interceptGETBlogPosts();
cy.visit("/");
});

it("should change", () => {
cy.wait("@getBlogPosts");

// check the elements are in English which is the default language
cy.get(".ant-menu > .ant-menu-item")
.contains("Blog Posts")
.get(".ant-page-header-heading-left")
.contains("Posts")
.get(".refine-create-button")
.contains("Create")
.get(".ant-table-thead > tr > :nth-child(2)")
.contains("Title")
.get(".ant-table-thead > tr > :nth-child(3)")
.contains("Content")
.get(".ant-table-thead > tr > :nth-child(4)")
.contains("Category")
.get(".ant-table-thead > tr > :nth-child(5)")
.contains("Status")
.get(".ant-table-thead > tr > :nth-child(6)")
.contains("Created At")
.get(".ant-table-thead > tr > :nth-child(7)")
.contains("Actions");

// find the language button
cy.get(".ant-layout-header > .ant-btn")
// should contain English which is the default language
.contains("English")
// hover over the button to show the dropdown
.trigger("mouseover")
// click on the German language
.get(".ant-dropdown-menu-title-content")
.contains("German")
.click()
// should contain German
.get(".ant-layout-header > .ant-btn")
.contains("German");

// check the elements are translated
cy.get(".ant-menu > .ant-menu-item")
.contains("Einträge")
.get(".ant-page-header-heading-left")
.contains("Einträge")
.get(".refine-create-button")
.contains("Erstellen")
.get(".ant-table-thead > tr > :nth-child(2)")
.contains("Titel")
.get(".ant-table-thead > tr > :nth-child(3)")
.contains("Inhalh")
.get(".ant-table-thead > tr > :nth-child(4)")
.contains("Kategorie")
.get(".ant-table-thead > tr > :nth-child(5)")
.contains("Status")
.get(".ant-table-thead > tr > :nth-child(6)")
.contains("Erstellt am")
.get(".ant-table-thead > tr > :nth-child(7)")
.contains("Aktionen");
});
});
63 changes: 63 additions & 0 deletions cypress/e2e/i18n-react/all.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/// <reference types="cypress" />
/// <reference types="../../cypress/support" />

Cypress.on("uncaught:exception", () => {
return false;
});

describe("i18n-react", () => {
beforeEach(() => {
cy.clearAllCookies();
cy.clearAllLocalStorage();
cy.clearAllSessionStorage();

cy.interceptGETPosts();
cy.visit("/");
});

it("should change", () => {
cy.wait("@getPosts");

// check the elements are in English which is the default language
cy.get(".ant-menu > .ant-menu-item")
.contains("Posts")
.get(".ant-page-header-heading-left")
.contains("Posts")
.get(".refine-create-button")
.contains("Create")
.get(".ant-table-thead > tr > :nth-child(2)")
.contains("Title")
.get(".ant-table-thead > tr > :nth-child(3)")
.contains("Category")
.get(".ant-table-thead > tr > :nth-child(4)")
.contains("Actions");

// find the language button
cy.get(".ant-layout-header > .ant-btn")
// should contain English which is the default language
.contains("English")
// hover over the button to show the dropdown
.trigger("mouseover")
// click on the German language
.get(".ant-dropdown-menu-title-content")
.contains("German")
.click()
// should contain German
.get(".ant-layout-header > .ant-btn")
.contains("German");

// check the elements are translated
cy.get(".ant-menu > .ant-menu-item")
.contains("Einträge")
.get(".ant-page-header-heading-left")
.contains("Einträge")
.get(".refine-create-button")
.contains("Erstellen")
.get(".ant-table-thead > tr > :nth-child(2)")
.contains("Titel")
.get(".ant-table-thead > tr > :nth-child(3)")
.contains("Kategorie")
.get(".ant-table-thead > tr > :nth-child(4)")
.contains("Aktionen");
});
});

0 comments on commit bc03bff

Please sign in to comment.