Skip to content

Commit d6d30f7

Browse files
committed
🧪 test: Milestone: all test-storage pass ✨
1 parent 33a78bd commit d6d30f7

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

‎test/data/urls.json‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"https://hal.science/hal-03171076",
7676
"https://hal.science/hal-03171076/file/paper_22.pdf",
7777
{
78-
"venue": "DGMM"
78+
"venue": "International Joint Conference on Discrete Geometry and Mathematical Morphology"
7979
}
8080
],
8181
"ijcai": [
@@ -115,7 +115,8 @@
115115
"https://www.mdpi.com/2076-328X/13/12/961",
116116
"https://www.mdpi.com/2076-328X/13/12/961/pdf",
117117
{
118-
"noPdf": true
118+
"noPdf": true,
119+
"venue": "Behavioral Sciences"
119120
}
120121
],
121122
"nature": [
@@ -141,7 +142,8 @@
141142
"https://academic.oup.com/brain/article/147/3/743/7617466",
142143
"https://watermark02.silverchair.com/awae043.pdf?token=AQECAHi208BE49Ooan9kkhW_Ercy7Dm3ZL_9Cf3qfKAc485ysgAAA1QwggNQBgkqhkiG9w0BBwagggNBMIIDPQIBADCCAzYGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQM7kysuY_cs4rR2-jhAgEQgIIDB4P9PivhWOCC8mFmhsZNyZflrzom2JHSmlFrmTEMfpOjewEbs6ujIgmf466LnSL_8BoyFCpXuwfCTp_EVwkQmBfdgVdL8ckkyt6k46nOXKAGKPHOzcv0EDIJaj6R3V9RUMikRSzI4A09fYlKZKE5LmYUxx41i85wYw00VErOHEmDV_yhQXD2VL168iDCDHCJii7QgbCh-m6s6uN-6PB78FXInRQihR4RgscNUHtb3zVU50Hiic0yXYp0wpkcC6j30tAFJlG9fTi4ZYJApvXw6dFTWL_z1kgn0YEg05TNqyCBA3KykBhcZfwB_e0nFiezf1K4ymsgseRyBd5y-e2SRdFw1cpYToGo2gvj53mKqRyWf2R-arEcNKHsx88WHfJsccUXU-ypM2l_jMGfJaKId3FXNXpOSd5zsUy4JoZ93tQgTlllxa9nOsAN9JwcC1y7wHocJ6YuornKusv7ERioglKJdwnbgXb8TUcYxlaiGiPMjkFubq97D9v3hJxsdvjCubkHrvaBG8GUvGd5rASrCUZjPnPzqL52UYKaDOHWQidk26mVV3rbJ1t9GnqZ1VXyiRO0PYChR8hQ46hpsgSmODx7LNBe1Um515BjcTKY6x6Vo-QXEUvj6EQ2yk_8KPwriOAXbKv2CJZNejsVVpx7v07K2XhFwNWthSOILMcV_abQxZxOToNPf59mPK_rTCW_RJkCZdJuklSyR6jY0EXIjPEKJBfIgsRn584ek1jNbOmAAy5qi9DDwPp-8XP-ctS5iN1U6G0bf5XW1umDCKwKrwuHAHgVc-ABiorChqpBPen3NhBPgCQBMyKr0u3_dBjiIrr599qn5a8U0ZsPOyCw1_RDThlP_qMsEdOvGZDwvmQtOQqD_rYgGh2RFDPjOR-GKix6pjFcwLYImoWc0iCjX1JhQJw4ReKI5F6n2Uavhp2Tsz8YrgSAZPDN8skS8Wqqp2cM886EkywyF6h6izg74nD5mYnzK6RUNM2Nu4_MV0jJ1xqsw2B-ou41yMDIQWd7mUqngBA7Jhg",
143144
{
144-
"noPdf": true
145+
"noPdf": true,
146+
"venue": "Brain"
145147
}
146148
],
147149
"pmc": [

‎test/test-storage.js‎

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ describe("Test paper detection and storage", function () {
148148
expect(missingTests).toEqual([]);
149149
});
150150
});
151+
152+
for (const [orderIdx, order] of orders.entries()) {
151153
describe("Parsing order: " + order, function () {
152154
before(async function () {
153155
// create browser
@@ -159,16 +161,17 @@ describe("Test paper detection and storage", function () {
159161
// visit all relevant urls
160162
// all abstracts then all pdfs
161163

162-
const indices = order === "abs;pdf" ? [0, 1] : [1, 0];
164+
const sourceOrder = order === "abs;pdf" ? [0, 1] : [1, 0];
163165

164-
for (const t of indices) {
165-
for (const [idx, targets] of Object.values(urls).entries()) {
166+
for (const sourceOrderIdx of sourceOrder) {
167+
for (const [targetIdx, targets] of Object.values(urls).entries()) {
166168
// for each target url (abstract, pdf), visit the url
167169
// and wait a little for it to load
168-
170+
const isPDF = sourceOrderIdx === 1;
171+
if (isPDF && targets[2]?.noPdf) continue;
169172
// filter out the additional test configs
170173
const targetUrls = targets.filter((u) => typeof u === "string");
171-
if (t >= targetUrls.length) {
174+
if (sourceOrderIdx >= targetUrls.length) {
172175
continue;
173176
}
174177
if (targets.length > 2) {
@@ -179,9 +182,14 @@ describe("Test paper detection and storage", function () {
179182
continue;
180183
}
181184
}
182-
const target = targetUrls[t];
185+
// TODO: handle no pdf but still check abstracts
186+
const target = targetUrls[sourceOrderIdx];
183187
// log prefix
184-
const n = idx + (o > 0 ? 1 - t : t) * nUrls + 1;
188+
const n =
189+
targetIdx +
190+
(orderIdx > 0 ? 1 - sourceOrderIdx : sourceOrderIdx) *
191+
nUrls +
192+
1;
185193
const prefix = `${" ".repeat(6)}(${n}/${nUrls * 2})`;
186194
console.log(`${prefix} Going to: ${target}`);
187195

@@ -231,8 +239,11 @@ describe("Test paper detection and storage", function () {
231239
const filteredSources = sources.filter(
232240
(s) => !ignoreSingleOrder(s, urls, order)
233241
);
234-
const memoryCounts = allAttributes(memoryPapers, "count");
235-
expect(memoryCounts.every((c) => c >= 2)).toBeTruthy();
242+
for (const paper of Object.values(memoryPapers)) {
243+
let targetMinCount = 2;
244+
if (urls[paper.source][2]?.noPdf) targetMinCount--;
245+
expect(paper.count).toBeGreaterThanOrEqual(targetMinCount);
246+
}
236247
});
237248

238249
it("No undefined keys", async function () {
@@ -265,10 +276,12 @@ describe("Test paper detection and storage", function () {
265276
expect(papers?.length).toBe(1);
266277
});
267278

268-
it("#count is 2", function () {
279+
it("#count is appropriate for the source", function () {
269280
const paper = paperForSource(source, memoryPapers);
270281
expect(paper).toBeDefined();
271-
expect(paper?.count).toBeGreaterThanOrEqual(2);
282+
let sourceCount = 2;
283+
if (urls[source][2]?.noPdf) sourceCount--;
284+
expect(paper?.count).toBeGreaterThanOrEqual(sourceCount);
272285
});
273286

274287
// more tests parameterized in the 3rd item in the list for this source

‎test/testConfig.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ keepOpen:
1212
# |> test-storage, test-duplicates
1313
pageTimeout:
1414
type: int
15-
defaultValue: 1000
15+
defaultValue: 100
1616

1717
# Max number of sources to iterate through for debug. -1 is all sources.
1818
# |> test-storage, test-duplicates

0 commit comments

Comments
 (0)