@prismicio/e2e-tests-utils 2.0.0-alpha.6 → 2.0.0-alpha.8
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.
|
@@ -20,14 +20,15 @@ async function login(baseUrl, email, password) {
|
|
|
20
20
|
throw new Error("Could not obtain OAuth token, check your credentials");
|
|
21
21
|
}
|
|
22
22
|
profiler.done({ message: "logged in via OAuth" });
|
|
23
|
-
const token = response.data.
|
|
23
|
+
const token = response.data.token;
|
|
24
24
|
return { token, cookies: response.headers["set-cookie"] };
|
|
25
25
|
}
|
|
26
26
|
function transformUrl(baseUrl, subdomainPrefix) {
|
|
27
27
|
try {
|
|
28
28
|
const url = new URL(baseUrl);
|
|
29
29
|
const domainParts = url.hostname.split(".");
|
|
30
|
-
const
|
|
30
|
+
const mainDomain = domainParts.slice(-2).join(".");
|
|
31
|
+
const transformedHostname = `${subdomainPrefix}.${mainDomain}`;
|
|
31
32
|
return `${url.protocol}//${transformedHostname}`;
|
|
32
33
|
} catch (error) {
|
|
33
34
|
throw new Error(`Invalid URL: ${baseUrl}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.cjs","sources":["../../../src/utils/authentication.ts"],"sourcesContent":["import axios from \"axios\";\n\nimport { logHttpResponse, logger } from \"./log\";\n\nexport async function login(\n\tbaseUrl: string,\n\temail: string,\n\tpassword: string,\n): Promise<{ token: string; cookies: string[] | undefined }> {\n\tconst profiler = logger.startTimer();\n\n\tconst payload = {\n\t\temail,\n\t\tpassword,\n\t};\n\n\tconst url = transformUrl(baseUrl, \"auth.internal\");\n\n\tconst response = await axios.post<{
|
|
1
|
+
{"version":3,"file":"authentication.cjs","sources":["../../../src/utils/authentication.ts"],"sourcesContent":["import axios from \"axios\";\n\nimport { logHttpResponse, logger } from \"./log\";\n\nexport async function login(\n\tbaseUrl: string,\n\temail: string,\n\tpassword: string,\n): Promise<{ token: string; cookies: string[] | undefined }> {\n\tconst profiler = logger.startTimer();\n\n\tconst payload = {\n\t\temail,\n\t\tpassword,\n\t};\n\n\tconst url = transformUrl(baseUrl, \"auth.internal\");\n\n\tconst response = await axios.post<{ token: string }>(\n\t\t`${url}/login-e2e`,\n\t\tpayload,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\tAuthorization:\n\t\t\t\t\t\"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NDE3ODQ5NDEsImF1ZCI6ImF1dGgwLWFjdGlvbnMiLCJpc3MiOiJwcmlzbWljLmlvIn0.1UPoVMXJSTWtsyNzK5XYftK_mW0ScVuXwCK69nsyf5c\",\n\t\t\t},\n\t\t},\n\t);\n\n\tif (response.status !== 200) {\n\t\tlogHttpResponse(response);\n\t\tthrow new Error(\"Could not obtain OAuth token, check your credentials\");\n\t}\n\n\tprofiler.done({ message: \"logged in via OAuth\" });\n\tconst token = response.data.token;\n\n\treturn { token, cookies: response.headers[\"set-cookie\"] };\n}\n\nfunction transformUrl(baseUrl: string, subdomainPrefix: string): string {\n\ttry {\n\t\tconst url = new URL(baseUrl);\n\t\tconst domainParts = url.hostname.split(\".\");\n\n\t\t// Ensure we retain only the main domain (e.g., \"platform-wroom.com\")\n\t\tconst mainDomain = domainParts.slice(-2).join(\".\"); // Keeps last two parts of domain\n\n\t\t// Construct the new hostname with the custom prefix\n\t\tconst transformedHostname = `${subdomainPrefix}.${mainDomain}`;\n\n\t\t// Construct and return the full URL with the new hostname\n\t\treturn `${url.protocol}//${transformedHostname}`;\n\t} catch (error) {\n\t\tthrow new Error(`Invalid URL: ${baseUrl}`);\n\t}\n}\n"],"names":["logger","logHttpResponse"],"mappings":";;;;AAIsB,eAAA,MACrB,SACA,OACA,UAAgB;AAEV,QAAA,WAAWA,WAAO;AAExB,QAAM,UAAU;AAAA,IACf;AAAA,IACA;AAAA,EAAA;AAGK,QAAA,MAAM,aAAa,SAAS,eAAe;AAEjD,QAAM,WAAW,MAAM,MAAM,KAC5B,GAAG,GAAG,cACN,SACA;AAAA,IACC,SAAS;AAAA,MACR,cAAc;AAAA,MACd,eACC;AAAA,IACD;AAAA,EAAA,CACD;AAGE,MAAA,SAAS,WAAW,KAAK;AAC5BC,QAAA,gBAAgB,QAAQ;AAClB,UAAA,IAAI,MAAM,sDAAsD;AAAA,EACvE;AAEA,WAAS,KAAK,EAAE,SAAS,sBAAuB,CAAA;AAC1C,QAAA,QAAQ,SAAS,KAAK;AAE5B,SAAO,EAAE,OAAO,SAAS,SAAS,QAAQ,YAAY;AACvD;AAEA,SAAS,aAAa,SAAiB,iBAAuB;AACzD,MAAA;AACG,UAAA,MAAM,IAAI,IAAI,OAAO;AAC3B,UAAM,cAAc,IAAI,SAAS,MAAM,GAAG;AAG1C,UAAM,aAAa,YAAY,MAAM,EAAE,EAAE,KAAK,GAAG;AAGjD,UAAM,sBAAsB,GAAG,eAAe,IAAI,UAAU;AAG5D,WAAO,GAAG,IAAI,QAAQ,KAAK,mBAAmB;AAAA,WACtC,OAAO;AACf,UAAM,IAAI,MAAM,gBAAgB,OAAO,EAAE;AAAA,EAC1C;AACD;;"}
|
|
@@ -18,14 +18,15 @@ async function login(baseUrl, email, password) {
|
|
|
18
18
|
throw new Error("Could not obtain OAuth token, check your credentials");
|
|
19
19
|
}
|
|
20
20
|
profiler.done({ message: "logged in via OAuth" });
|
|
21
|
-
const token = response.data.
|
|
21
|
+
const token = response.data.token;
|
|
22
22
|
return { token, cookies: response.headers["set-cookie"] };
|
|
23
23
|
}
|
|
24
24
|
function transformUrl(baseUrl, subdomainPrefix) {
|
|
25
25
|
try {
|
|
26
26
|
const url = new URL(baseUrl);
|
|
27
27
|
const domainParts = url.hostname.split(".");
|
|
28
|
-
const
|
|
28
|
+
const mainDomain = domainParts.slice(-2).join(".");
|
|
29
|
+
const transformedHostname = `${subdomainPrefix}.${mainDomain}`;
|
|
29
30
|
return `${url.protocol}//${transformedHostname}`;
|
|
30
31
|
} catch (error) {
|
|
31
32
|
throw new Error(`Invalid URL: ${baseUrl}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.js","sources":["../../../src/utils/authentication.ts"],"sourcesContent":["import axios from \"axios\";\n\nimport { logHttpResponse, logger } from \"./log\";\n\nexport async function login(\n\tbaseUrl: string,\n\temail: string,\n\tpassword: string,\n): Promise<{ token: string; cookies: string[] | undefined }> {\n\tconst profiler = logger.startTimer();\n\n\tconst payload = {\n\t\temail,\n\t\tpassword,\n\t};\n\n\tconst url = transformUrl(baseUrl, \"auth.internal\");\n\n\tconst response = await axios.post<{
|
|
1
|
+
{"version":3,"file":"authentication.js","sources":["../../../src/utils/authentication.ts"],"sourcesContent":["import axios from \"axios\";\n\nimport { logHttpResponse, logger } from \"./log\";\n\nexport async function login(\n\tbaseUrl: string,\n\temail: string,\n\tpassword: string,\n): Promise<{ token: string; cookies: string[] | undefined }> {\n\tconst profiler = logger.startTimer();\n\n\tconst payload = {\n\t\temail,\n\t\tpassword,\n\t};\n\n\tconst url = transformUrl(baseUrl, \"auth.internal\");\n\n\tconst response = await axios.post<{ token: string }>(\n\t\t`${url}/login-e2e`,\n\t\tpayload,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\tAuthorization:\n\t\t\t\t\t\"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NDE3ODQ5NDEsImF1ZCI6ImF1dGgwLWFjdGlvbnMiLCJpc3MiOiJwcmlzbWljLmlvIn0.1UPoVMXJSTWtsyNzK5XYftK_mW0ScVuXwCK69nsyf5c\",\n\t\t\t},\n\t\t},\n\t);\n\n\tif (response.status !== 200) {\n\t\tlogHttpResponse(response);\n\t\tthrow new Error(\"Could not obtain OAuth token, check your credentials\");\n\t}\n\n\tprofiler.done({ message: \"logged in via OAuth\" });\n\tconst token = response.data.token;\n\n\treturn { token, cookies: response.headers[\"set-cookie\"] };\n}\n\nfunction transformUrl(baseUrl: string, subdomainPrefix: string): string {\n\ttry {\n\t\tconst url = new URL(baseUrl);\n\t\tconst domainParts = url.hostname.split(\".\");\n\n\t\t// Ensure we retain only the main domain (e.g., \"platform-wroom.com\")\n\t\tconst mainDomain = domainParts.slice(-2).join(\".\"); // Keeps last two parts of domain\n\n\t\t// Construct the new hostname with the custom prefix\n\t\tconst transformedHostname = `${subdomainPrefix}.${mainDomain}`;\n\n\t\t// Construct and return the full URL with the new hostname\n\t\treturn `${url.protocol}//${transformedHostname}`;\n\t} catch (error) {\n\t\tthrow new Error(`Invalid URL: ${baseUrl}`);\n\t}\n}\n"],"names":[],"mappings":";;AAIsB,eAAA,MACrB,SACA,OACA,UAAgB;AAEV,QAAA,WAAW,OAAO;AAExB,QAAM,UAAU;AAAA,IACf;AAAA,IACA;AAAA,EAAA;AAGK,QAAA,MAAM,aAAa,SAAS,eAAe;AAEjD,QAAM,WAAW,MAAM,MAAM,KAC5B,GAAG,GAAG,cACN,SACA;AAAA,IACC,SAAS;AAAA,MACR,cAAc;AAAA,MACd,eACC;AAAA,IACD;AAAA,EAAA,CACD;AAGE,MAAA,SAAS,WAAW,KAAK;AAC5B,oBAAgB,QAAQ;AAClB,UAAA,IAAI,MAAM,sDAAsD;AAAA,EACvE;AAEA,WAAS,KAAK,EAAE,SAAS,sBAAuB,CAAA;AAC1C,QAAA,QAAQ,SAAS,KAAK;AAE5B,SAAO,EAAE,OAAO,SAAS,SAAS,QAAQ,YAAY;AACvD;AAEA,SAAS,aAAa,SAAiB,iBAAuB;AACzD,MAAA;AACG,UAAA,MAAM,IAAI,IAAI,OAAO;AAC3B,UAAM,cAAc,IAAI,SAAS,MAAM,GAAG;AAG1C,UAAM,aAAa,YAAY,MAAM,EAAE,EAAE,KAAK,GAAG;AAGjD,UAAM,sBAAsB,GAAG,eAAe,IAAI,UAAU;AAG5D,WAAO,GAAG,IAAI,QAAQ,KAAK,mBAAmB;AAAA,WACtC,OAAO;AACf,UAAM,IAAI,MAAM,gBAAgB,OAAO,EAAE;AAAA,EAC1C;AACD;"}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ export async function login(
|
|
|
16
16
|
|
|
17
17
|
const url = transformUrl(baseUrl, "auth.internal");
|
|
18
18
|
|
|
19
|
-
const response = await axios.post<{
|
|
19
|
+
const response = await axios.post<{ token: string }>(
|
|
20
20
|
`${url}/login-e2e`,
|
|
21
21
|
payload,
|
|
22
22
|
{
|
|
@@ -34,7 +34,7 @@ export async function login(
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
profiler.done({ message: "logged in via OAuth" });
|
|
37
|
-
const token = response.data.
|
|
37
|
+
const token = response.data.token;
|
|
38
38
|
|
|
39
39
|
return { token, cookies: response.headers["set-cookie"] };
|
|
40
40
|
}
|
|
@@ -44,10 +44,13 @@ function transformUrl(baseUrl: string, subdomainPrefix: string): string {
|
|
|
44
44
|
const url = new URL(baseUrl);
|
|
45
45
|
const domainParts = url.hostname.split(".");
|
|
46
46
|
|
|
47
|
-
//
|
|
48
|
-
const
|
|
47
|
+
// Ensure we retain only the main domain (e.g., "platform-wroom.com")
|
|
48
|
+
const mainDomain = domainParts.slice(-2).join("."); // Keeps last two parts of domain
|
|
49
49
|
|
|
50
|
-
// Construct the new
|
|
50
|
+
// Construct the new hostname with the custom prefix
|
|
51
|
+
const transformedHostname = `${subdomainPrefix}.${mainDomain}`;
|
|
52
|
+
|
|
53
|
+
// Construct and return the full URL with the new hostname
|
|
51
54
|
return `${url.protocol}//${transformedHostname}`;
|
|
52
55
|
} catch (error) {
|
|
53
56
|
throw new Error(`Invalid URL: ${baseUrl}`);
|