77 type Step ,
88 type UserFlow ,
99} from "@puppeteer/replay"
10- import { Extension } from "."
10+ import { Extension , RecorderPlugin , stringifySelector } from "."
1111import flow from "./fixtures/Example.json"
1212
1313const extension = new Extension ( )
@@ -110,6 +110,16 @@ describe("Extension", () => {
110110 } ,
111111 'await userEvent.dblClick(screen.getByText("Test"))' ,
112112 ] ,
113+ [
114+ {
115+ type : "doubleClick" ,
116+ selectors,
117+ button : "secondary" ,
118+ offsetX : 0 ,
119+ offsetY : 0 ,
120+ } ,
121+ 'await userEvent.dblClick(screen.getByText("Test"), { buttons: 2 })' ,
122+ ] ,
113123 [
114124 {
115125 type : "keyDown" ,
@@ -138,6 +148,14 @@ describe("Extension", () => {
138148 } ,
139149 'expect(location.href).toBe("https://example.com/")\nexpect(document.title).toBe("Example Domain")' ,
140150 ] ,
151+ [
152+ {
153+ type : "navigate" ,
154+ url : "https://example.com/" ,
155+ assertedEvents : [ { type : "navigation" } ] ,
156+ } ,
157+ "" ,
158+ ] ,
141159 [
142160 {
143161 type : "waitForElement" ,
@@ -157,3 +175,27 @@ describe("Extension", () => {
157175 } )
158176 } )
159177} )
178+
179+ describe ( "stringifySelector" , ( ) => {
180+ test ( "aria" , ( ) => {
181+ expect ( stringifySelector ( "aria/Test" ) ) . toBe ( 'screen.getByText("Test")' )
182+ } )
183+
184+ test ( "selector" , ( ) => {
185+ expect ( stringifySelector ( "p" ) ) . toBe ( 'document.querySelector("p")' )
186+ } )
187+ } )
188+
189+ describe ( "RecorderPlugin" , ( ) => {
190+ test ( "stringify" , async ( ) => {
191+ expect ( await new RecorderPlugin ( ) . stringify ( flow as UserFlow ) ) . toBe (
192+ await readFile ( join ( __dirname , "fixtures/example.test.js" ) , "utf8" ) ,
193+ )
194+ } )
195+
196+ test ( "stringifyStep" , async ( ) => {
197+ expect (
198+ await new RecorderPlugin ( ) . stringifyStep ( flow . steps [ 1 ] as Step ) ,
199+ ) . toBe ( 'await waitFor(() => screen.getByText("More information..."))\n' )
200+ } )
201+ } )
0 commit comments