|
| 1 | +declare module "@srcpush/plugin-testing-framework" { |
| 2 | + import Q = require("q"); |
| 3 | + |
| 4 | + namespace Platform { |
| 5 | + interface IPlatform { |
| 6 | + getName(): string; |
| 7 | + getCommandLineFlagName(): string; |
| 8 | + getServerUrl(): string; |
| 9 | + getEmulatorManager(): IEmulatorManager; |
| 10 | + getDefaultDeploymentKey(): string; |
| 11 | + } |
| 12 | + |
| 13 | + interface IEmulatorManager { |
| 14 | + getTargetEmulator(): Q.Promise<string>; |
| 15 | + bootEmulator(restartEmulators: boolean): Q.Promise<void>; |
| 16 | + launchInstalledApplication(appId: string): Q.Promise<void>; |
| 17 | + endRunningApplication(appId: string): Q.Promise<void>; |
| 18 | + restartApplication(appId: string): Q.Promise<void>; |
| 19 | + resumeApplication(appId: string, delayBeforeResumingMs?: number): Q.Promise<void>; |
| 20 | + prepareEmulatorForTest(appId: string): Q.Promise<void>; |
| 21 | + uninstallApplication(appId: string): Q.Promise<void>; |
| 22 | + } |
| 23 | + |
| 24 | + class Android implements IPlatform { |
| 25 | + constructor(emulatorManager: IEmulatorManager); |
| 26 | + getName(): string; |
| 27 | + getCommandLineFlagName(): string; |
| 28 | + getServerUrl(): string; |
| 29 | + getEmulatorManager(): IEmulatorManager; |
| 30 | + getDefaultDeploymentKey(): string; |
| 31 | + } |
| 32 | + |
| 33 | + class IOS implements IPlatform { |
| 34 | + constructor(emulatorManager: IEmulatorManager); |
| 35 | + getName(): string; |
| 36 | + getCommandLineFlagName(): string; |
| 37 | + getServerUrl(): string; |
| 38 | + getEmulatorManager(): IEmulatorManager; |
| 39 | + getDefaultDeploymentKey(): string; |
| 40 | + } |
| 41 | + |
| 42 | + class AndroidEmulatorManager implements IEmulatorManager { |
| 43 | + getTargetEmulator(): Q.Promise<string>; |
| 44 | + bootEmulator(restartEmulators: boolean): Q.Promise<void>; |
| 45 | + launchInstalledApplication(appId: string): Q.Promise<void>; |
| 46 | + endRunningApplication(appId: string): Q.Promise<void>; |
| 47 | + restartApplication(appId: string): Q.Promise<void>; |
| 48 | + resumeApplication(appId: string, delayBeforeResumingMs?: number): Q.Promise<void>; |
| 49 | + prepareEmulatorForTest(appId: string): Q.Promise<void>; |
| 50 | + uninstallApplication(appId: string): Q.Promise<void>; |
| 51 | + } |
| 52 | + |
| 53 | + class IOSEmulatorManager implements IEmulatorManager { |
| 54 | + getTargetEmulator(): Q.Promise<string>; |
| 55 | + bootEmulator(restartEmulators: boolean): Q.Promise<void>; |
| 56 | + launchInstalledApplication(appId: string): Q.Promise<void>; |
| 57 | + endRunningApplication(appId: string): Q.Promise<void>; |
| 58 | + restartApplication(appId: string): Q.Promise<void>; |
| 59 | + resumeApplication(appId: string, delayBeforeResumingMs?: number): Q.Promise<void>; |
| 60 | + prepareEmulatorForTest(appId: string): Q.Promise<void>; |
| 61 | + uninstallApplication(appId: string): Q.Promise<void>; |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + namespace PluginTestingFramework { |
| 66 | + function initializeTests( |
| 67 | + projectManager: ProjectManager, |
| 68 | + supportedTargetPlatforms: Platform.IPlatform[], |
| 69 | + describeTests: (projectManager: ProjectManager, targetPlatform: Platform.IPlatform) => void |
| 70 | + ): void; |
| 71 | + } |
| 72 | + |
| 73 | + class ProjectManager { |
| 74 | + static DEFAULT_APP_VERSION: string; |
| 75 | + getPluginName(): string; |
| 76 | + setupProject(projectDirectory: string, templatePath: string, appName: string, appNamespace: string, version?: string): Q.Promise<void>; |
| 77 | + setupScenario(projectDirectory: string, appId: string, templatePath: string, jsPath: string, targetPlatform: Platform.IPlatform, version?: string): Q.Promise<void>; |
| 78 | + createUpdateArchive(projectDirectory: string, targetPlatform: Platform.IPlatform, isDiff?: boolean): Q.Promise<string>; |
| 79 | + preparePlatform(projectDirectory: string, targetPlatform: Platform.IPlatform): Q.Promise<void>; |
| 80 | + cleanupAfterPlatform(projectDirectory: string, targetPlatform: Platform.IPlatform): Q.Promise<void>; |
| 81 | + runApplication(projectDirectory: string, targetPlatform: Platform.IPlatform): Q.Promise<void>; |
| 82 | + } |
| 83 | + |
| 84 | + function setupTestRunScenario(projectManager: ProjectManager, targetPlatform: Platform.IPlatform, scenarioJsPath: string, version?: string): Q.Promise<void>; |
| 85 | + function setupUpdateScenario(projectManager: ProjectManager, targetPlatform: Platform.IPlatform, scenarioJsPath: string, version: string): Q.Promise<string>; |
| 86 | + |
| 87 | + namespace ServerUtil { |
| 88 | + let server: any; |
| 89 | + let updateResponse: any; |
| 90 | + let testMessageResponse: any; |
| 91 | + let testMessageCallback: (requestBody: any) => void; |
| 92 | + let updateCheckCallback: (requestBody: any) => void; |
| 93 | + let updatePackagePath: string; |
| 94 | + |
| 95 | + function setupServer(targetPlatform: Platform.IPlatform): void; |
| 96 | + function cleanupServer(): void; |
| 97 | + function createDefaultResponse(): any; |
| 98 | + function createUpdateResponse(mandatory?: boolean, targetPlatform?: Platform.IPlatform, randomHash?: boolean): any; |
| 99 | + function expectTestMessages(expectedMessages: any[]): Q.Promise<void>; |
| 100 | + |
| 101 | + class TestMessage { |
| 102 | + static CHECK_UP_TO_DATE: string; |
| 103 | + static CHECK_UPDATE_AVAILABLE: string; |
| 104 | + static CHECK_ERROR: string; |
| 105 | + static DOWNLOAD_SUCCEEDED: string; |
| 106 | + static DOWNLOAD_ERROR: string; |
| 107 | + static UPDATE_INSTALLED: string; |
| 108 | + static INSTALL_ERROR: string; |
| 109 | + static DEVICE_READY_AFTER_UPDATE: string; |
| 110 | + static UPDATE_FAILED_PREVIOUSLY: string; |
| 111 | + static NOTIFY_APP_READY_SUCCESS: string; |
| 112 | + static NOTIFY_APP_READY_FAILURE: string; |
| 113 | + static SKIPPED_NOTIFY_APPLICATION_READY: string; |
| 114 | + static SYNC_STATUS: string; |
| 115 | + static RESTART_SUCCEEDED: string; |
| 116 | + static RESTART_FAILED: string; |
| 117 | + static PENDING_PACKAGE: string; |
| 118 | + static CURRENT_PACKAGE: string; |
| 119 | + static SYNC_UP_TO_DATE: number; |
| 120 | + static SYNC_UPDATE_INSTALLED: number; |
| 121 | + static SYNC_UPDATE_IGNORED: number; |
| 122 | + static SYNC_ERROR: number; |
| 123 | + static SYNC_IN_PROGRESS: number; |
| 124 | + static SYNC_CHECKING_FOR_UPDATE: number; |
| 125 | + static SYNC_AWAITING_USER_ACTION: number; |
| 126 | + static SYNC_DOWNLOADING_PACKAGE: number; |
| 127 | + static SYNC_INSTALLING_UPDATE: number; |
| 128 | + } |
| 129 | + |
| 130 | + class TestMessageResponse { |
| 131 | + static SKIP_NOTIFY_APPLICATION_READY: string; |
| 132 | + } |
| 133 | + |
| 134 | + class AppMessage { |
| 135 | + message: string; |
| 136 | + args: any[]; |
| 137 | + constructor(message: string, args: any[]); |
| 138 | + static fromString(message: string): AppMessage; |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + class TestBuilder { |
| 143 | + static describe: { |
| 144 | + (description: string, spec: () => void, scenarioPath?: string): void; |
| 145 | + only(description: string, spec: () => void, scenarioPath?: string): void; |
| 146 | + skip(description: string, spec: () => void, scenarioPath?: string): void; |
| 147 | + }; |
| 148 | + static it: { |
| 149 | + (expectation: string, isCoreTest: boolean, assertion: (done: Mocha.Done) => void): void; |
| 150 | + only(expectation: string, isCoreTest: boolean, assertion: (done: Mocha.Done) => void): void; |
| 151 | + skip(expectation: string, isCoreTest: boolean, assertion: (done: Mocha.Done) => void): void; |
| 152 | + }; |
| 153 | + } |
| 154 | + |
| 155 | + namespace TestConfig { |
| 156 | + const TestAppName: string; |
| 157 | + const TestNamespace: string; |
| 158 | + const AcquisitionSDKPluginName: string; |
| 159 | + const templatePath: string; |
| 160 | + const thisPluginInstallString: string; |
| 161 | + const testRunDirectory: string; |
| 162 | + const updatesDirectory: string; |
| 163 | + const onlyRunCoreTests: boolean; |
| 164 | + const shouldSetup: boolean; |
| 165 | + const restartEmulators: boolean; |
| 166 | + const isOldArchitecture: boolean; |
| 167 | + } |
| 168 | + |
| 169 | + class TestUtil { |
| 170 | + static ANDROID_KEY_PLACEHOLDER: string; |
| 171 | + static IOS_KEY_PLACEHOLDER: string; |
| 172 | + static SERVER_URL_PLACEHOLDER: string; |
| 173 | + static INDEX_JS_PLACEHOLDER: string; |
| 174 | + static CODE_PUSH_APP_VERSION_PLACEHOLDER: string; |
| 175 | + static CODE_PUSH_TEST_APP_NAME_PLACEHOLDER: string; |
| 176 | + static CODE_PUSH_APP_ID_PLACEHOLDER: string; |
| 177 | + static PLUGIN_VERSION_PLACEHOLDER: string; |
| 178 | + |
| 179 | + static readMochaCommandLineOption(optionName: string, defaultValue?: string): string; |
| 180 | + static readMochaCommandLineFlag(optionName: string): boolean; |
| 181 | + static getProcessOutput(command: string, options?: any): Q.Promise<string>; |
| 182 | + static getPluginName(): string; |
| 183 | + static getPluginVersion(): string; |
| 184 | + static replaceString(filePath: string, regex: string, replacement: string): void; |
| 185 | + static copyFile(source: string, destination: string, overwrite: boolean): Q.Promise<void>; |
| 186 | + static archiveFolder(sourceFolder: string, targetFolder: string, archivePath: string, isDiff: boolean): Q.Promise<string>; |
| 187 | + static resolveBooleanVariables(variable: string | undefined): boolean; |
| 188 | + } |
| 189 | + |
| 190 | + export { Platform, PluginTestingFramework, ProjectManager, setupTestRunScenario, setupUpdateScenario, ServerUtil, TestBuilder, TestConfig, TestUtil }; |
| 191 | +} |
0 commit comments