@@ -2,14 +2,6 @@ import { defineConfig } from 'cypress';
2
2
import { cwd as _cwd } from 'process' ;
3
3
import * as fs from 'fs' ;
4
4
import * as yaml from 'js-yaml' ;
5
- import {
6
- BROKEN_LINKS_FILE ,
7
- FIRST_BROKEN_LINK_FILE ,
8
- initializeReport ,
9
- readBrokenLinksReport ,
10
- saveCacheStats ,
11
- saveValidationStrategy ,
12
- } from './cypress/support/link-reporter.js' ;
13
5
14
6
export default defineConfig ( {
15
7
e2e : {
@@ -88,98 +80,6 @@ export default defineConfig({
88
80
}
89
81
} ,
90
82
91
- // Broken links reporting tasks
92
- initializeBrokenLinksReport ( ) {
93
- return initializeReport ( ) ;
94
- } ,
95
-
96
- // Special case domains are now handled directly in the test without additional reporting
97
- // This task is kept for backward compatibility but doesn't do anything special
98
- reportSpecialCaseLink ( linkData ) {
99
- console . log (
100
- `✅ Expected status code: ${ linkData . url } (status: ${ linkData . status } ) is valid for this domain`
101
- ) ;
102
- return true ;
103
- } ,
104
-
105
- reportBrokenLink ( linkData ) {
106
- try {
107
- // Validate link data
108
- if ( ! linkData || ! linkData . url || ! linkData . page ) {
109
- console . error ( 'Invalid link data provided' ) ;
110
- return false ;
111
- }
112
-
113
- // Read current report
114
- const report = readBrokenLinksReport ( ) ;
115
-
116
- // Find or create entry for this page
117
- let pageReport = report . find ( ( r ) => r . page === linkData . page ) ;
118
- if ( ! pageReport ) {
119
- pageReport = { page : linkData . page , links : [ ] } ;
120
- report . push ( pageReport ) ;
121
- }
122
-
123
- // Check if link is already in the report to avoid duplicates
124
- const isDuplicate = pageReport . links . some (
125
- ( link ) => link . url === linkData . url && link . type === linkData . type
126
- ) ;
127
-
128
- if ( ! isDuplicate ) {
129
- // Add the broken link to the page's report
130
- pageReport . links . push ( {
131
- url : linkData . url ,
132
- status : linkData . status ,
133
- type : linkData . type ,
134
- linkText : linkData . linkText ,
135
- } ) ;
136
-
137
- // Write updated report back to file
138
- fs . writeFileSync (
139
- BROKEN_LINKS_FILE ,
140
- JSON . stringify ( report , null , 2 )
141
- ) ;
142
-
143
- // Store first broken link if not already recorded
144
- const firstBrokenLinkExists =
145
- fs . existsSync ( FIRST_BROKEN_LINK_FILE ) &&
146
- fs . readFileSync ( FIRST_BROKEN_LINK_FILE , 'utf8' ) . trim ( ) !== '' ;
147
-
148
- if ( ! firstBrokenLinkExists ) {
149
- // Store first broken link with complete information
150
- const firstBrokenLink = {
151
- url : linkData . url ,
152
- status : linkData . status ,
153
- type : linkData . type ,
154
- linkText : linkData . linkText ,
155
- page : linkData . page ,
156
- time : new Date ( ) . toISOString ( ) ,
157
- } ;
158
-
159
- fs . writeFileSync (
160
- FIRST_BROKEN_LINK_FILE ,
161
- JSON . stringify ( firstBrokenLink , null , 2 )
162
- ) ;
163
-
164
- console . error (
165
- `🔴 FIRST BROKEN LINK: ${ linkData . url } (${ linkData . status } ) - ${ linkData . type } on page ${ linkData . page } `
166
- ) ;
167
- }
168
-
169
- // Log the broken link immediately to console
170
- console . error (
171
- `❌ BROKEN LINK: ${ linkData . url } (${ linkData . status } ) - ${ linkData . type } on page ${ linkData . page } `
172
- ) ;
173
- }
174
-
175
- return true ;
176
- } catch ( error ) {
177
- console . error ( `Error reporting broken link: ${ error . message } ` ) ;
178
- // Even if there's an error, we want to ensure the test knows there was a broken link
179
- return true ;
180
- }
181
- } ,
182
-
183
83
// Cache and incremental validation tasks
184
84
saveCacheStatistics ( stats ) {
185
85
try {
0 commit comments