Skip to content

Commit d75c199

Browse files
committed
fix: one simple e2e test
1 parent 182bb49 commit d75c199

File tree

6 files changed

+507
-11
lines changed

6 files changed

+507
-11
lines changed

web/cypress.config.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { fsConfig } from "@dzcode.io/utils/dist/config";
2+
import { defineConfig } from "cypress";
3+
4+
export default defineConfig({
5+
e2e: {
6+
baseUrl: fsConfig("development").web.url,
7+
supportFile: false,
8+
specPattern: "src/_e2e-test/tests/**/*.spec.{js,jsx,ts,tsx}",
9+
downloadsFolder: "src/_e2e-test/downloads",
10+
videosFolder: "src/_e2e-test/videos",
11+
screenshotsFolder: "src/_e2e-test/screenshots",
12+
},
13+
});

web/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@types/react": "^18.3.3",
2424
"@types/react-dom": "^18.3.0",
2525
"autoprefixer": "^10.4.19",
26+
"cypress": "^13.14.1",
2627
"daisyui": "^4.12.10",
2728
"globals": "^15.8.0",
2829
"postcss": "^8.4.39",
@@ -32,7 +33,8 @@
3233
"react-router-dom": "^6.24.1",
3334
"sitemap": "^7.1.1",
3435
"tailwindcss": "^3.4.4",
35-
"typescript-eslint": "^7.15.0"
36+
"typescript-eslint": "^7.15.0",
37+
"wait-on": "^8.0.0"
3638
},
3739
"engines": {
3840
"node": ">=16",
@@ -58,6 +60,7 @@
5860
"clean:alone": "rimraf dist coverage bundle node_modules/.cache",
5961
"deploy": "yarn generate:sitemap && rimraf ./firebase/public && cpx -u \"./bundle/**/*\" ./firebase/public && cd ./firebase && firebase deploy --only hosting:dzcode.io --token \"$FIREBASE_TOKEN\"",
6062
"deploy:stg": "yarn generate:sitemap && rimraf ./firebase/public && cpx -u \"./bundle/**/*\" ./firebase/public && cd ./firebase && firebase deploy --only hosting:stage.dzcode.io --token \"$FIREBASE_TOKEN\"",
63+
"e2e:dev": "yarn wait-on http://localhost:8080/ && yarn cypress open",
6164
"generate:bundle-info": "ts-node ../packages/tooling/bundle-info.ts",
6265
"generate:sentry-release": "ts-node ../packages/tooling/sentry-release.ts web bundle",
6366
"generate:sitemap": "cross-env TS_NODE_SKIP_PROJECT=true ts-node --compilerOptions \"{\\\"baseUrl\\\": \\\".\\\"}\" src/_build/sitemap.ts",

web/rsbuild.config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export default defineConfig({
2424
html: {
2525
template: "./src/_entry/main.html",
2626
},
27+
server: {
28+
port: 8080,
29+
},
2730
output: {
2831
distPath: {
2932
root: "./bundle",
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference types="cypress" />
2+
3+
describe("Landing Page", () => {
4+
it("should redirect to `/faq` when clicking on `FAQ`", () => {
5+
cy.visit("/");
6+
cy.get('[data-testid="top-bar-to:/faq"]').click();
7+
cy.url().should("contain", "/faq");
8+
});
9+
});

web/src/components/top-bar.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export function TopBar({ version, links }: TopBarProps): JSX.Element {
115115
key={index}
116116
role="tab"
117117
className={`tab ${activeIndex === index ? "tab-active" : ""}`}
118+
data-testid={`top-bar-to:${href}`}
118119
>
119120
<Locale {...{ localeKey }} />
120121
</Link>

0 commit comments

Comments
 (0)