1
- import { ArrowLeft , Plus } from 'lucide-react'
2
- import Link from 'next/link'
3
1
import { notFound } from 'next/navigation'
4
2
5
- import { Button } from '@/components/ui/button'
6
- import {
7
- Dialog ,
8
- DialogContent ,
9
- DialogDescription ,
10
- DialogHeader ,
11
- DialogTitle ,
12
- DialogTrigger ,
13
- } from '@/components/ui/dialog'
14
- import { Input } from '@/components/ui/input'
15
- import { Tabs , TabsContent , TabsList , TabsTrigger } from '@/components/ui/tabs'
3
+ import { SuiteDetails } from '@/components/suite/SuiteDetails'
16
4
17
- import { HistoryTab } from '../../../components/suite/HistoryTab'
18
- import { TestsTab } from '../../../components/suite/TestsTab'
19
5
import { createTestAction , deleteSuiteAction , runSuiteAction } from './actions'
20
6
import { loader } from './loader'
21
7
@@ -34,110 +20,7 @@ export default async function SuitePage({ params }: { params: Promise<{ suiteId:
34
20
35
21
const runSuite = runSuiteAction . bind ( null , suiteIdNum )
36
22
const deleteSuite = deleteSuiteAction . bind ( null , suiteIdNum )
23
+ const createTest = createTestAction . bind ( null , suiteIdNum )
37
24
38
- return (
39
- < div className = "min-h-screen bg-gray-50" >
40
- < div className = "max-w-6xl mx-auto px-6 py-8" >
41
- { /* Header */ }
42
- < div className = "mb-8" >
43
- < Link
44
- href = "/"
45
- className = "inline-flex items-center gap-2 text-gray-600 hover:text-gray-800 mb-4 transition-colors"
46
- >
47
- < ArrowLeft className = "w-4 h-4" />
48
- Back to Suites
49
- </ Link >
50
-
51
- < div className = "flex items-start gap-4" >
52
- < div className = "mr-auto" >
53
- < h1 className = "text-4xl font-bold text-gray-900 mb-2" > { suite . name } </ h1 >
54
- < p className = "text-md text-gray-500" > { suite . domain } </ p >
55
- </ div >
56
-
57
- < form action = { runSuite } >
58
- < Button type = "submit" > Run Suite</ Button >
59
- </ form >
60
-
61
- < form action = { deleteSuite } >
62
- < Button type = "submit" variant = "destructive" >
63
- Delete
64
- </ Button >
65
- </ form >
66
- </ div >
67
- </ div >
68
-
69
- { /* Body with Tabs */ }
70
- < Tabs defaultValue = "history" className = "space-y-6" >
71
- < div className = "flex items-center justify-between" >
72
- < TabsList >
73
- < TabsTrigger value = "history" > History</ TabsTrigger >
74
- < TabsTrigger value = "tests" > Tests</ TabsTrigger >
75
- </ TabsList >
76
-
77
- < CreateTestDialog suiteId = { suiteIdNum } />
78
- </ div >
79
-
80
- < TabsContent value = "history" >
81
- < HistoryTab suite = { suite } />
82
- </ TabsContent >
83
-
84
- < TabsContent value = "tests" >
85
- < TestsTab suite = { suite } suiteId = { suiteIdNum } />
86
- </ TabsContent >
87
- </ Tabs >
88
- </ div >
89
- </ div >
90
- )
91
- }
92
-
93
- function CreateTestDialog ( { suiteId } : { suiteId : number } ) {
94
- const action = createTestAction . bind ( null , suiteId )
95
-
96
- return (
97
- < Dialog >
98
- < DialogTrigger asChild >
99
- < Button variant = "outline" className = "ml-auto" >
100
- < Plus className = "w-4 h-4" />
101
- Create Test
102
- </ Button >
103
- </ DialogTrigger >
104
-
105
- < DialogContent >
106
- < DialogHeader >
107
- < DialogTitle > Create New Test</ DialogTitle >
108
- < DialogDescription >
109
- Add a new test to this suite. Provide a name and description of what should be tested.
110
- </ DialogDescription >
111
- </ DialogHeader >
112
-
113
- < form action = { action } className = "space-y-4" >
114
- < div >
115
- < label htmlFor = "label" className = "block text-sm font-medium text-gray-700 mb-1" >
116
- Test Name
117
- </ label >
118
- < Input id = "label" name = "label" type = "text" placeholder = "e.g., Login functionality test" required />
119
- </ div >
120
-
121
- < div >
122
- < label htmlFor = "task" className = "block text-sm font-medium text-gray-700 mb-1" >
123
- Task Description
124
- </ label >
125
- < Input
126
- id = "task"
127
- name = "task"
128
- type = "text"
129
- placeholder = "e.g., Verify user can log in with valid credentials"
130
- required
131
- />
132
- </ div >
133
-
134
- < input type = "hidden" name = "suiteId" value = { suiteId } />
135
-
136
- < div className = "flex justify-end gap-2" >
137
- < Button type = "submit" > Create Test</ Button >
138
- </ div >
139
- </ form >
140
- </ DialogContent >
141
- </ Dialog >
142
- )
25
+ return < SuiteDetails suite = { suite } runSuite = { runSuite } deleteSuite = { deleteSuite } createTest = { createTest } />
143
26
}
0 commit comments