fix: support profile editor swipe and show account deletion entry
This commit is contained in:
@@ -38,3 +38,10 @@ test('concurrent homepage notice reads share a request and do not dismiss a fres
|
||||
test('a hidden homepage cannot consume a once-per-login notification',async()=>{
|
||||
let done;const e=page('index/index.js',{announcement:()=>new Promise(resolve=>done=resolve)});const a=e.p.loadAnnouncement();e.p.onHide();done({mode:'login_once',enabled:true,content:'hello',revision:'v1'});await a;assert.equal(e.p.data.showAnnouncement,false);e.p._announcementActive=true;const b=e.p.loadAnnouncement();done({mode:'login_once',enabled:true,content:'hello',revision:'v1'});await b;assert.equal(e.p.data.showAnnouncement,true);
|
||||
});
|
||||
|
||||
test('bound accounts see an explanation instead of starting account deletion',async()=>{
|
||||
let calls=0;const e=page('settings/settings.js',{accountDeletionPreview:async()=>{calls++;},accountDelete:async()=>{calls++;}});
|
||||
e.p.data.hasPartner=true;e.p.data.bindingKnown=true;
|
||||
await e.p.deleteAccount();assert.equal(calls,0);assert.equal(e.dialogs.length,1);
|
||||
assert.match(e.dialogs[0].content,/请先完成情侣解绑/);assert.equal(e.dialogs[0].showCancel,false);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
const test=require('node:test'),assert=require('node:assert/strict'),path=require('node:path');
|
||||
function setup(partner=false){
|
||||
let def;const calls=[];
|
||||
const load=require('./load-module.cjs')({Page:p=>def=p,console,Date,wx:{hideKeyboard:()=>calls.push('keyboard'),navigateBack:()=>calls.push('back')}},{'../../utils/page-cache':{withDataCache:p=>p},'../../utils/request':{api:{}}});
|
||||
load(path.join(__dirname,'../pages/profile/profile.js'));
|
||||
const p={...def,data:{...def.data,showEditProfileModal:!partner,showEditPartnerModal:partner},setData(v){Object.assign(this.data,v)},getTabBar:()=>({setHidden:v=>calls.push(v)})};return {p,calls};
|
||||
}
|
||||
const start=(x,y,ignore=false)=>({touches:[{clientX:x,clientY:y}],target:{dataset:{swipeIgnore:ignore}}});
|
||||
const end=(x,y)=>({changedTouches:[{clientX:x,clientY:y}]});
|
||||
test('left swipe closes either editor once, restores tabs and never navigates away from profile',()=>{
|
||||
for(const partner of [false,true]){const {p,calls}=setup(partner);p.onEditTouchStart(start(280,300));p.onEditTouchEnd(end(100,310));p.onEditTouchEnd(end(100,310));assert.equal(p.data.showEditProfileModal,false);assert.equal(p.data.showEditPartnerModal,false);assert.deepEqual(calls,[false,'keyboard']);}
|
||||
});
|
||||
test('vertical scrolling, short or rightward gestures and text selection keep the editor open',()=>{
|
||||
for(const [s,e] of [[start(280,300),end(240,305)],[start(280,300),end(160,500)],[start(100,300),end(280,310)],[start(280,300,true),end(100,310)]]){const {p,calls}=setup();p.onEditTouchStart(s);p.onEditTouchEnd(e);assert.equal(p.data.showEditProfileModal,true);assert.equal(calls.length,0);}
|
||||
});
|
||||
test('cancelled touches and partner saving never dismiss the editor',()=>{
|
||||
const {p}=setup();p.onEditTouchStart(start(280,300));p.onEditTouchCancel();p.onEditTouchEnd(end(100,300));assert.equal(p.data.showEditProfileModal,true);
|
||||
const e=setup(true);e.p.data.partnerSaving=true;e.p.onEditTouchStart(start(280,300));e.p.onEditTouchEnd(end(100,300));assert.equal(e.p.data.showEditPartnerModal,true);
|
||||
});
|
||||
Reference in New Issue
Block a user