@@ -39,7 +39,7 @@ test.describe('Ghost Explore', () => {
39
39
} ) ;
40
40
} ) ;
41
41
42
- test ( 'can choose to share growth data' , async ( { page} ) => {
42
+ test ( 'can share growth data with Ghost Explore ' , async ( { page} ) => {
43
43
const { lastApiRequests} = await mockApi ( { page, requests : {
44
44
...globalDataRequests ,
45
45
browseSettings : {
@@ -67,28 +67,79 @@ test.describe('Ghost Explore', () => {
67
67
const mainToggle = section . getByTestId ( 'explore-toggle' ) ;
68
68
await expect ( mainToggle ) . toBeChecked ( ) ;
69
69
70
- // Preview should be visible
71
- const preview = section . getByTestId ( 'explore-preview' ) ;
72
- await expect ( preview ) . toBeVisible ( ) ;
73
- await expect ( preview . getByText ( 'Preview' ) ) . toBeVisible ( ) ;
74
- await expect ( preview . getByText ( 'Test Site' ) ) . toBeVisible ( ) ;
75
- await expect ( preview . getByText ( 'Thoughts, stories and ideas' ) ) . toBeVisible ( ) ;
76
- await expect ( preview . getByText ( 'test.com' ) ) . toBeVisible ( ) ;
77
-
78
- // Growth data toggle should be visible and off
70
+ // Growth data toggle should be off
79
71
const growthDataToggle = section . getByTestId ( 'explore-growth-toggle' ) ;
80
- await expect ( growthDataToggle ) . toBeVisible ( ) ;
81
72
await expect ( growthDataToggle ) . not . toBeChecked ( ) ;
82
73
83
- // Turn on growth data sharing
74
+ // Enable growth data sharing
84
75
await growthDataToggle . click ( ) ;
85
76
86
- // Verify the API call to disable explore_ping_growth
77
+ // Verify the API call to enable explore_ping_growth
87
78
expect ( lastApiRequests . editSettings ?. body ) . toEqual ( {
88
79
settings : [ { key : 'explore_ping_growth' , value : true } ]
89
80
} ) ;
90
81
} ) ;
91
82
83
+ test ( 'renders a preview with members count' , async ( { page} ) => {
84
+ await mockApi ( { page, requests : {
85
+ ...globalDataRequests ,
86
+ browseSettings : {
87
+ ...globalDataRequests . browseSettings ,
88
+ response : {
89
+ ...responseFixtures . settings ,
90
+ settings : [
91
+ ...responseFixtures . settings . settings ,
92
+ { key : 'explore_ping' , value : true } ,
93
+ { key : 'explore_ping_growth' , value : true }
94
+ ]
95
+ }
96
+ } ,
97
+ browseMembers : {
98
+ method : 'GET' ,
99
+ path : '/members/?limit=1' ,
100
+ response : {
101
+ members : [ {
102
+ id : '0000000086b42a93546b7315' ,
103
+ uuid : '7e0ae12f-2a44-4117-b825-2c78a1e73260' ,
104
+
105
+ name : 'Emily Langworth'
106
+ } ] ,
107
+ meta : {
108
+ pagination : {
109
+ page : 1 ,
110
+ limit : 1 ,
111
+ pages : 1000 ,
112
+ total : 1000 ,
113
+ next : 2 ,
114
+ prev : null
115
+ }
116
+ }
117
+ }
118
+ }
119
+ } } ) ;
120
+
121
+ await page . goto ( '/' ) ;
122
+
123
+ const section = page . getByTestId ( 'explore' ) ;
124
+ await expect ( section ) . toBeVisible ( ) ;
125
+
126
+ // Check that the preview is rendered correctly
127
+ const preview = section . getByTestId ( 'explore-preview' ) ;
128
+ await expect ( preview ) . toBeVisible ( ) ;
129
+
130
+ // Check site title
131
+ await expect ( preview . getByText ( 'Test Site' ) ) . toBeVisible ( ) ;
132
+
133
+ // Check site description
134
+ await expect ( preview . getByText ( 'Thoughts, stories and ideas' ) ) . toBeVisible ( ) ;
135
+
136
+ // Check site URL (domain)
137
+ await expect ( preview . getByText ( 'test.com' ) ) . toBeVisible ( ) ;
138
+
139
+ // Check members count
140
+ await expect ( preview . getByText ( '1k members' ) ) . toBeVisible ( ) ;
141
+ } ) ;
142
+
92
143
test ( 'can send a testimonial' , async ( { page} ) => {
93
144
const testimonialApiUrl = 'https://mocked.com/api/testimonials' ;
94
145
@@ -153,6 +204,10 @@ test.describe('Ghost Explore', () => {
153
204
await expect ( modal ) . toBeVisible ( ) ;
154
205
await expect ( modal . getByText ( 'Send a testimonial' ) ) . toBeVisible ( ) ;
155
206
207
+ // Check that the staff user name, staff user role and site title are rendered
208
+ await expect ( modal . getByText ( 'By Owner User' ) ) . toBeVisible ( ) ;
209
+ await expect ( modal . getByText ( 'Owner — Test Site' ) ) . toBeVisible ( ) ;
210
+
156
211
// Try to submit with empty content
157
212
const submitButton = modal . getByRole ( 'button' , { name : 'Send testimonial' } ) ;
158
213
await submitButton . click ( ) ;
0 commit comments