@@ -31,10 +31,90 @@ const puppeteer = require('puppeteer');
3131 throw new Error ( 'Signup form not found' ) ;
3232 }
3333
34- console . log ( '✓ Test passed successfully!' ) ;
34+ // Fill out the signup form
35+ console . log ( 'Filling out signup form...' ) ;
36+
37+ // Generate test data
38+ const testData = {
39+ email : `test${ Date . now ( ) } @example.com` ,
40+ password : 'TestPassword123!' ,
41+ firstName : 'Test' ,
42+ lastName : 'User' ,
43+ organization : 'Test Organization'
44+ } ;
45+
46+ // Fill out the specific RapidPro signup form fields
47+ const firstNameField = await page . $ ( '#id_first_name' ) ;
48+ if ( firstNameField ) {
49+ await firstNameField . type ( testData . firstName ) ;
50+ console . log ( '✓ First name field filled' ) ;
51+ } else {
52+ throw new Error ( 'First name field not found' ) ;
53+ }
54+
55+ const lastNameField = await page . $ ( '#id_last_name' ) ;
56+ if ( lastNameField ) {
57+ await lastNameField . type ( testData . lastName ) ;
58+ console . log ( '✓ Last name field filled' ) ;
59+ } else {
60+ throw new Error ( 'Last name field not found' ) ;
61+ }
62+
63+ const emailField = await page . $ ( '#id_email' ) ;
64+ if ( emailField ) {
65+ await emailField . type ( testData . email ) ;
66+ console . log ( '✓ Email field filled' ) ;
67+ } else {
68+ throw new Error ( 'Email field not found' ) ;
69+ }
70+
71+ const passwordField = await page . $ ( '#id_password1' ) ;
72+ if ( passwordField ) {
73+ await passwordField . type ( testData . password ) ;
74+ console . log ( '✓ Password field filled' ) ;
75+ } else {
76+ throw new Error ( 'Password field not found' ) ;
77+ }
78+
79+ const workspaceField = await page . $ ( '#id_workspace' ) ;
80+ if ( workspaceField ) {
81+ // Clear any placeholder text first
82+ await workspaceField . click ( { clickCount : 3 } ) ;
83+ await workspaceField . type ( testData . organization ) ;
84+ console . log ( '✓ Workspace field filled' ) ;
85+ } else {
86+ throw new Error ( 'Workspace field not found' ) ;
87+ }
88+
89+ // Submit the form using the "Sign Up" button
90+ console . log ( 'Submitting signup form...' ) ;
91+
92+ const submitButton = await page . $ ( 'button[type="submit"], input[type="submit"], button:contains("Sign Up")' ) ;
93+ if ( submitButton ) {
94+ await submitButton . click ( ) ;
95+ console . log ( '✓ Sign Up button clicked' ) ;
96+ } else {
97+ // Fallback: submit the form directly
98+ await signupForm . evaluate ( form => form . submit ( ) ) ;
99+ console . log ( '✓ Form submitted directly' ) ;
100+ }
101+
102+ // Wait for navigation or response
103+ await page . waitForNavigation ( { waitUntil : 'networkidle2' , timeout : 10000 } ) ;
104+
105+ console . log ( '✓ Signup form test completed successfully!' ) ;
35106
36107 } catch ( error ) {
37108 console . error ( '✗ Test failed:' , error . message ) ;
109+
110+ // Try to capture a screenshot for debugging
111+ try {
112+ await page . screenshot ( { path : 'test-failure.png' , fullPage : true } ) ;
113+ console . log ( 'Screenshot saved as test-failure.png' ) ;
114+ } catch ( screenshotError ) {
115+ console . log ( 'Could not save screenshot' ) ;
116+ }
117+
38118 process . exit ( 1 ) ;
39119 } finally {
40120 await browser . close ( ) ;
0 commit comments