@@ -1162,22 +1162,102 @@ export default class MockRequests {
11621162 }
11631163
11641164 /**
1165- * Mock a connected YouTube account that has no channels.
1165+ * Mock helper that simulates an incomplete YouTube account connection by calling
1166+ * `fulfillYouTubeAccountConnection` with a predefined payload.
1167+ *
1168+ * The payload sets `status` to `'incomplete'` while still providing channel metadata
1169+ * (`id` and `label`), which may be used by consumers to determine that the account
1170+ * connection process has been started but not completed.
11661171 *
1167- * This asynchronous helper fulfills the YouTube account connection with a
1168- * status of "connected" and an explicit null channel value, simulating a
1169- * scenario where the account is connected but no channels are available or
1170- * accessible.
1172+ * This method is asynchronous and awaits the underlying fulfillment call.
11711173 *
1172- * @return {Promise<void > } Resolves once the mock connection has been fulfilled .
1174+ * @return {Promise<* > } Resolves with whatever value `fulfillYouTubeAccountConnection` returns .
11731175 */
1174- async mockYouTubeAccountNoChannels ( ) {
1176+ async mockYouTubeAccountIncomplete ( ) {
11751177 await this . fulfillYouTubeAccountConnection ( {
1176- status : 'connected' ,
1177- channel : [ ] ,
1178+ status : 'incomplete' ,
1179+ channel : {
1180+ id : 'a89ahifdaffe234' ,
1181+ label : 'My YouTube Channel' ,
1182+ } ,
11781183 } ) ;
11791184 }
11801185
1186+ /**
1187+ * Mock helper that simulates a YouTube account connection with an ineligible channel by calling
1188+ * `fulfillYouTubeAccountConnection` with a predefined payload.
1189+ * The payload includes an error message and code indicating that the channel is not eligible for the linking program.
1190+ *
1191+ * This method is asynchronous and awaits the underlying fulfillment call.
1192+ *
1193+ * @return {Promise<*> } Resolves with whatever value `fulfillYouTubeAccountConnection` returns.
1194+ */
1195+ async mockNotEligibleYouTubeChannel ( ) {
1196+ await this . fulfillYouTubeCompleteSetup (
1197+ {
1198+ message : 'The channel is not eligible for the linking program.' ,
1199+ error : {
1200+ code : 403 ,
1201+ message :
1202+ 'The channel is not eligible for the linking program.' ,
1203+ errors : [
1204+ {
1205+ message :
1206+ 'The channel is not eligible for the linking program.' ,
1207+ domain : 'youtube.thirdPartyLink' ,
1208+ reason : 'CHANNEL_NOT_ELIGIBLE' ,
1209+ } ,
1210+ ] ,
1211+ } ,
1212+ } ,
1213+ 403
1214+ ) ;
1215+ }
1216+
1217+ /**
1218+ * Mock helper that simulates a YouTube account connection with an eligible channel by calling
1219+ * `fulfillYouTubeAccountConnection` with a predefined payload.
1220+ * The payload includes a message indicating that the channel is eligible for the linking program.
1221+ *
1222+ * This method is asynchronous and awaits the underlying fulfillment call.
1223+ *
1224+ * @return {Promise<*> } Resolves with whatever value `fulfillYouTubeAccountConnection` returns.
1225+ */
1226+ async mockEligibleYouTubeChannel ( ) {
1227+ await this . fulfillYouTubeCompleteSetup ( {
1228+ message : 'The channel is eligible for the linking program.' ,
1229+ } ) ;
1230+ }
1231+
1232+ /**
1233+ * Fulfills a mock request for the YouTube complete setup endpoint, simulating the completion of the YouTube setup process.
1234+ *
1235+ * @param {Object } payload - The mock response payload to be returned, which may include details about the completed setup.
1236+ * @param {number } [status=200] - The HTTP status code to be returned. Defaults to 200.
1237+ * @return {Promise<void> } A promise that resolves when the request is fulfilled.
1238+ */
1239+ async fulfillYouTubeCompleteSetup ( payload , status = 200 ) {
1240+ await this . fulfillRequest (
1241+ / \/ w c \/ g l a \/ y o u t u b e \/ s e t u p \/ c o m p l e t e \b / ,
1242+ payload ,
1243+ status ,
1244+ [ 'POST' ]
1245+ ) ;
1246+ }
1247+
1248+ /**
1249+ * Registers a wait for a request to the YouTube complete setup endpoint, allowing tests to wait until this specific request is made before proceeding.
1250+ *
1251+ * @return {Promise<import('playwright').Request> } A promise that resolves with the intercepted request object when a request matching the criteria is made.
1252+ */
1253+ async registerYouTubeCompleteSetupRequest ( ) {
1254+ return this . page . waitForRequest (
1255+ ( request ) =>
1256+ request . url ( ) . includes ( '/gla/youtube/setup/complete' ) &&
1257+ request . method ( ) === 'POST'
1258+ ) ;
1259+ }
1260+
11811261 /**
11821262 * Fulfills a mock request for the final URL suggestions endpoint for campaign assets.
11831263 *
0 commit comments