Merge pull request 'refactor: remove the unused URL shortener' (#11) from refactor/remove-unused-shortener into develop
Reviewed-on: https://git.zavage.net/Zavage-Software/search-with-chatgpt-powered-by-openai-extension/pulls/11
This commit is contained in:
@@ -24,6 +24,17 @@ test('URLs are validated and preserved whole, never shortened', () => {
|
||||
assert.equal(out.kind,'ready');
|
||||
assert.ok(new URL(out.url).searchParams.get('q').endsWith(source));
|
||||
});
|
||||
test('shortened selections end on a whole word and decode cleanly', () => {
|
||||
assert.equal(typeof prepareAction, 'function');
|
||||
const out=prepareAction(req({source:'lorem ipsum '.repeat(2000)}));
|
||||
assert.equal(out.kind,'shortened');
|
||||
const words=new URL(out.url).searchParams.get('q').replace('[Selected text shortened]','').trim().split(/\s+/);
|
||||
assert.ok(words.length>1);
|
||||
for (const word of words) assert.ok(word==='lorem'||word==='ipsum',`cut mid-word: ${word}`);
|
||||
const emoji=prepareAction(req({source:'😀 '.repeat(9000)}));
|
||||
assert.equal(emoji.kind,'shortened');
|
||||
assert.doesNotThrow(()=>decodeURIComponent(new URL(emoji.url).search.slice(1)));
|
||||
});
|
||||
test('long selections preserve instructions, repetition and Unicode with explicit consent', () => {
|
||||
assert.equal(typeof prepareAction, 'function');
|
||||
const settings={...DEFAULT_SETTINGS,promptTemplate:'START {query} AGAIN {query} END',temporaryChat:true,webSearch:true};
|
||||
|
||||
Reference in New Issue
Block a user