const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
const isHarmony = platformInfo.startsWith('harmony')
const isIOS = platformInfo.startsWith('ios')
const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true'
const PAGE_PATH = '/pages/component/rich-text/rich-text-complex'
describe('rich-text-test', () => {
if (isWeb || isMP || isHarmony) {
it('other platform', () => {
expect(1).toBe(1)
})
return
}
if (process.env.UNI_TEST_DEVICES_DIRECTION == 'landscape') {
it('跳过横屏模式', () => {
expect(1).toBe(1)
})
return
}
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor('view');
await page.waitFor(2000);
})
if (!isAppWebView) {
it('screenshot', async () => {
const image = await program.screenshot({
fullPage: true,
});
expect(image).toSaveImageSnapshot();
});
}
if (isAndroid && !isAppWebView) {
it("test attr mode", async () => {
await page.setData({
mode: 'native'
});
await page.waitFor(1000);
const image = await program.screenshot({ fullPage: true });
expect(image).toSaveImageSnapshot();
});
return;
}
it('click-event', async () => {
await program.tap({
x: 210,
y: 280,
duration: 100
})
await page.waitFor(1000);
const fViewClicked = await page.data('fViewClicked')
const selfClicked = await page.data('selfClicked')
expect(fViewClicked).toBe(true)
expect(selfClicked).toBe(true)
})
it('itemclick-event', async () => {
await program.tap({
x: 66,
y: 266,
duration: 100
})
await page.waitFor(500);
if (isIOS) {
await program.tap({
x: 200,
y: 433,
duration: 100
})
await program.tap({
x: 220,
y: 476,
duration: 100
})
await program.tap({
x: 220,
y: 526,
duration: 100
})
await program.tap({
x: 186,
y: 400,
duration: 100
})
}
const imageClicked = await page.data('imageClicked')
expect(imageClicked).toBe(true)
})
})