feat: podpora více odkazů na podnik při objednávání
This commit is contained in:
13 files changed
+338
-81
No files matched your search
@@ -40,6 +40,42 @@ describe('createGroup', () => {
|
||||
expect(d2.groups).toHaveLength(2);
|
||||
expect(d2.groups![1].id).not.toBe(d2.groups![0].id);
|
||||
});
|
||||
|
||||
describe('výběr URL na nabídku', () => {
|
||||
const MULTI_STORE = 'Bistro';
|
||||
const WOLT_URL = 'https://wolt.com/bistro';
|
||||
const BOLT_URL = 'https://food.bolt.eu/bistro';
|
||||
|
||||
beforeEach(async () => {
|
||||
await addStore(MULTI_STORE, ADMIN_PW, [WOLT_URL, BOLT_URL]);
|
||||
});
|
||||
|
||||
test('uloží vybranou URL do skupiny', async () => {
|
||||
const data = await createGroup(CREATOR, MULTI_STORE, TODAY, BOLT_URL);
|
||||
expect(data.groups![0].url).toBe(BOLT_URL);
|
||||
});
|
||||
|
||||
test('odmítne URL, která k obchodu nepatří', async () => {
|
||||
await expect(createGroup(CREATOR, MULTI_STORE, TODAY, 'https://wolt.com/jine'))
|
||||
.rejects.toThrow('nepatří');
|
||||
});
|
||||
|
||||
test('bez výběru zůstane skupina bez URL, když má obchod více nabídek', async () => {
|
||||
const data = await createGroup(CREATOR, MULTI_STORE, TODAY);
|
||||
expect(data.groups![0].url).toBeUndefined();
|
||||
});
|
||||
|
||||
test('dosadí jedinou URL obchodu automaticky', async () => {
|
||||
await addStore('Pizzerie', ADMIN_PW, [WOLT_URL]);
|
||||
const data = await createGroup(CREATOR, 'Pizzerie', TODAY);
|
||||
expect(data.groups![0].url).toBe(WOLT_URL);
|
||||
});
|
||||
|
||||
test('obchod bez URL vytvoří skupinu bez URL', async () => {
|
||||
const data = await createGroup(CREATOR, STORE, TODAY);
|
||||
expect(data.groups![0].url).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('deleteGroup', () => {
|
||||
|
||||
@@ -28,6 +28,13 @@ describe('getStores', () => {
|
||||
const stores = await getStores();
|
||||
expect(stores).toEqual([{ name: 'McDonald\'s' }, { name: 'KFC' }]);
|
||||
});
|
||||
|
||||
test('převede starý formát s jednou URL na seznam urls', async () => {
|
||||
// Simulace dat uložených před zavedením více URL na jeden podnik
|
||||
await getStorage().setData('stores', [{ name: 'Bistro', url: 'https://wolt.com/bistro' }]);
|
||||
const stores = await getStores();
|
||||
expect(stores).toEqual([{ name: 'Bistro', urls: ['https://wolt.com/bistro'] }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('addStore', () => {
|
||||
@@ -37,21 +44,46 @@ describe('addStore', () => {
|
||||
});
|
||||
|
||||
test('uloží volitelnou URL a ořízne mezery', async () => {
|
||||
const stores = await addStore('Bistro', ADMIN_PW, ' https://wolt.com/bistro ');
|
||||
expect(stores).toContainEqual({ name: 'Bistro', url: 'https://wolt.com/bistro' });
|
||||
const stores = await addStore('Bistro', ADMIN_PW, [' https://wolt.com/bistro ']);
|
||||
expect(stores).toContainEqual({ name: 'Bistro', urls: ['https://wolt.com/bistro'] });
|
||||
});
|
||||
|
||||
test('bez URL uloží obchod bez pole url', async () => {
|
||||
const stores = await addStore('KFC', ADMIN_PW, ' ');
|
||||
test('uloží více URL na jeden podnik (různé dovozové služby)', async () => {
|
||||
const stores = await addStore('Bistro', ADMIN_PW, [
|
||||
'https://wolt.com/bistro',
|
||||
'https://food.bolt.eu/bistro',
|
||||
]);
|
||||
expect(stores).toContainEqual({
|
||||
name: 'Bistro',
|
||||
urls: ['https://wolt.com/bistro', 'https://food.bolt.eu/bistro'],
|
||||
});
|
||||
});
|
||||
|
||||
test('zahodí prázdné URL a duplicity (case-insensitive)', async () => {
|
||||
const stores = await addStore('Bistro', ADMIN_PW, [
|
||||
'https://wolt.com/bistro',
|
||||
' ',
|
||||
'https://WOLT.com/bistro',
|
||||
]);
|
||||
expect(stores).toContainEqual({ name: 'Bistro', urls: ['https://wolt.com/bistro'] });
|
||||
});
|
||||
|
||||
test('bez URL uloží obchod bez pole urls', async () => {
|
||||
const stores = await addStore('KFC', ADMIN_PW, [' ']);
|
||||
expect(stores).toContainEqual({ name: 'KFC' });
|
||||
});
|
||||
|
||||
test('odmítne URL s nepovoleným schématem (javascript:)', async () => {
|
||||
await expect(addStore('Zlo', ADMIN_PW, 'javascript:alert(1)')).rejects.toThrow('http');
|
||||
await expect(addStore('Zlo', ADMIN_PW, ['javascript:alert(1)'])).rejects.toThrow('http');
|
||||
});
|
||||
|
||||
test('odmítne nevalidní URL', async () => {
|
||||
await expect(addStore('Zlo', ADMIN_PW, 'nfdjska')).rejects.toThrow('Neplatná URL');
|
||||
test('odmítne nevalidní URL i mezi platnými', async () => {
|
||||
await expect(addStore('Zlo', ADMIN_PW, ['https://wolt.com/x', 'nfdjska'])).rejects.toThrow('Neplatná URL');
|
||||
});
|
||||
|
||||
test('odmítne příliš mnoho URL', async () => {
|
||||
const urls = Array.from({ length: 11 }, (_, i) => `https://wolt.com/bistro${i}`);
|
||||
await expect(addStore('Bistro', ADMIN_PW, urls)).rejects.toThrow('nejvýše');
|
||||
});
|
||||
|
||||
test('vyhodí UNAUTHORIZED s nesprávným heslem', async () => {
|
||||
|
||||
Reference in new issue
Block a user