@prismicio/e2e-tests-utils 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -9
- package/dist/clients/apiClient.cjs +39 -0
- package/dist/clients/apiClient.cjs.map +1 -0
- package/dist/clients/apiClient.d.ts +30 -0
- package/dist/clients/apiClient.js +39 -0
- package/dist/clients/apiClient.js.map +1 -0
- package/dist/clients/authenticationApi.cjs +54 -34
- package/dist/clients/authenticationApi.cjs.map +1 -1
- package/dist/clients/authenticationApi.d.ts +13 -5
- package/dist/clients/authenticationApi.js +55 -35
- package/dist/clients/authenticationApi.js.map +1 -1
- package/dist/clients/contentApi.cjs +12 -48
- package/dist/clients/contentApi.cjs.map +1 -1
- package/dist/clients/contentApi.d.ts +5 -6
- package/dist/clients/contentApi.js +12 -48
- package/dist/clients/contentApi.js.map +1 -1
- package/dist/clients/coreApi.cjs +36 -31
- package/dist/clients/coreApi.cjs.map +1 -1
- package/dist/clients/coreApi.d.ts +21 -3
- package/dist/clients/coreApi.js +37 -32
- package/dist/clients/coreApi.js.map +1 -1
- package/dist/clients/customTypesApi.cjs +48 -42
- package/dist/clients/customTypesApi.cjs.map +1 -1
- package/dist/clients/customTypesApi.d.ts +34 -6
- package/dist/clients/customTypesApi.js +49 -43
- package/dist/clients/customTypesApi.js.map +1 -1
- package/dist/clients/migrationApi.cjs +30 -29
- package/dist/clients/migrationApi.cjs.map +1 -1
- package/dist/clients/migrationApi.d.ts +25 -5
- package/dist/clients/migrationApi.js +31 -30
- package/dist/clients/migrationApi.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/managers/repositories.cjs +19 -9
- package/dist/managers/repositories.cjs.map +1 -1
- package/dist/managers/repositories.d.ts +2 -2
- package/dist/managers/repositories.js +23 -13
- package/dist/managers/repositories.js.map +1 -1
- package/dist/managers/repository.cjs +5 -0
- package/dist/managers/repository.cjs.map +1 -1
- package/dist/managers/repository.d.ts +6 -4
- package/dist/managers/repository.js +5 -0
- package/dist/managers/repository.js.map +1 -1
- package/dist/utils/log.cjs +4 -0
- package/dist/utils/log.cjs.map +1 -1
- package/dist/utils/log.d.ts +2 -0
- package/dist/utils/log.js +4 -0
- package/dist/utils/log.js.map +1 -1
- package/package.json +1 -1
- package/src/clients/apiClient.ts +48 -0
- package/src/clients/authenticationApi.ts +52 -50
- package/src/clients/contentApi.ts +18 -24
- package/src/clients/coreApi.ts +36 -42
- package/src/clients/customTypesApi.ts +34 -59
- package/src/clients/migrationApi.ts +33 -45
- package/src/managers/repositories.ts +26 -20
- package/src/managers/repository.ts +17 -7
- package/src/utils/log.ts +11 -0
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { SetupConfiguration, UrlConfig } from "../types";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "../clients/authenticationApi";
|
|
7
|
-
import { createCoreApiClient } from "../clients/coreApi";
|
|
8
|
-
import { createCustomTypesApiClient } from "../clients/customTypesApi";
|
|
3
|
+
import { AuthenticationApiClient } from "../clients/authenticationApi";
|
|
4
|
+
import { CoreApiClient } from "../clients/coreApi";
|
|
5
|
+
import { CustomTypesApiClient } from "../clients/customTypesApi";
|
|
9
6
|
import { ManageV2Client } from "../clients/manageV2";
|
|
10
|
-
import {
|
|
7
|
+
import { MigrationApiClient } from "../clients/migrationApi";
|
|
11
8
|
import { WroomClient } from "../clients/wroom";
|
|
12
9
|
import { EnvVariableManager } from "../utils/envVariableManager";
|
|
13
10
|
import { logHttpResponse, logger } from "../utils/log";
|
|
@@ -41,7 +38,7 @@ export class RepositoriesManager {
|
|
|
41
38
|
urlConfig: UrlConfig;
|
|
42
39
|
};
|
|
43
40
|
private readonly wroomClient: WroomClient;
|
|
44
|
-
private readonly authClient:
|
|
41
|
+
private readonly authClient: AuthenticationApiClient;
|
|
45
42
|
private readonly manageV2Client: ManageV2Client;
|
|
46
43
|
/**
|
|
47
44
|
* helper to keep track of repositories across independent test phases (setup,
|
|
@@ -70,7 +67,7 @@ export class RepositoriesManager {
|
|
|
70
67
|
this.config.urlConfig.baseURL,
|
|
71
68
|
this.config.authConfig,
|
|
72
69
|
);
|
|
73
|
-
this.authClient =
|
|
70
|
+
this.authClient = new AuthenticationApiClient(
|
|
74
71
|
this.config.urlConfig.authenticationApi,
|
|
75
72
|
this.config.authConfig,
|
|
76
73
|
);
|
|
@@ -139,9 +136,12 @@ export class RepositoriesManager {
|
|
|
139
136
|
}
|
|
140
137
|
this.repositories.add(repositoryName);
|
|
141
138
|
|
|
142
|
-
profiler.done({ message: `created repository '${repositoryName}'` });
|
|
143
|
-
|
|
144
139
|
const repository = this.getRepositoryManager(repositoryName);
|
|
140
|
+
const version = await repository.getDeployedVersion();
|
|
141
|
+
|
|
142
|
+
profiler.done({
|
|
143
|
+
message: `created repository '${repositoryName}', Wroom version is "${version}"`,
|
|
144
|
+
});
|
|
145
145
|
await repository.configure(config);
|
|
146
146
|
|
|
147
147
|
return repository;
|
|
@@ -190,23 +190,29 @@ export class RepositoriesManager {
|
|
|
190
190
|
/**
|
|
191
191
|
* Return a repository utilities object for a repository.
|
|
192
192
|
*
|
|
193
|
-
* @param
|
|
193
|
+
* @param repository - The name of the repository.
|
|
194
194
|
*/
|
|
195
|
-
getRepositoryManager(
|
|
195
|
+
getRepositoryManager(repository: string): RepositoryManager {
|
|
196
196
|
const { urlConfig } = this.config;
|
|
197
|
-
const
|
|
197
|
+
const authToken = () => this.authClient.getToken();
|
|
198
|
+
const customTypeClient = new CustomTypesApiClient(
|
|
198
199
|
urlConfig.customTypesApi,
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
{
|
|
201
|
+
authToken,
|
|
202
|
+
repository,
|
|
203
|
+
},
|
|
201
204
|
);
|
|
202
|
-
const coreApiUrl = getRepositoryUrl(urlConfig.baseURL,
|
|
203
|
-
const coreApiClient =
|
|
205
|
+
const coreApiUrl = getRepositoryUrl(urlConfig.baseURL, repository);
|
|
206
|
+
const coreApiClient = new CoreApiClient(coreApiUrl, authToken);
|
|
204
207
|
const migrationApiClient = urlConfig.migrationApi
|
|
205
|
-
?
|
|
208
|
+
? new MigrationApiClient(urlConfig.migrationApi, {
|
|
209
|
+
authToken,
|
|
210
|
+
repository,
|
|
211
|
+
})
|
|
206
212
|
: undefined;
|
|
207
213
|
|
|
208
214
|
return new RepositoryManager(
|
|
209
|
-
|
|
215
|
+
repository,
|
|
210
216
|
coreApiClient,
|
|
211
217
|
this.authClient,
|
|
212
218
|
this.wroomClient,
|
|
@@ -6,15 +6,15 @@ import {
|
|
|
6
6
|
SharedSlice,
|
|
7
7
|
} from "@prismicio/types-internal/lib/customtypes";
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import { AuthenticationApiClient } from "../clients/authenticationApi";
|
|
10
10
|
import { ContentApiClient } from "../clients/contentApi";
|
|
11
11
|
import type { CoreClient } from "../clients/coreApi";
|
|
12
|
-
import {
|
|
12
|
+
import { CustomTypesApiClient } from "../clients/customTypesApi";
|
|
13
13
|
import { ManageV2Client } from "../clients/manageV2";
|
|
14
14
|
import {
|
|
15
15
|
DocumentPayload,
|
|
16
16
|
DocumentResponse,
|
|
17
|
-
|
|
17
|
+
MigrationApiClient,
|
|
18
18
|
} from "../clients/migrationApi";
|
|
19
19
|
import { WroomClient } from "../clients/wroom";
|
|
20
20
|
import { logHttpResponse, logger } from "../utils/log";
|
|
@@ -25,10 +25,10 @@ export class RepositoryManager {
|
|
|
25
25
|
constructor(
|
|
26
26
|
readonly name: string,
|
|
27
27
|
private readonly coreApiClient: CoreClient,
|
|
28
|
-
private readonly authApiClient:
|
|
28
|
+
private readonly authApiClient: AuthenticationApiClient,
|
|
29
29
|
private readonly wroomClient: WroomClient,
|
|
30
|
-
private readonly customTypesApiClient:
|
|
31
|
-
private readonly migrationApiClient:
|
|
30
|
+
private readonly customTypesApiClient: CustomTypesApiClient,
|
|
31
|
+
private readonly migrationApiClient: MigrationApiClient | undefined,
|
|
32
32
|
private readonly manageV2Client: ManageV2Client,
|
|
33
33
|
) {}
|
|
34
34
|
|
|
@@ -37,7 +37,6 @@ export class RepositoryManager {
|
|
|
37
37
|
config.defaultLocale || config.locales || config.customLocale;
|
|
38
38
|
if (hasLangConfig) {
|
|
39
39
|
const languages = await this.coreApiClient.getLanguages();
|
|
40
|
-
|
|
41
40
|
// default locale must be set first
|
|
42
41
|
if (config.defaultLocale) {
|
|
43
42
|
const master = languages.find(({ is_master }) => is_master === true);
|
|
@@ -105,6 +104,17 @@ export class RepositoryManager {
|
|
|
105
104
|
return new ContentApiClient(this.getBaseCdnURL(), config);
|
|
106
105
|
}
|
|
107
106
|
|
|
107
|
+
/** @returns the Wroom commit hash deployed on the current repository */
|
|
108
|
+
async getDeployedVersion(): Promise<string | undefined> {
|
|
109
|
+
const response = await this.wroomClient.get(
|
|
110
|
+
this.name,
|
|
111
|
+
"underground/834b34f16f451e00f268dd5c8c81d16e3c020275",
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
// Somehow axios directly parses the text response `Prismic version: <commit hash> into a version attribute
|
|
115
|
+
return response.data.version;
|
|
116
|
+
}
|
|
117
|
+
|
|
108
118
|
/**
|
|
109
119
|
* Set additional standard locales for a repository in Wroom, does not fail if
|
|
110
120
|
* the locales already exist.
|
package/src/utils/log.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { APIResponse } from "@playwright/test";
|
|
1
2
|
import { AxiosResponse } from "axios";
|
|
2
3
|
import { createLogger, format, transports } from "winston";
|
|
3
4
|
|
|
@@ -13,6 +14,16 @@ export const logHttpResponse = (response: AxiosResponse): void => {
|
|
|
13
14
|
);
|
|
14
15
|
};
|
|
15
16
|
|
|
17
|
+
export const logPlaywrightApiResponse = async (
|
|
18
|
+
response: APIResponse,
|
|
19
|
+
): Promise<void> => {
|
|
20
|
+
logger.info(
|
|
21
|
+
`Call to ${response.url()} failed, received [${response.status()}] ${JSON.stringify(
|
|
22
|
+
await response.text(),
|
|
23
|
+
)}`,
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
16
27
|
const { combine, printf } = format;
|
|
17
28
|
|
|
18
29
|
const customFormat = printf(({ message, durationMs }) => {
|