Skip to content

Commit a5662ca

Browse files
committed
test: nextjs related simple tests
1 parent 7f62dbe commit a5662ca

31 files changed

+201
-481
lines changed

apps/playground/app/api/hello/route.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

apps/playground/app/page.tsx

Lines changed: 0 additions & 416 deletions
This file was deleted.

apps/playground/.eslintrc.json renamed to apps/tester/.eslintrc.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"extends": [
3+
"plugin:cypress/recommended",
34
"plugin:@nx/react-typescript",
45
"next",
56
"next/core-web-vitals",
@@ -16,7 +17,7 @@
1617
{
1718
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
1819
"rules": {
19-
"@next/next/no-html-link-for-pages": ["error", "apps/playground/pages"]
20+
"@next/next/no-html-link-for-pages": ["error", "apps/tester/pages"]
2021
}
2122
},
2223
{
@@ -32,6 +33,10 @@
3233
"env": {
3334
"jest": true
3435
}
36+
},
37+
{
38+
"files": ["*.cy.{ts,js,tsx,jsx}", "cypress/**/*.{ts,js,tsx,jsx}"],
39+
"rules": {}
3540
}
3641
]
3742
}
File renamed without changes.

apps/playground/app/layout.tsx renamed to apps/tester/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import './global.css';
22

33
export const metadata = {
4-
title: 'Welcome to playground',
4+
title: 'Welcome to tester',
55
description: 'Generated by create-nx-workspace',
66
};
77

File renamed without changes.

apps/tester/app/page.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import styles from './page.module.css';
2+
3+
export default async function Index() {
4+
/*
5+
* Replace the elements below with your own.
6+
*
7+
* Note: The corresponding styles are in the ./index.css file.
8+
*/
9+
return (
10+
<div className={styles.page}>
11+
<div className="wrapper">
12+
<div className="container">
13+
<div id="welcome">
14+
<h1>
15+
<span> Hello there, </span>
16+
Welcome tester 👋
17+
</h1>
18+
</div>
19+
</div>
20+
</div>
21+
</div>
22+
);
23+
}

apps/playground/app/state/page.tsx renamed to apps/tester/app/state/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { StateChanger } from '../../components/StateChanger';
33
export default async function Index() {
44
return (
55
<div>
6-
<h1>Welcome to playground!</h1>
6+
<h1>Welcome to tester!</h1>
77

88
<StateChanger />
99
</div>
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ButtonHTMLAttributes } from 'react';
2-
3-
export type ButtonProps = React.ComponentPropsWithoutRef<"button">;
4-
5-
export function Button(props: ButtonProps) {
6-
return <button
7-
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
8-
{...props}
9-
/>;
10-
}
1+
import { ButtonHTMLAttributes } from 'react';
2+
3+
export type ButtonProps = React.ComponentPropsWithoutRef<"button">;
4+
5+
export function Button(props: ButtonProps) {
6+
return <button
7+
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
8+
{...props}
9+
/>;
10+
}

apps/playground/components/StateChanger.tsx renamed to apps/tester/components/StateChanger.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,35 @@ export function StateChanger() {
1919
.passthrough(),
2020
);
2121

22-
const [age, setAge] = useState(11);
23-
2422
const router = useRouter();
2523

2624
return (
2725
<div className="max-w-6xl mx-auto">
2826
<div className="flex gap-4">
2927
<Button
28+
id="set-age-10"
3029
onClick={() => {
3130
setValue('age', 10);
3231
}}
3332
>
3433
setValue('age', 10)
3534
</Button>
3635
<Button
36+
id="set-birth-date"
3737
onClick={() => {
38-
setValue('age', age);
39-
setAge(age + 1);
40-
}}
41-
>
42-
setValue('age', setAge)
43-
</Button>
44-
<Button
45-
onClick={() => {
46-
setValue('birthDate', new Date());
38+
setValue('birthDate', new Date('2021-01-01T10:00:00.000Z'));
4739
}}
4840
>
4941
setValue('birthDate', new Date());
5042
</Button>
5143
<Button
44+
id="set-everything"
5245
onClick={() => {
53-
setState({ name: 'test', age: 10, birthDate: new Date() });
46+
setState({
47+
name: 'test',
48+
age: 10,
49+
birthDate: new Date('2021-01-01T10:00:00.000Z'),
50+
});
5451
}}
5552
>
5653
{`setState({ name: 'test', age: 10, birthDate: new Date() })`}
@@ -64,6 +61,7 @@ export function StateChanger() {
6461

6562
<div>
6663
<Button
64+
id="router-push"
6765
onClick={() => {
6866
router.push(
6967
`?${new URLSearchParams({
@@ -77,6 +75,7 @@ export function StateChanger() {
7775
</div>
7876
<div>
7977
<Link
78+
id="next-link"
8079
href={`?${new URLSearchParams({
8180
name: 'link/test',
8281
age: '77',

0 commit comments

Comments
 (0)