-
Notifications
You must be signed in to change notification settings - Fork 0
/
progress.spec.ts
133 lines (119 loc) · 5.13 KB
/
progress.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import { expect, test } from '@playwright/test';
import { changeState } from '../utils/wiremock';
import { EppPage } from './page-objects/epp-page';
import { setupClientAndScheduleStores, setupTemporal, trashTemporal } from '../utils/setup-temporal';
test.describe('progress a manuscript through the manifestations', () => {
const { minioClient, scheduleIds } = setupClientAndScheduleStores();
const checkEmpty = async (eppPage: EppPage) => {
// Verify that no preview or article page available.
await eppPage.gotoPreviewPage({ status: 404 });
await eppPage.gotoArticlePage({ status: 404 });
};
const checkPreview = async (eppPage: EppPage) => {
// Wait for preview to become available.
await eppPage.gotoPreviewPage();
await eppPage.reloadAndAssertStatus(200);
await eppPage.assertTitleText('OpenApePose: a database of annotated ape photographs for pose estimation (reviewed)');
await eppPage.gotoArticlePage({ status: 404 });
};
const checkReviews = async (eppPage: EppPage) => {
// Wait for reviewed preprint to become available.
await eppPage.gotoArticlePage();
await eppPage.reloadAndAssertStatus(200);
await eppPage.assertTitleText('OpenApePose: a database of annotated ape photographs for pose estimation (enhanced) (reviewed)');
};
const checkPreviewRevised = async (eppPage: EppPage) => {
// Wait for preview of revised preprint to become available.
await eppPage.gotoPreviewPage({ version: 2 });
await eppPage.reloadAndAssertStatus(200);
await eppPage.assertTitleText('OpenApePose: a database of annotated ape photographs for pose estimation (revised)');
await eppPage.gotoArticlePage({ version: 2, status: 404 });
// Ensure that umbrella id still works with preview available
await eppPage.gotoArticlePage();
await eppPage.reloadAndAssertStatus(200);
await eppPage.assertTitleText('OpenApePose: a database of annotated ape photographs for pose estimation (enhanced) (reviewed)');
};
const checkRevised = async (eppPage: EppPage) => {
// Wait for revised preprint to become available.
await eppPage.gotoArticlePage({ version: 2 });
await eppPage.reloadAndAssertStatus(200);
await eppPage.assertTitleText('OpenApePose: a database of annotated ape photographs for pose estimation (enhanced) (revised)');
};
const checkVersionOfRecord = async (eppPage: EppPage) => {
// Wait for Version of Record summary to become available.
await eppPage.gotoArticlePage({ version: 2 });
await expect(async () => {
const response = await eppPage.reload();
expect(response?.status()).toBe(200);
await eppPage.assertTimelineEventText(1, 'Version of Record');
await eppPage.assertTimelineEventLink(1, 'https://elifesciences.org/articles/000001v1');
await eppPage.assertTimelineDetailText(1, 'June 7, 2023');
}).toPass();
};
const checkVersionOfRecordCorrection = async (eppPage: EppPage) => {
// Wait for Version of Record summary with correction to become available.
await eppPage.gotoArticlePage({ version: 2 });
await expect(async () => {
const response = await eppPage.reload();
expect(response?.status()).toBe(200);
await eppPage.assertTimelineEventText(1, 'Version of Record');
await eppPage.assertTimelineEventLink(1, 'https://elifesciences.org/articles/000001v2');
await eppPage.assertTimelineDetailText(1, 'July 6, 2023');
}).toPass();
await eppPage.assertTimelineEventText(2, 'Version of Record');
await eppPage.assertTimelineEventLink(2, 'https://elifesciences.org/articles/000001v1');
await eppPage.assertTimelineDetailText(2, 'June 7, 2023');
};
// eslint-disable-next-line no-empty-pattern
test.beforeEach(async ({}, testInfo) => {
const { scheduleId } = await setupTemporal({ name: testInfo.title, s3Client: minioClient });
scheduleIds[testInfo.title] = scheduleId;
});
// eslint-disable-next-line no-empty-pattern
test.afterEach(async ({}, testInfo) => {
await trashTemporal({
name: testInfo.title,
s3Client: minioClient,
scheduleId: scheduleIds[testInfo.title],
});
});
[
{
name: 'empty-to-preview',
setupCheck: checkEmpty,
switchCheck: checkPreview,
},
{
name: 'preview-to-reviews',
setupCheck: checkPreview,
switchCheck: checkReviews,
},
{
name: 'reviews-to-preview-revised',
setupCheck: checkReviews,
switchCheck: checkPreviewRevised,
},
{
name: 'preview-revised-to-revised',
setupCheck: checkPreviewRevised,
switchCheck: checkRevised,
},
{
name: 'revised-to-version-of-record',
setupCheck: checkRevised,
switchCheck: checkVersionOfRecord,
},
{
name: 'version-of-record-to-version-of-record-correction',
setupCheck: checkVersionOfRecord,
switchCheck: checkVersionOfRecordCorrection,
},
].forEach(({ name, setupCheck, switchCheck }) => {
test(`progress--${name}`, async ({ page }, testInfo) => {
const eppPage = new EppPage(page, testInfo.title);
await setupCheck(eppPage);
await changeState(testInfo.title, 'Switch');
await switchCheck(eppPage);
});
});
});