-
Notifications
You must be signed in to change notification settings - Fork 0
/
continuum-api.spec.ts
115 lines (102 loc) · 4.6 KB
/
continuum-api.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { test, expect } from '@playwright/test';
import { config } from '../utils/config';
import { setupClientAndScheduleStores, setupTemporal, trashTemporal } from '../utils/setup-temporal';
test.describe('continuum api', () => {
const name = 'continuum-api';
const { minioClient, scheduleIds } = setupClientAndScheduleStores();
test.beforeEach(async () => {
const { scheduleId } = await setupTemporal({ name, s3Client: minioClient });
scheduleIds[name] = scheduleId;
});
test.afterEach(async () => {
await trashTemporal({
name,
s3Client: minioClient,
scheduleId: scheduleIds[name],
});
});
test('response from continuum api after import of reviewed preprint', async ({ request }) => {
await expect(async () => {
const item = await request.get(`${config.client_url}/api/reviewed-preprints/${name}-msid`, {
headers: {
Accept: 'application/vnd.elife.reviewed-preprint+json; version=1',
},
});
expect(item.ok()).toBeTruthy();
}).toPass();
const listResponse = await request.get(`${config.client_url}/api/reviewed-preprints`, {
headers: {
Accept: 'application/vnd.elife.reviewed-preprint-list+json; version=1',
},
});
const expectSnippet = {
title: 'OpenApePose: a database of annotated ape photographs for pose estimation (reviewed)',
id: `${name}-msid`,
version: 1,
doi: '10.1101/000001',
elifeAssessment: {
title: 'eLife Assessment',
content: [
{
type: 'paragraph',
text: 'evaluation summary for convincingly compelling discovery in landmark study',
},
],
id: 'sa3',
doi: '10.7554/eLife.000001.1.sa3',
significance: [
'landmark',
],
strength: [
'convincing',
'compelling',
],
},
authorLine: 'Nisarg Desai, Praneet Bala ... Benjamin Hayden',
published: '2023-05-07T09:03:08Z',
reviewedDate: '2023-05-07T09:03:08Z',
statusDate: '2023-05-07T09:03:08Z',
versionDate: '2023-05-07T09:03:08Z',
stage: 'published',
status: 'reviewed',
subjects: [
{
id: 'cell-biology',
name: 'Cell Biology',
},
{
id: 'structural-biology-molecular-biophysics',
name: 'Structural Biology and Molecular Biophysics',
},
],
};
expect(listResponse.ok()).toBeTruthy();
const list = await listResponse.json();
// this isn't isolated enough to work
// expect(list).toStrictEqual({ total: 1, items: [expectSnippet] });
expect(list.items).toContainEqual(expectSnippet);
const listHeaders = listResponse.headers();
expect(listHeaders['content-type']).toBe('application/vnd.elife.reviewed-preprint-list+json; version=1');
expect(listHeaders['cache-control']).toBe('max-age=300, public, stale-if-error=86400, stale-while-revalidate=300');
const listHeaderVary = listHeaders.vary.split(', ');
expect(listHeaderVary).toContain('Accept');
expect(listHeaderVary).toContain('Authorization');
const item = await request.get(`${config.client_url}/api/reviewed-preprints/${name}-msid`, {
headers: {
Accept: 'application/vnd.elife.reviewed-preprint+json; version=1',
},
});
const itemJson = await item.json();
expect(itemJson).toStrictEqual({ ...expectSnippet, indexContent: expect.any(String) });
expect(itemJson.indexContent).toContain('Nisarg Desai, Praneet Bala, Rebecca Richardson, Jessica Raper, Jan Zimmermann, Benjamin Hayden');
expect(itemJson.indexContent).toContain('Such systems allow data collected from digital video cameras to be used to infer the positions of body landmarks such as head, hands, and feet, without the use of specialized markers.');
// eslint-disable-next-line max-len
expect(itemJson.indexContent).toContain('We thank Estelle Reballand from Chimpanzee Conservation Center, Fred Rubio from Project Chimps, Adam Thompson from Zoo Atlanta, Reba Collins from Chimp Haven, and Amanda Epping and Jared Taglialatela from Ape Initiative for permissions to take photographs from these sanctuaries as well as contributing images for the dataset.');
const itemHeaders = item.headers();
expect(itemHeaders['content-type']).toBe('application/vnd.elife.reviewed-preprint+json; version=1');
expect(itemHeaders['cache-control']).toBe('max-age=300, public, stale-if-error=86400, stale-while-revalidate=300');
const itemHeaderVary = itemHeaders.vary.split(', ');
expect(itemHeaderVary).toContain('Accept');
expect(itemHeaderVary).toContain('Authorization');
});
});