Skip to content

Commit 2bae552

Browse files
committed
chore: fix cypress tes
1 parent 8397a7f commit 2bae552

6 files changed

Lines changed: 40 additions & 47 deletions

File tree

cypress/e2e/basic_tests.cy.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
describe("Integration Tests", () => {
22
beforeEach(() => {
3-
cy.visit("http://localhost:3000");
3+
cy.visit("/");
44
});
55

66
it("Home page is loaded", () => {
@@ -31,9 +31,13 @@ describe("Integration Tests", () => {
3131
// homepage get started button clicked
3232
cy.contains("GET STARTED").click();
3333

34-
// show default docs page
35-
cy.contains("Quick Start").click();
34+
// Navigate through the sidebar link. The page title is "Quick Start",
35+
// but the docs page also has footer links with the same text.
36+
cy.get(".theme-doc-sidebar-container")
37+
.contains("a", "CLI Quick Start")
38+
.click();
3639

40+
cy.url().should("include", "/docs/doc-cli-install-quick-start");
3741
cy.contains("Detailed usage");
3842
});
39-
});
43+
});

cypress/e2e/image_tests.cy.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe("Documentation Page Images", () => {
5555
}).as('imageRequestCounter');
5656

5757
// Visit the page and wait for it to load
58-
cy.visit(`http://localhost:3000${page.url}`, {
58+
cy.visit(page.url, {
5959
timeout: 10000,
6060
retryOnStatusCodeFailure: true
6161
});
@@ -108,14 +108,14 @@ describe("Documentation Page Images", () => {
108108
});
109109

110110
it('should have proper alt text for all images', () => {
111-
cy.visit(`http://localhost:3000/docs`, {
111+
cy.visit("/docs", {
112112
timeout: 10000,
113113
retryOnStatusCodeFailure: true
114114
});
115115

116116
cy.get('main', { timeout: 10000 }).should('be.visible');
117117

118-
cy.get('img').each(($img, index) => {
118+
cy.get('.theme-doc-markdown img:visible').each(($img, index) => {
119119
const imgId = `img-alt-${index}`;
120120
cy.wrap($img).as(imgId);
121121

@@ -126,14 +126,14 @@ describe("Documentation Page Images", () => {
126126
});
127127

128128
it('should load images with correct dimensions', () => {
129-
cy.visit(`http://localhost:3000/docs`, {
129+
cy.visit("/docs", {
130130
timeout: 10000,
131131
retryOnStatusCodeFailure: true
132132
});
133133

134134
cy.get('main', { timeout: 10000 }).should('be.visible');
135135

136-
cy.get('img').each(($img, index) => {
136+
cy.get('.theme-doc-markdown img:visible').each(($img, index) => {
137137
const imgId = `img-dim-${index}`;
138138
cy.wrap($img).as(imgId);
139139

@@ -152,4 +152,4 @@ describe("Documentation Page Images", () => {
152152
});
153153
});
154154
});
155-
});
155+
});

cypress/e2e/link_tests.cy.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ interface SidebarLink {
55

66
describe("Link Tests", () => {
77
beforeEach(() => {
8-
cy.visit("http://localhost:3000");
8+
cy.visit("/");
99
});
1010

1111
describe("Navigation Links", () => {
@@ -22,27 +22,24 @@ describe("Link Tests", () => {
2222
});
2323

2424
it("should have working footer links", () => {
25-
// Test Learn section links
26-
cy.contains("Quick Start").click();
27-
cy.url().should("include", "/docs");
28-
cy.go("back");
29-
30-
cy.contains("Getting Started With CLI").click();
31-
cy.url().should("include", "/docs/doc-cli-install-quick-start");
32-
cy.go("back");
33-
34-
// Test Decorate section links
35-
cy.contains("Color").click();
36-
cy.url().should("include", "/docs/doc-color");
37-
cy.go("back");
25+
const footerLinks: SidebarLink[] = [
26+
{ text: "Quick Start", url: "/docs" },
27+
{ text: "Getting Started With CLI", url: "/docs/doc-cli-install-quick-start" },
28+
{ text: "Color", url: "/docs/doc-color" },
29+
{ text: "Border", url: "/docs/doc-border-design" },
30+
{ text: "Alignment", url: "/docs/doc-alignment" },
31+
];
3832

39-
cy.contains("Border").click();
40-
cy.url().should("include", "/docs/doc-border-design");
41-
cy.go("back");
33+
footerLinks.forEach((link: SidebarLink) => {
34+
cy.visit("/");
35+
cy.get("footer")
36+
.contains("a", link.text)
37+
.should("have.attr", "href")
38+
.and("include", link.url);
4239

43-
cy.contains("Alignment").click();
44-
cy.url().should("include", "/docs/doc-alignment");
45-
cy.go("back");
40+
cy.get("footer").contains("a", link.text).click();
41+
cy.url().should("include", link.url);
42+
});
4643
});
4744

4845
it("should have working external links in footer", () => {
@@ -90,7 +87,7 @@ describe("Link Tests", () => {
9087
];
9188

9289
sidebarLinks.forEach((link: SidebarLink) => {
93-
cy.contains(link.text).click();
90+
cy.get(".theme-doc-sidebar-container").contains("a", link.text).click();
9491
cy.url().should("include", link.url);
9592
// Verify page content is loaded
9693
cy.get("main").should("exist");
@@ -120,4 +117,4 @@ describe("Link Tests", () => {
120117
.should("have.attr", "rel", "noopener noreferrer");
121118
});
122119
});
123-
});
120+
});

cypress/e2e/page_tests.cy.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,9 @@ describe("Testing Each Documentation Page", () => {
104104
title: "Typescript",
105105
headlines: ["You can easily import these in typescript"]
106106
},
107-
{
108-
title: "Quick Start",
109-
headlines: ["Synopsis", "Installation", "Basic Example", "Detailed usage"]
110-
},
111107
{
112108
title: "CLI Quick Start",
113-
headlines: ["Installation", "Basic Example"]
109+
headlines: ["Synopsis", "Installation", "Basic Example", "Detailed usage"]
114110
},
115111
{
116112
title: "Homebrew",
@@ -135,13 +131,13 @@ describe("Testing Each Documentation Page", () => {
135131

136132
beforeEach(() => {
137133
// Go to docs page before each test
138-
cy.visit("http://localhost:3000");
134+
cy.visit("/");
139135
cy.contains("GET STARTED").click();
140136
});
141137

142138
pages.forEach((page: PageTestInterface) => {
143139
it(`${page.title} page contains correct headlines`, () => {
144-
cy.contains(page.title).click();
140+
cy.get(".theme-doc-sidebar-container").contains("a", page.title).click();
145141

146142
// Check each headline
147143
page.headlines.forEach((headline: string) => {
@@ -161,4 +157,4 @@ describe("Testing Each Documentation Page", () => {
161157
}
162158
});
163159
});
164-
});
160+
});

cypress/e2e/site_integrity_tests.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ interface MainPage {
44

55
describe("Site Integrity Tests", () => {
66
beforeEach(() => {
7-
cy.visit("http://localhost:3000");
7+
cy.visit("/");
88
});
99

1010
describe("Basic Navigation", () => {
@@ -107,4 +107,4 @@ describe("Site Integrity Tests", () => {
107107
});
108108
});
109109
});
110-
});
110+
});

cypress/e2e/url_tests.cy.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,9 @@ describe("Testing Each Documentation Page", () => {
140140
}
141141
];
142142

143-
beforeEach(() => {
144-
cy.visit("http://localhost:3000");
145-
});
146-
147143
pages.forEach((page: PageTest) => {
148144
it(`${page.title} page contains correct headlines`, () => {
149-
cy.visit(`http://localhost:3000${page.url}`);
145+
cy.visit(page.url);
150146

151147
// Check each headline
152148
page.headlines.forEach((headline: string) => {

0 commit comments

Comments
 (0)