@@ -13,7 +13,8 @@ import { faker } from "@faker-js/faker";
1313import { test } from "@fixtures/walletExtension" ;
1414import { setAllureEpic } from "@helpers/allure" ;
1515import { isMobile , openDrawer } from "@helpers/mobile" ;
16- import { expect } from "@playwright/test" ;
16+ import { expect , Page } from "@playwright/test" ;
17+ import { randomUUID } from "crypto" ;
1718import environments from "lib/constants/environments" ;
1819
1920test . beforeEach ( async ( ) => {
@@ -172,17 +173,50 @@ test.describe("User Snap", () => {
172173 const attachmentInputSelector = "input[type=file]" ;
173174 const feedbackApiUrl =
174175 "https://widget.usersnap.com/api/widget/xhrrpc?submit_feedback" ;
176+ const bucketUrl =
177+ "https://s3.eu-central-1.amazonaws.com/upload.usersnap.com" ;
175178 const mockAttachmentPath = "./lib/_mock/mockAttachment.png" ;
176179
177- test ( "6Q. Should report an issue" , async ( { page } ) => {
178- // Intercept Usersnap submit API
180+ const interceptBucket = async ( page : Page ) => {
181+ await page . route ( bucketUrl , async ( route ) =>
182+ route . fulfill ( {
183+ status : 204 ,
184+ } )
185+ ) ;
186+ } ;
187+
188+ const interceptUsersnap = async ( page : Page ) => {
179189 await page . route ( feedbackApiUrl , async ( route ) =>
180190 route . fulfill ( {
181- status : 403 ,
182- body : JSON . stringify ( { error : "Blocked by test" } ) ,
191+ status : 200 ,
192+ body : JSON . stringify ( {
193+ status : true ,
194+ data : {
195+ feedback : {
196+ feedback_id : randomUUID ( ) ,
197+ assignee_id : randomUUID ( ) ,
198+ labels : [ ] ,
199+ } ,
200+ screen_recording_url : null ,
201+ attachment_urls : [
202+ {
203+ url : bucketUrl ,
204+ fields : {
205+ "Content-Type" : "image/png" ,
206+ key : randomUUID ( ) ,
207+ } ,
208+ } ,
209+ ] ,
210+ } ,
211+ } ) ,
183212 } )
184213 ) ;
214+ } ;
185215
216+ test ( "6Q. Should report an issue" , async ( { page } ) => {
217+ // Intercept Usersnap submit API
218+ await interceptUsersnap ( page ) ;
219+ await interceptBucket ( page ) ;
186220 await page
187221 . getByRole ( "button" , {
188222 name : "Report an issue Something" ,
@@ -196,17 +230,13 @@ test.describe("User Snap", () => {
196230
197231 await page . getByRole ( "button" , { name : "Submit" } ) . click ( ) ;
198232
199- await expect ( page . getByText ( "Feedback was not submitted, " ) ) . toBeVisible ( ) ;
233+ await expect ( page . getByText ( "Thank you! " ) ) . toBeVisible ( ) ;
200234 } ) ;
201235
202236 test ( "6R. Should submit an idea or new feature" , async ( { page } ) => {
203237 // Intercept Usersnap submit API
204- await page . route ( feedbackApiUrl , async ( route ) =>
205- route . fulfill ( {
206- status : 403 ,
207- body : JSON . stringify ( { error : "Blocked by test" } ) ,
208- } )
209- ) ;
238+ await interceptUsersnap ( page ) ;
239+ await interceptBucket ( page ) ;
210240
211241 await page
212242 . getByRole ( "button" , {
@@ -227,7 +257,7 @@ test.describe("User Snap", () => {
227257
228258 await page . getByRole ( "button" , { name : "Submit" } ) . click ( ) ;
229259
230- await expect ( page . getByText ( "Feedback was not submitted, " ) ) . toBeVisible ( ) ;
260+ await expect ( page . getByText ( "Thank you! " ) ) . toBeVisible ( ) ;
231261 } ) ;
232262 } ) ;
233263} ) ;
0 commit comments