refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,53 @@
|
||||
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
|
||||
const isAndroid = platformInfo.startsWith('android')
|
||||
const isIOS = platformInfo.startsWith('ios')
|
||||
const isWeb = platformInfo.startsWith('web')
|
||||
|
||||
let page;
|
||||
describe('web-clipboard', () => {
|
||||
if (!(isAndroid || isIOS || isWeb)) {
|
||||
it('app', async () => {
|
||||
expect(1).toBe(1)
|
||||
})
|
||||
return
|
||||
}
|
||||
beforeAll(async () => {
|
||||
page = await program.reLaunch('/pages/API/clipboard/clipboard')
|
||||
await page.waitFor('view');
|
||||
});
|
||||
|
||||
it('screenshot', async () => {
|
||||
const image = await program.screenshot({ fullPage: true });
|
||||
expect(image).toSaveImageSnapshot();
|
||||
});
|
||||
it('setClipboardData', async () => {
|
||||
await page.setData({
|
||||
data:{data: '123456'}
|
||||
})
|
||||
await page.callMethod('setClipboard')
|
||||
await page.waitFor(500);
|
||||
console.log(await page.data('data.setClipboardTest'), 'setClipboardTest')
|
||||
// bug:自动化测试时设置成功也进入了fail
|
||||
// expect(await page.data('setClipboardTest')).toBeTruthy()
|
||||
// 等待 toast 隐藏
|
||||
await page.waitFor(2000);
|
||||
});
|
||||
it('getClipboardData', async () => {
|
||||
if (
|
||||
isIOS &&
|
||||
platformInfo.indexOf('15.5') != -1
|
||||
) {
|
||||
// 该api在iOS 15.5版本的模拟器上有系统bug
|
||||
expect(1).toBe(1)
|
||||
}else{
|
||||
await page.callMethod('getClipboard')
|
||||
expect(await page.data('data.getDataTest')).toBe('123456')
|
||||
}
|
||||
// 等待 toast 隐藏
|
||||
await page.waitFor(3000);
|
||||
if(isAndroid) {
|
||||
// Android平台规避部分设备左下角弹框影响其他测试例
|
||||
await page.waitFor(3000);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,105 @@
|
||||
<template>
|
||||
<view>
|
||||
<page-head :title="title"></page-head>
|
||||
<view class="uni-padding-wrap">
|
||||
<view class="uni-title">请输入剪贴板内容</view>
|
||||
<view class="uni-list">
|
||||
<view class="uni-list-cell">
|
||||
<input class="uni-input" type="text" placeholder="请输入剪贴板内容" :value="data.data" @input="dataChange" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="uni-btn-v">
|
||||
<button type="primary" @click="setClipboard">存储数据</button>
|
||||
<button @tap="getClipboard">读取数据</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup lang="uts">
|
||||
type DataType = {
|
||||
data: string;
|
||||
// 自动化测试
|
||||
getDataTest: string;
|
||||
setClipboardTest: boolean;
|
||||
}
|
||||
|
||||
const title = ref('get/setClipboardData')
|
||||
const data = reactive({
|
||||
data: '',
|
||||
// 自动化测试
|
||||
getDataTest: '',
|
||||
setClipboardTest: false
|
||||
} as DataType)
|
||||
|
||||
// 页面卸载时清空剪贴板,避免影响其他测试用例
|
||||
onUnload(() => {
|
||||
uni.setClipboardData({
|
||||
data: ''
|
||||
})
|
||||
})
|
||||
|
||||
const dataChange = (e:UniInputEvent) => {
|
||||
data.data = e.detail.value
|
||||
}
|
||||
|
||||
const getClipboard = () => {
|
||||
uni.getClipboardData({
|
||||
success: (res) => {
|
||||
console.log(res.data);
|
||||
data.getDataTest = res.data;
|
||||
const content = res.data != "" ? '剪贴板内容为:' + res.data : '剪贴板暂无内容';
|
||||
uni.showModal({
|
||||
content,
|
||||
title: '读取剪贴板',
|
||||
showCancel: false
|
||||
})
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.showModal({
|
||||
content: `读取剪贴板失败: ${err.errMsg}`,
|
||||
showCancel: false
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const setClipboard = () => {
|
||||
if (data.data.length == 0) {
|
||||
uni.showModal({
|
||||
title: '设置剪贴板失败',
|
||||
content: '内容不能为空',
|
||||
showCancel: false
|
||||
})
|
||||
} else {
|
||||
uni.setClipboardData({
|
||||
data: data.data,
|
||||
success: () => {
|
||||
data.setClipboardTest = true
|
||||
// 成功处理
|
||||
uni.showToast({
|
||||
title: '设置剪贴板成功',
|
||||
icon: "success"
|
||||
})
|
||||
},
|
||||
fail: () => {
|
||||
// bug:自动化测试时设置成功也进入了fail
|
||||
data.setClipboardTest = false
|
||||
// 失败处理
|
||||
uni.showToast({
|
||||
title: '储存数据失败!',
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
data,
|
||||
getClipboard,
|
||||
setClipboard
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户