mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-12-18 11:45:07 +08:00
feat: project init
This commit is contained in:
89
Example/testHotUpdate/e2e/NativeModule.test.ts
Normal file
89
Example/testHotUpdate/e2e/NativeModule.test.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
import {by, device, element, expect} from 'detox';
|
||||
|
||||
describe('测试Native模块的方法', () => {
|
||||
beforeAll(async () => {
|
||||
await device.launchApp();
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
it('getLocalHashInfo', async () => {
|
||||
await element(by.id('getLocalHashInfo')).tap();
|
||||
await element(by.id('submit')).tap();
|
||||
await expect(element(by.text('done'))).toBeVisible();
|
||||
await element(by.text('OK')).tap();
|
||||
});
|
||||
|
||||
it('setUuid', async () => {
|
||||
await element(by.id('setUuid')).tap();
|
||||
await element(by.id('submit')).tap();
|
||||
await expect(element(by.text('done'))).toBeVisible();
|
||||
await element(by.text('OK')).tap();
|
||||
});
|
||||
|
||||
it('setBlockUpdate', async () => {
|
||||
await element(by.id('setBlockUpdate')).tap();
|
||||
await element(by.id('submit')).tap();
|
||||
await expect(element(by.text('done'))).toBeVisible();
|
||||
await element(by.text('OK')).tap();
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
it('setNeedUpdate', async () => {
|
||||
await element(by.id('testcase')).longPress();
|
||||
await element(by.id('setNeedUpdate')).tap();
|
||||
await element(by.id('submit')).tap();
|
||||
await expect(element(by.text('done'))).toBeVisible();
|
||||
await element(by.text('OK')).tap();
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
});
|
||||
29
Example/testHotUpdate/e2e/globalSetup.ts
Normal file
29
Example/testHotUpdate/e2e/globalSetup.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
16
Example/testHotUpdate/e2e/jest.config.js
Normal file
16
Example/testHotUpdate/e2e/jest.config.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/** @type {import('jest').Config} */
|
||||
module.exports = {
|
||||
maxWorkers: 1,
|
||||
globalSetup: './globalSetup.ts',
|
||||
globalTeardown: 'detox/runners/jest/globalTeardown',
|
||||
testEnvironment: 'detox/runners/jest/testEnvironment',
|
||||
setupFilesAfterEnv: ['./setup.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
testTimeout: 120000,
|
||||
testMatch: ['**/*.test.ts'],
|
||||
transform: {
|
||||
'\\.tsx?$': 'ts-jest',
|
||||
},
|
||||
reporters: ['detox/runners/jest/reporter'],
|
||||
verbose: true,
|
||||
};
|
||||
5
Example/testHotUpdate/e2e/setup.ts
Normal file
5
Example/testHotUpdate/e2e/setup.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { device } from 'detox';
|
||||
|
||||
beforeAll(async () => {
|
||||
await device.launchApp();
|
||||
});
|
||||
Reference in New Issue
Block a user