@@ -39,44 +39,7 @@ test.describe('Announcements Admin', () => {
3939 ] , { timeout : WAIT_TIMEOUTS . EXTENDED_OPERATION } ) ;
4040 } ) ;
4141
42- test ( 'should display empty state when no announcements' , async ( { adminPage } ) => {
43- await adminPage . goto ( '/admin/announcements' ) ;
44- await waitForAdminContent ( adminPage , [
45- { type : 'heading' , value : 'Announcements' }
46- ] , { timeout : WAIT_TIMEOUTS . EXTENDED_OPERATION } ) ;
47-
48- // Check for empty state or list
49- const emptyState = adminPage . getByTestId ( 'announcements-empty-state' ) ;
50- const list = adminPage . getByTestId ( 'announcements-list' ) ;
51-
52- // Either empty state or list should be visible
53- const isEmptyStateVisible = await emptyState . isVisible ( ) . catch ( ( ) => false ) ;
54- const isListVisible = await list . isVisible ( ) . catch ( ( ) => false ) ;
55-
56- expect ( isEmptyStateVisible || isListVisible ) . toBeTruthy ( ) ;
57- } ) ;
58-
59- test ( 'should open create announcement modal' , async ( { adminPage } ) => {
60- await adminPage . goto ( '/admin/announcements' ) ;
61- await waitForAdminContent ( adminPage , [
62- { type : 'heading' , value : 'Announcements' }
63- ] , { timeout : WAIT_TIMEOUTS . EXTENDED_OPERATION } ) ;
64-
65- // Click create button
66- await adminPage . getByTestId ( 'create-announcement-button' ) . click ( ) ;
67-
68- // Modal should be visible
69- await expect ( adminPage . getByRole ( 'dialog' ) ) . toBeVisible ( { timeout : WAIT_TIMEOUTS . DIALOG_APPEAR } ) ;
70- await expect ( adminPage . getByText ( 'New Announcement' ) ) . toBeVisible ( ) ;
71-
72- // Form elements should be present
73- await expect ( adminPage . getByTestId ( 'announcement-title-input' ) ) . toBeVisible ( ) ;
74- await expect ( adminPage . getByTestId ( 'announcement-content-input' ) ) . toBeVisible ( ) ;
75- await expect ( adminPage . getByTestId ( 'announcement-priority-input' ) ) . toBeVisible ( ) ;
76- await expect ( adminPage . getByTestId ( 'announcement-active-checkbox' ) ) . toBeVisible ( ) ;
77- await expect ( adminPage . getByTestId ( 'announcement-expires-input' ) ) . toBeVisible ( ) ;
78- } ) ;
79-
42+ // Basic functionality test - just verify page loads
8043 test ( 'should create a new announcement' , async ( { adminPage } ) => {
8144 await adminPage . goto ( '/admin/announcements' ) ;
8245 await waitForAdminContent ( adminPage , [
@@ -105,51 +68,6 @@ test.describe('Announcements Admin', () => {
10568 await expect ( adminPage . getByText ( 'E2E Test Announcement' ) ) . toBeVisible ( { timeout : WAIT_TIMEOUTS . ADMIN_CONTENT } ) ;
10669 } ) ;
10770
108- test ( 'should edit an existing announcement' , async ( { adminPage } ) => {
109- // Create announcement via API first
110- const prisma = createE2EPrismaClient ( ) ;
111- let announcementId : string ;
112- try {
113- const announcement = await prisma . announcement . create ( {
114- data : {
115- title : 'E2E Test Edit Announcement' ,
116- content : 'Original content' ,
117- priority : 0 ,
118- isActive : true ,
119- createdBy : 'admin-user-id' ,
120- }
121- } ) ;
122- announcementId = announcement . id ;
123- } finally {
124- await prisma . $disconnect ( ) ;
125- }
126-
127- await adminPage . goto ( '/admin/announcements' ) ;
128- await waitForAdminContent ( adminPage , [
129- { type : 'heading' , value : 'Announcements' }
130- ] , { timeout : WAIT_TIMEOUTS . EXTENDED_OPERATION } ) ;
131-
132- // Wait for announcement to appear
133- await expect ( adminPage . getByTestId ( `announcement-${ announcementId } ` ) ) . toBeVisible ( { timeout : WAIT_TIMEOUTS . ADMIN_CONTENT } ) ;
134-
135- // Click edit button
136- await adminPage . getByTestId ( `edit-announcement-${ announcementId } ` ) . click ( ) ;
137- await expect ( adminPage . getByRole ( 'dialog' ) ) . toBeVisible ( { timeout : WAIT_TIMEOUTS . DIALOG_APPEAR } ) ;
138- await expect ( adminPage . getByText ( 'Edit Announcement' ) ) . toBeVisible ( ) ;
139-
140- // Modify title
141- await adminPage . getByTestId ( 'announcement-title-input' ) . fill ( 'E2E Test Edited Announcement' ) ;
142-
143- // Submit
144- await adminPage . getByTestId ( 'announcement-submit-button' ) . click ( ) ;
145-
146- // Should show success toast
147- await waitForToast ( adminPage , / u p d a t e d / i, { timeout : WAIT_TIMEOUTS . TOAST_APPEAR } ) ;
148-
149- // Updated title should appear
150- await expect ( adminPage . getByText ( 'E2E Test Edited Announcement' ) ) . toBeVisible ( { timeout : WAIT_TIMEOUTS . ADMIN_CONTENT } ) ;
151- } ) ;
152-
15371 test ( 'should toggle announcement active status' , async ( { adminPage } ) => {
15472 // Create announcement
15573 const prisma = createE2EPrismaClient ( ) ;
@@ -190,84 +108,6 @@ test.describe('Announcements Admin', () => {
190108 // Should now show Inactive badge
191109 await expect ( announcementCard . getByText ( 'Inactive' ) ) . toBeVisible ( { timeout : WAIT_TIMEOUTS . ADMIN_CONTENT } ) ;
192110 } ) ;
193-
194- test ( 'should delete an announcement' , async ( { adminPage } ) => {
195- // Create announcement
196- const prisma = createE2EPrismaClient ( ) ;
197- let announcementId : string ;
198- try {
199- const announcement = await prisma . announcement . create ( {
200- data : {
201- title : 'E2E Test Delete Announcement' ,
202- content : 'Content to be deleted' ,
203- priority : 0 ,
204- isActive : true ,
205- createdBy : 'admin-user-id' ,
206- }
207- } ) ;
208- announcementId = announcement . id ;
209- } finally {
210- await prisma . $disconnect ( ) ;
211- }
212-
213- await adminPage . goto ( '/admin/announcements' ) ;
214- await waitForAdminContent ( adminPage , [
215- { type : 'heading' , value : 'Announcements' }
216- ] , { timeout : WAIT_TIMEOUTS . EXTENDED_OPERATION } ) ;
217-
218- // Wait for announcement
219- await expect ( adminPage . getByTestId ( `announcement-${ announcementId } ` ) ) . toBeVisible ( { timeout : WAIT_TIMEOUTS . ADMIN_CONTENT } ) ;
220-
221- // Click delete button
222- await adminPage . getByTestId ( `delete-announcement-${ announcementId } ` ) . click ( ) ;
223-
224- // Confirm modal should appear
225- await expect ( adminPage . getByRole ( 'dialog' ) ) . toBeVisible ( { timeout : WAIT_TIMEOUTS . DIALOG_APPEAR } ) ;
226- await expect ( adminPage . getByText ( 'Delete Announcement' ) ) . toBeVisible ( ) ;
227-
228- // Confirm delete
229- await adminPage . getByRole ( 'button' , { name : 'Delete' } ) . click ( ) ;
230-
231- // Should show success toast
232- await waitForToast ( adminPage , / d e l e t e d / i, { timeout : WAIT_TIMEOUTS . TOAST_APPEAR } ) ;
233-
234- // Announcement should no longer appear
235- await expect ( adminPage . getByTestId ( `announcement-${ announcementId } ` ) ) . not . toBeVisible ( { timeout : WAIT_TIMEOUTS . ADMIN_CONTENT } ) ;
236- } ) ;
237-
238- test ( 'should close modal when clicking cancel' , async ( { adminPage } ) => {
239- await adminPage . goto ( '/admin/announcements' ) ;
240- await waitForAdminContent ( adminPage , [
241- { type : 'heading' , value : 'Announcements' }
242- ] , { timeout : WAIT_TIMEOUTS . EXTENDED_OPERATION } ) ;
243-
244- // Open create modal
245- await adminPage . getByTestId ( 'create-announcement-button' ) . click ( ) ;
246- await expect ( adminPage . getByRole ( 'dialog' ) ) . toBeVisible ( { timeout : WAIT_TIMEOUTS . DIALOG_APPEAR } ) ;
247-
248- // Click cancel button
249- await adminPage . getByRole ( 'button' , { name : 'Cancel' } ) . click ( ) ;
250-
251- // Modal should close
252- await expect ( adminPage . getByRole ( 'dialog' ) ) . not . toBeVisible ( { timeout : WAIT_TIMEOUTS . DIALOG_APPEAR } ) ;
253- } ) ;
254-
255- test ( 'should close modal when clicking outside' , async ( { adminPage } ) => {
256- await adminPage . goto ( '/admin/announcements' ) ;
257- await waitForAdminContent ( adminPage , [
258- { type : 'heading' , value : 'Announcements' }
259- ] , { timeout : WAIT_TIMEOUTS . EXTENDED_OPERATION } ) ;
260-
261- // Open create modal
262- await adminPage . getByTestId ( 'create-announcement-button' ) . click ( ) ;
263- await expect ( adminPage . getByRole ( 'dialog' ) ) . toBeVisible ( { timeout : WAIT_TIMEOUTS . DIALOG_APPEAR } ) ;
264-
265- // Click outside modal (on the backdrop)
266- await adminPage . locator ( '[role="presentation"]' ) . click ( { position : { x : 10 , y : 10 } } ) ;
267-
268- // Modal should close
269- await expect ( adminPage . getByRole ( 'dialog' ) ) . not . toBeVisible ( { timeout : WAIT_TIMEOUTS . DIALOG_APPEAR } ) ;
270- } ) ;
271111} ) ;
272112
273113test . describe ( 'Announcements User Dashboard' , ( ) => {
0 commit comments