@@ -1020,6 +1020,73 @@ export class PageObject {
10201020 await new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
10211021 }
10221022}
1023+ // Helper functions for e2e tests
1024+
1025+ export async function createApp ( page : Page , appName : string , options : { isFullStack : boolean ; selectedBackendFramework : string } ) : Promise < number > {
1026+ await page . getByRole ( "link" , { name : "Chat" } ) . click ( ) ;
1027+ const prompt = `Create a ${ options . isFullStack ? 'fullstack' : 'frontend' } app named ${ appName } ${ options . isFullStack ? ` with ${ options . selectedBackendFramework } backend` : '' } ` ;
1028+ await page . getByRole ( "textbox" , { name : "Ask AliFullStack to build..." } ) . fill ( prompt ) ;
1029+ await page . getByRole ( "button" , { name : "Send message" } ) . click ( ) ;
1030+ await page . waitForSelector ( '[data-testid="retry-button"]' , { timeout : Timeout . MEDIUM } ) ;
1031+ return 0 ;
1032+ }
1033+
1034+ export async function deleteApp ( page : Page , appId : number ) : Promise < void > {
1035+ await page . getByRole ( "link" , { name : "Apps" } ) . click ( ) ;
1036+ const appItems = page . locator ( '[data-testid^="app-list-item-"]' ) ;
1037+ await appItems . nth ( appId ) . click ( ) ;
1038+ await page . getByTestId ( "app-details-more-options-button" ) . click ( ) ;
1039+ await page . getByRole ( "button" , { name : "Delete" } ) . click ( ) ;
1040+ await page . getByRole ( "button" , { name : "Delete App" } ) . click ( ) ;
1041+ }
1042+
1043+ export async function startApp ( page : Page , appId : number , mode : string ) : Promise < void > {
1044+ await page . getByRole ( "link" , { name : "Chat" } ) . click ( ) ;
1045+ const prompt = `Start the app in ${ mode } mode` ;
1046+ await page . getByRole ( "textbox" , { name : "Ask AliFullStack to build..." } ) . fill ( prompt ) ;
1047+ await page . getByRole ( "button" , { name : "Send message" } ) . click ( ) ;
1048+ await page . waitForSelector ( '[data-testid="retry-button"]' , { timeout : Timeout . MEDIUM } ) ;
1049+ }
1050+
1051+ export async function stopApp ( page : Page , appId : number ) : Promise < void > {
1052+ await page . getByRole ( "link" , { name : "Chat" } ) . click ( ) ;
1053+ const prompt = `Stop the app` ;
1054+ await page . getByRole ( "textbox" , { name : "Ask AliFullStack to build..." } ) . fill ( prompt ) ;
1055+ await page . getByRole ( "button" , { name : "Send message" } ) . click ( ) ;
1056+ await page . waitForSelector ( '[data-testid="retry-button"]' , { timeout : Timeout . MEDIUM } ) ;
1057+ }
1058+
1059+ export async function getAppOutput ( page : Page , appId : number ) : Promise < string > {
1060+ const messagesList = page . getByTestId ( "messages-list" ) ;
1061+ return ( await messagesList . textContent ( ) ) || '' ;
1062+ }
1063+
1064+ export async function switchTerminal ( page : Page , terminal : string ) : Promise < void > {
1065+ await page . getByRole ( "tab" , { name : terminal } ) . click ( ) ;
1066+ }
1067+
1068+ export async function getTerminalOutput ( page : Page , appId : number , terminal : string ) : Promise < string > {
1069+ // Assume the terminal content is in a locator after switching
1070+ // This might need adjustment based on actual UI
1071+ const terminalLocator = page . locator ( '.terminal' ) ;
1072+ return ( await terminalLocator . textContent ( ) ) || '' ;
1073+ }
1074+
1075+ export async function createBackendFile ( page : Page , appId : number , filePath : string , content : string ) : Promise < void > {
1076+ await page . getByRole ( "link" , { name : "Chat" } ) . click ( ) ;
1077+ const prompt = `Create a backend file ${ filePath } with the following content:\n${ content } ` ;
1078+ await page . getByRole ( "textbox" , { name : "Ask AliFullStack to build..." } ) . fill ( prompt ) ;
1079+ await page . getByRole ( "button" , { name : "Send message" } ) . click ( ) ;
1080+ await page . waitForSelector ( '[data-testid="retry-button"]' , { timeout : Timeout . MEDIUM } ) ;
1081+ }
1082+
1083+ export async function createFrontendFile ( page : Page , appId : number , filePath : string , content : string ) : Promise < void > {
1084+ await page . getByRole ( "link" , { name : "Chat" } ) . click ( ) ;
1085+ const prompt = `Create a frontend file ${ filePath } with the following content:\n${ content } ` ;
1086+ await page . getByRole ( "textbox" , { name : "Ask AliFullStack to build..." } ) . fill ( prompt ) ;
1087+ await page . getByRole ( "button" , { name : "Send message" } ) . click ( ) ;
1088+ await page . waitForSelector ( '[data-testid="retry-button"]' , { timeout : Timeout . MEDIUM } ) ;
1089+ }
10231090
10241091interface ElectronConfig {
10251092 preLaunchHook ?: ( { userDataDir } : { userDataDir : string } ) => Promise < void > ;
0 commit comments