@jahia/cypress 3.21.0 → 3.21.2
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.
|
@@ -4,18 +4,18 @@ exports.apolloClient = exports.switchApolloClient = void 0;
|
|
|
4
4
|
var core_1 = require("@apollo/client/core");
|
|
5
5
|
var links_1 = require("./links");
|
|
6
6
|
var switchApolloClient = function (config, options) {
|
|
7
|
-
if (config === void 0) { config = {
|
|
7
|
+
if (config === void 0) { config = {}; }
|
|
8
8
|
if (options === void 0) { options = {
|
|
9
9
|
log: true,
|
|
10
10
|
setCurrentApolloClient: true
|
|
11
11
|
}; }
|
|
12
12
|
// Switch context to apollo client
|
|
13
|
-
cy.visit(config.url, { failOnStatusCode: false });
|
|
13
|
+
cy.visit(config.url || Cypress.config().baseUrl, { failOnStatusCode: false });
|
|
14
14
|
return exports.apolloClient(config, options);
|
|
15
15
|
};
|
|
16
16
|
exports.switchApolloClient = switchApolloClient;
|
|
17
17
|
var apolloClient = function (config, options) {
|
|
18
|
-
if (config === void 0) { config = {
|
|
18
|
+
if (config === void 0) { config = {}; }
|
|
19
19
|
if (options === void 0) { options = {
|
|
20
20
|
log: true,
|
|
21
21
|
setCurrentApolloClient: true
|
|
@@ -30,7 +30,7 @@ var apolloClient = function (config, options) {
|
|
|
30
30
|
else {
|
|
31
31
|
headers.authorization = "Basic " + btoa('root:' + Cypress.env('SUPER_USER_PASSWORD'));
|
|
32
32
|
}
|
|
33
|
-
var links = [links_1.uploadLink, links_1.formDataHttpLink(config.url, headers)];
|
|
33
|
+
var links = [links_1.uploadLink, links_1.formDataHttpLink(config.url || Cypress.config().baseUrl, headers)];
|
|
34
34
|
var client = new core_1.ApolloClient({
|
|
35
35
|
link: core_1.from(links),
|
|
36
36
|
cache: new core_1.InMemoryCache(),
|
package/dist/support/login.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
declare global {
|
|
3
3
|
namespace Cypress {
|
|
4
4
|
interface Chainable<Subject> {
|
|
5
|
-
login(username?: string, password?: string): Chainable<Cypress.Response<any>>;
|
|
6
|
-
loginAndStoreSession(username?: string, password?: string): Chainable<Cypress.Response<any>>;
|
|
5
|
+
login(username?: string, password?: string, url?: string): Chainable<Cypress.Response<any>>;
|
|
6
|
+
loginAndStoreSession(username?: string, password?: string, url?: string): Chainable<Cypress.Response<any>>;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
export declare const login: (username?: string, password?: string, url?: string) => void;
|
|
11
|
-
export declare const loginAndStoreSession: (username?: string, password?: string) => void;
|
|
11
|
+
export declare const loginAndStoreSession: (username?: string, password?: string, url?: string) => void;
|
package/dist/support/login.js
CHANGED
|
@@ -28,14 +28,15 @@ var login = function (username, password, url) {
|
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
30
|
exports.login = login;
|
|
31
|
-
var loginAndStoreSession = function (username, password) {
|
|
31
|
+
var loginAndStoreSession = function (username, password, url) {
|
|
32
32
|
if (username === void 0) { username = 'root'; }
|
|
33
33
|
if (password === void 0) { password = Cypress.env('SUPER_USER_PASSWORD'); }
|
|
34
|
+
if (url === void 0) { url = '/start'; }
|
|
34
35
|
cy.session('session-' + username, function () {
|
|
35
36
|
cy.login(username, password); // Edit in chief
|
|
36
37
|
}, {
|
|
37
38
|
validate: function () {
|
|
38
|
-
cy.request(
|
|
39
|
+
cy.request(url).its('status').should('eq', 200);
|
|
39
40
|
}
|
|
40
41
|
});
|
|
41
42
|
};
|
package/package.json
CHANGED
|
@@ -22,16 +22,16 @@ export type ApolloClientOptions = Cypress.Loggable & {
|
|
|
22
22
|
setCurrentApolloClient: boolean
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export const switchApolloClient = function (config: HostConfig = {
|
|
25
|
+
export const switchApolloClient = function (config: HostConfig = {}, options: ApolloClientOptions = {
|
|
26
26
|
log: true,
|
|
27
27
|
setCurrentApolloClient: true
|
|
28
28
|
}): void {
|
|
29
29
|
// Switch context to apollo client
|
|
30
|
-
cy.visit(config.url, {failOnStatusCode: false});
|
|
30
|
+
cy.visit(config.url || Cypress.config().baseUrl, {failOnStatusCode: false});
|
|
31
31
|
return apolloClient(config, options);
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
export const apolloClient = function (config: HostConfig = {
|
|
34
|
+
export const apolloClient = function (config: HostConfig = {}, options: ApolloClientOptions = {
|
|
35
35
|
log: true,
|
|
36
36
|
setCurrentApolloClient: true
|
|
37
37
|
}): void {
|
|
@@ -44,7 +44,7 @@ export const apolloClient = function (config: HostConfig = {url: Cypress.config(
|
|
|
44
44
|
headers.authorization = `Basic ${btoa('root:' + Cypress.env('SUPER_USER_PASSWORD'))}`;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const links = [uploadLink, formDataHttpLink(config.url, headers)];
|
|
47
|
+
const links = [uploadLink, formDataHttpLink(config.url || Cypress.config().baseUrl, headers)];
|
|
48
48
|
|
|
49
49
|
const client = new ApolloClient({
|
|
50
50
|
link: from(links),
|
package/src/support/login.ts
CHANGED
|
@@ -7,8 +7,8 @@ declare global {
|
|
|
7
7
|
namespace Cypress {
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
9
|
interface Chainable<Subject> {
|
|
10
|
-
login(username?: string, password?: string): Chainable<Cypress.Response<any>>
|
|
11
|
-
loginAndStoreSession(username?: string, password?: string): Chainable<Cypress.Response<any>>
|
|
10
|
+
login(username?: string, password?: string, url?: string): Chainable<Cypress.Response<any>>
|
|
11
|
+
loginAndStoreSession(username?: string, password?: string, url?: string): Chainable<Cypress.Response<any>>
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -36,12 +36,12 @@ export const login = (username = 'root', password: string = Cypress.env('SUPER_U
|
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
export const loginAndStoreSession = (username = 'root', password: string = Cypress.env('SUPER_USER_PASSWORD')): void => {
|
|
39
|
+
export const loginAndStoreSession = (username = 'root', password: string = Cypress.env('SUPER_USER_PASSWORD'), url = '/start'): void => {
|
|
40
40
|
cy.session('session-' + username, () => {
|
|
41
41
|
cy.login(username, password); // Edit in chief
|
|
42
42
|
}, {
|
|
43
43
|
validate() {
|
|
44
|
-
cy.request(
|
|
44
|
+
cy.request(url).its('status').should('eq', 200);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
};
|