mirror of
				https://gitcode.com/gh_mirrors/re/react-native-pushy.git
				synced 2025-10-31 13:23:12 +08:00 
			
		
		
		
	feat: CI测试
This commit is contained in:
		| @@ -1,5 +1,4 @@ | ||||
| import {by, device, element, expect} from 'detox'; | ||||
|  | ||||
| import {by, device, element, expect, waitFor} from 'detox'; | ||||
| describe('测试Native模块的方法', () => { | ||||
|   beforeAll(async () => { | ||||
|     await device.launchApp(); | ||||
| @@ -7,83 +6,118 @@ describe('测试Native模块的方法', () => { | ||||
|  | ||||
|   it('setLocalHashInfo', async () => { | ||||
|     await element(by.id('testcase')).longPress(); | ||||
|     await element(by.id('setLocalHashInfo')).tap(); | ||||
|     await element(by.id('submit')).tap(); | ||||
|     await expect(element(by.text('done'))).toBeVisible(); | ||||
|     await element(by.text('OK')).tap(); | ||||
|     await element(by.id('setLocalHashInfo')).longPress(); | ||||
|     await element(by.id('submit')).longPress(); | ||||
|     await expect(element(by.id('done'))).toBeVisible(); | ||||
|     await element(by.id('done')).longPress(); | ||||
|     await expect(element(by.id('done'))).toBeNotVisible(); | ||||
|   }); | ||||
|  | ||||
|   it('getLocalHashInfo', async () => { | ||||
|     await element(by.id('getLocalHashInfo')).tap(); | ||||
|     await element(by.id('submit')).tap(); | ||||
|     await element(by.id('getLocalHashInfo')).longPress(); | ||||
|     await element(by.id('submit')).longPress(); | ||||
|     await expect(element(by.text('done'))).toBeVisible(); | ||||
|     await element(by.text('OK')).tap(); | ||||
|     await element(by.id('done')).longPress(); | ||||
|     await expect(element(by.id('done'))).toBeNotVisible(); | ||||
|   }); | ||||
|  | ||||
|   it('setUuid', async () => { | ||||
|     await element(by.id('setUuid')).tap(); | ||||
|     await element(by.id('submit')).tap(); | ||||
|     await element(by.id('setUuid')).longPress(); | ||||
|     await element(by.id('submit')).longPress(); | ||||
|     await expect(element(by.text('done'))).toBeVisible(); | ||||
|     await element(by.text('OK')).tap(); | ||||
|     await element(by.id('done')).longPress(); | ||||
|     await expect(element(by.id('done'))).toBeNotVisible(); | ||||
|   }); | ||||
|  | ||||
|   it('setBlockUpdate', async () => { | ||||
|     await element(by.id('setBlockUpdate')).tap(); | ||||
|     await element(by.id('submit')).tap(); | ||||
|     await element(by.id('setBlockUpdate')).longPress(); | ||||
|     await element(by.id('submit')).longPress(); | ||||
|     await expect(element(by.text('done'))).toBeVisible(); | ||||
|     await element(by.text('OK')).tap(); | ||||
|     await element(by.id('done')).longPress(); | ||||
|     await expect(element(by.id('done'))).toBeNotVisible(); | ||||
|   }); | ||||
|  | ||||
|   // it('reloadUpdate', async () => { | ||||
|   //   await element(by.id('reloadUpdate')).tap(); | ||||
|   //   await element(by.id('submit')).tap(); | ||||
|   //   await expect(element(by.text('刚刚更新失败了,版本被回滚.'))).toBeVisible(); | ||||
|   //   await element(by.text('OK')).tap(); | ||||
|   // }); | ||||
|   if (device.getPlatform() === 'android') { | ||||
|     it('reloadUpdate', async () => { | ||||
|       await element(by.id('reloadUpdate')).longPress(); | ||||
|       await element(by.id('submit')).longPress(); | ||||
|       await waitFor(element(by.text('确认'))) | ||||
|         .toBeVisible() | ||||
|         .withTimeout(10000); | ||||
|       await element(by.id('done')).longPress(); | ||||
|       await expect(element(by.id('done'))).toBeNotVisible(); | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   it('setNeedUpdate', async () => { | ||||
|     // await element(by.id('testcase')).longPress(); | ||||
|     await element(by.id('setNeedUpdate')).tap(); | ||||
|     await element(by.id('submit')).tap(); | ||||
|     await element(by.id('setNeedUpdate')).longPress(); | ||||
|     await element(by.id('submit')).longPress(); | ||||
|     await expect(element(by.text('done'))).toBeVisible(); | ||||
|     await element(by.text('OK')).tap(); | ||||
|     await element(by.id('done')).longPress(); | ||||
|     await expect(element(by.id('done'))).toBeNotVisible(); | ||||
|   }); | ||||
|  | ||||
|   it('markSuccess', async () => { | ||||
|     await element(by.id('markSuccess')).tap(); | ||||
|     await element(by.id('submit')).tap(); | ||||
|     await expect(element(by.text('done'))).toBeVisible(); | ||||
|     await element(by.text('OK')).tap(); | ||||
|   }); | ||||
|   if (device.getPlatform() === 'android') { | ||||
|     it('markSuccess', async () => { | ||||
|       await element(by.id('markSuccess')).longPress(); | ||||
|       await element(by.id('submit')).longPress(); | ||||
|       await waitFor(element(by.text('确认'))) | ||||
|         .toBeVisible() | ||||
|         .withTimeout(10000); | ||||
|       await element(by.id('done')).longPress(); | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   it('downloadPatchFromPpk', async () => { | ||||
|     await element(by.id('downloadPatchFromPpk')).tap(); | ||||
|     await element(by.id('submit')).tap(); | ||||
|     await expect(element(by.text('failed to open zip file'))).toBeVisible(); | ||||
|     await element(by.text('OK')).tap(); | ||||
|     await element(by.id('downloadPatchFromPpk')).longPress(); | ||||
|     await element(by.id('submit')).longPress(); | ||||
|     if (device.getPlatform() === 'ios') { | ||||
|       await expect(element(by.text('failed to open zip file'))).toBeVisible(); | ||||
|     } else { | ||||
|       await waitFor(element(by.text('确认'))) | ||||
|         .toBeVisible() | ||||
|         .withTimeout(10000); | ||||
|     } | ||||
|     await element(by.id('done')).longPress(); | ||||
|     await expect(element(by.id('done'))).toBeNotVisible(); | ||||
|   }); | ||||
|  | ||||
|   it('downloadPatchFromPackage', async () => { | ||||
|     await element(by.id('downloadPatchFromPackage')).tap(); | ||||
|     await element(by.id('submit')).tap(); | ||||
|     await expect(element(by.text('failed to open zip file'))).toBeVisible(); | ||||
|     await element(by.text('OK')).tap(); | ||||
|     await element(by.id('downloadPatchFromPackage')).longPress(); | ||||
|     await element(by.id('submit')).longPress(); | ||||
|     if (device.getPlatform() === 'ios') { | ||||
|       await expect(element(by.text('failed to open zip file'))).toBeVisible(); | ||||
|     } else { | ||||
|       await waitFor(element(by.text('确认'))) | ||||
|         .toBeVisible() | ||||
|         .withTimeout(10000); | ||||
|     } | ||||
|     await element(by.id('done')).longPress(); | ||||
|     await expect(element(by.id('done'))).toBeNotVisible(); | ||||
|   }); | ||||
|  | ||||
|   it('downloadFullUpdate', async () => { | ||||
|     await element(by.id('downloadFullUpdate')).tap(); | ||||
|     await element(by.id('submit')).tap(); | ||||
|     await expect(element(by.text('failed to open zip file'))).toBeVisible(); | ||||
|     await element(by.text('OK')).tap(); | ||||
|     await element(by.id('downloadFullUpdate')).longPress(); | ||||
|     await element(by.id('submit')).longPress(); | ||||
|     if (device.getPlatform() === 'ios') { | ||||
|       await expect(element(by.text('failed to open zip file'))).toBeVisible(); | ||||
|     } else { | ||||
|       await waitFor(element(by.text('确认'))) | ||||
|         .toBeVisible() | ||||
|         .withTimeout(10000); | ||||
|     } | ||||
|     await element(by.id('done')).longPress(); | ||||
|     await expect(element(by.id('done'))).toBeNotVisible(); | ||||
|   }); | ||||
|  | ||||
|   if (device.getPlatform() === 'android') { | ||||
|     it('downloadAndInstallApk', async () => { | ||||
|       await element(by.id('testcase')).longPress(); | ||||
|       await element(by.id('downloadAndInstallApk')).tap(); | ||||
|       await element(by.id('submit')).tap(); | ||||
|       await expect(element(by.text('failed to open zip file'))).toBeVisible(); | ||||
|       await element(by.text('OK')).tap(); | ||||
|       await element(by.id('downloadAndInstallApk')).longPress(); | ||||
|       await element(by.id('submit')).longPress(); | ||||
|       await waitFor(element(by.text('确认'))) | ||||
|         .toBeVisible() | ||||
|         .withTimeout(10000); | ||||
|       await element(by.id('done')).longPress(); | ||||
|       await expect(element(by.id('done'))).toBeNotVisible(); | ||||
|     }); | ||||
|   } | ||||
| }); | ||||
|   | ||||
| @@ -1,29 +0,0 @@ | ||||
| import { execSync } from 'child_process'; | ||||
|  | ||||
| import { pathExists, ensureDir } from 'fs-extra'; | ||||
|  | ||||
| import { resolveConfig } from 'detox/internals'; | ||||
| import { globalSetup } from 'detox/runners/jest'; | ||||
|  | ||||
| export default async function customGlobalSetup() { | ||||
|   const config = await resolveConfig(); | ||||
|   if (config.device.type === 'android.emulator') { | ||||
|     await downloadTestButlerAPK(); | ||||
|   } | ||||
|  | ||||
|   await globalSetup(); | ||||
| } | ||||
|  | ||||
| async function downloadTestButlerAPK() { | ||||
|   const version = '2.2.1'; | ||||
|   const artifactUrl = `https://repo1.maven.org/maven2/com/linkedin/testbutler/test-butler-app/${version}/test-butler-app-${version}.apk`; | ||||
|   const filePath = `cache/test-butler-app.apk`; | ||||
|  | ||||
|   await ensureDir('cache'); | ||||
|   if (!(await pathExists(filePath))) { | ||||
|     console.log(`\nDownloading Test-Butler APK v${version}...`); | ||||
|     execSync(`curl -f -o ${filePath} ${artifactUrl}`); | ||||
|   } | ||||
| } | ||||
|  | ||||
| module.exports = customGlobalSetup; | ||||
| @@ -1,16 +1,16 @@ | ||||
| /** @type {import('jest').Config} */ | ||||
| /** @type {import('@jest/types').Config.InitialOptions} */ | ||||
| module.exports = { | ||||
|   maxWorkers: 1, | ||||
|   globalSetup: './globalSetup.ts', | ||||
|   globalTeardown: 'detox/runners/jest/globalTeardown', | ||||
|   testEnvironment: 'detox/runners/jest/testEnvironment', | ||||
|   setupFilesAfterEnv: ['./setup.ts'], | ||||
|   testRunner: 'jest-circus/runner', | ||||
|   rootDir: '..', | ||||
|   testMatch: ['<rootDir>/e2e/**/*.test.js'], | ||||
|   testTimeout: 120000, | ||||
|   maxWorkers: 1, | ||||
|   testMatch: ['**/*.test.ts'], | ||||
|   transform: { | ||||
|     '\\.tsx?$': 'ts-jest', | ||||
|   }, | ||||
|   globalSetup: 'detox/runners/jest/globalSetup', | ||||
|   globalTeardown: 'detox/runners/jest/globalTeardown', | ||||
|   reporters: ['detox/runners/jest/reporter'], | ||||
|   testEnvironment: 'detox/runners/jest/testEnvironment', | ||||
|   verbose: true, | ||||
| }; | ||||
|   | ||||
| @@ -1,5 +0,0 @@ | ||||
| import { device } from 'detox'; | ||||
|  | ||||
| beforeAll(async () => { | ||||
|   await device.launchApp(); | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user
	 steven
					steven