Skip to content

Commit 01207fc

Browse files
committed
Add more integration tests
1 parent 4a858c2 commit 01207fc

3 files changed

Lines changed: 73 additions & 29 deletions

File tree

.github/workflows/integration_tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
pull_request:
66
schedule:
7-
# Codziennie o 6:00 UTC — wykrywa zmiany na stronach sklepów
87
- cron: '0 6 * * *'
98

109
jobs:

README.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,25 @@ Chrome
1515
2) Włącz **Developer mode** (prawy górny róg)
1616
3) Kliknij **Load unpacked**
1717
4) Wskaż folder z rozszerzeniem i kliknij **OK**
18+
19+
20+
Wspierane sklepy:
21+
=======
22+
23+
* https://www.frisco.pl/
24+
* https://erli.pl/
25+
* https://dodomku.pl/
26+
* https://megasam24.pl/
27+
* https://leclerc-online.pl/
28+
29+
Pracujemy nad wsparciem dla:
30+
------
31+
* https://mamyito
32+
* https://polskikoszyk.pl/
33+
* https://www.carrefour.pl/
34+
* https://zakupy.biedronka.pl/
35+
* https://delio.com.pl/
36+
* https://topaz24.pl/
37+
* https://szybkikoszyk.pl/
38+
* https://sklep.brat.pl/
39+
* https://www.espolem.pl/

test-e2e/ean-detection.spec.js

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
* 4. Wstrzykuje lib/validateEAN.js (definicja funkcji walidacji)
99
* 5. Wstrzykuje content_scripts/pola.js (logika skanowania)
1010
* 6. Sprawdza czy content script znalazł oczekiwany kod EAN
11-
*
12-
* UWAGA: Te testy odpytują prawdziwe strony internetowe, więc:
13-
* - Mogą być wolniejsze (zależą od sieci)
14-
* - Mogą się "zepsuć" jeśli sklep zmieni stronę (wtedy trzeba zaktualizować test)
15-
* - W CI uruchamiamy je z retry=1 i osobnym jobem (allow-failure)
1611
*/
1712

1813
const { test, expect } = require('@playwright/test');
@@ -54,32 +49,60 @@ async function injectContentScript(page) {
5449
// TESTY
5550
// ============================================================================
5651

52+
const productPages = [
53+
{
54+
store: 'frisco.pl',
55+
product: 'Makłowicz i Synowie oliwa z oliwek extra virgin',
56+
ean: '5905644030022',
57+
url: 'https://www.frisco.pl/pid,145610/n,maklowicz-i-synowie-oliwa-z-oliwek-extra-vergine/stn,product',
58+
},
59+
{
60+
store: 'erli.pl',
61+
product: 'Szklany dzbanek filtrujący Dafi CRYSTAL 2l biały',
62+
ean: '5900950928254',
63+
url: 'https://erli.pl/produkt/szklany-dzbanek-filtrujacy-dafi-crystal-2l-bialy,159105253',
64+
},
65+
{
66+
store: 'dodomku.pl',
67+
product: 'Maluta Masło ekstra',
68+
ean: '5904467191316',
69+
url: 'https://dodomku.pl/Maluta_Maslo_ekstra/61218_2435341_552.html',
70+
},
71+
{
72+
store: 'megasam24.pl',
73+
product: 'Baton mango bez dodatku cukru 35 g',
74+
ean: '4820287102619',
75+
url: 'https://megasam24.pl/baton-mango-bez-dodatku-cukru-35-g',
76+
},
77+
{
78+
store: 'leclerc-online.pl',
79+
product: 'Dolina Noteci Premium Sterilised Danie z kaczki dla kota 85g',
80+
ean: '5902921303213',
81+
url: 'https://leclerc-online.pl/dolina-noteci-premium-sterilised-danie-z-kaczki-dla-kota-85g',
82+
}
83+
];
84+
5785
test.describe('EAN detection on real product pages', () => {
5886

59-
test('frisco.pl — Makłowicz oliwa z oliwek → EAN 5905644030022', async ({ page }) => {
60-
await page.goto(
61-
'https://www.frisco.pl/pid,145610/n,maklowicz-i-synowie-oliwa-z-oliwek-extra-vergine/stn,product',
62-
{ waitUntil: 'domcontentloaded' }
63-
);
87+
for (const { store, product, ean, url } of productPages) {
88+
test(`${store}${product} → EAN ${ean}`, async ({ page }) => {
89+
await page.goto(url, { waitUntil: 'domcontentloaded' });
6490

65-
const messages = await injectContentScript(page);
91+
const messages = await injectContentScript(page);
6692

67-
// Content script powinien znaleźć dokładnie 1 EAN i wysłać { type: 'ean', result: '...' }
68-
// LUB znaleźć wiele i wysłać { type: 'multiple', result: [...] }
69-
const eanMessage = messages.find(m => m.type === 'ean');
70-
const multipleMessage = messages.find(m => m.type === 'multiple');
71-
72-
if (eanMessage) {
73-
expect(eanMessage.result).toBe('5905644030022');
74-
} else if (multipleMessage) {
75-
expect(multipleMessage.result).toContain('5905644030022');
76-
} else {
77-
// Jeśli nie znaleziono — test powinien sfailować z czytelnym komunikatem
78-
throw new Error(
79-
`Content script nie znalazł EAN 5905644030022 na stronie frisco.pl. ` +
80-
`Przechwycone wiadomości: ${JSON.stringify(messages)}`
81-
);
82-
}
83-
});
93+
const eanMessage = messages.find(m => m.type === 'ean');
94+
const multipleMessage = messages.find(m => m.type === 'multiple');
8495

96+
if (eanMessage) {
97+
expect(eanMessage.result).toBe(ean);
98+
} else if (multipleMessage) {
99+
expect(multipleMessage.result).toContain(ean);
100+
} else {
101+
throw new Error(
102+
`Content script nie znalazł EAN ${ean} na stronie ${store}. ` +
103+
`Przechwycone wiadomości: ${JSON.stringify(messages)}`
104+
);
105+
}
106+
});
107+
}
85108
});

0 commit comments

Comments
 (0)