feat: add retained upload management controls
This commit is contained in:
1 parent
be2b9f83d0
commit
8dda23a1d8
2 files changed
+21
-6
No files matched your search
@@ -16,10 +16,11 @@ MOCK = r'''() => {
|
||||
binary:options.body instanceof File,headers:options.headers});
|
||||
if (path==='/api/capabilities') return {features:capabilities};
|
||||
if (path==='/api/attachments') {
|
||||
if(options.method==='GET') return {attachments:[{id:'c'.repeat(32),filename:'notes.txt',size:5,extraction_status:'ready'}]};
|
||||
if(pendingUpload) await new Promise((resolve,reject)=>options.signal.addEventListener('abort',()=>reject(new DOMException('Stopped','AbortError'))));
|
||||
return {attachment:{id:'c'.repeat(32),filename:options.body.name,extraction_status:'ready'}};
|
||||
}
|
||||
if(path==='/api/artifacts') return options.method==='POST'?{artifact:{...artifact,...JSON.parse(options.body),revision:1}}:{artifacts:[artifact]};
|
||||
if(path==='/api/artifacts') {const {content,...metadata}=artifact;return options.method==='POST'?{artifact:{...artifact,...JSON.parse(options.body),revision:1}}:{artifacts:[metadata]};}
|
||||
if(path.startsWith('/api/artifacts/')) {
|
||||
if(options.method==='PATCH') {if(conflict) throw new Error('Artifact revision conflict');artifact={...artifact,...JSON.parse(options.body),revision:artifact.revision+1};}
|
||||
return {artifact};
|
||||
@@ -79,6 +80,15 @@ class ChatFeaturesWebTests(unittest.TestCase):
|
||||
self.page.evaluate('HopeFeatures.clearAttachmentsAfterSend()')
|
||||
self.assertEqual(self.page.evaluate('HopeFeatures.attachmentIDs()'), [])
|
||||
|
||||
def test_retained_upload_management_delete_is_explicit(self):
|
||||
self.open_panel('Files')
|
||||
self.page.get_by_text('Delete notes.txt',exact=True).click()
|
||||
self.assertIn("old chat attachment references won't work", self.page.locator('#hopeFeatures').inner_text())
|
||||
self.assertEqual(self.page.evaluate('calls.filter(c=>c.method==="DELETE").length'), 0)
|
||||
self.assertTrue(self.page.get_by_role('link',name='Download notes.txt').get_attribute('href').endswith('/content'))
|
||||
self.page.get_by_role('button',name='Confirm delete notes.txt').click()
|
||||
self.page.wait_for_function('calls.some(c=>c.path.startsWith("/api/attachments/")&&c.method==="DELETE")')
|
||||
|
||||
def test_cancel_retry_and_conversation_change(self):
|
||||
self.page.evaluate('pendingUpload=true')
|
||||
self.page.locator('input[type=file]').set_input_files({'name':'notes.txt','mimeType':'text/plain','buffer':b'Hello'})
|
||||
|
||||
Reference in new issue
Block a user