-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommands.js
More file actions
99 lines (91 loc) · 2.75 KB
/
Copy pathcommands.js
File metadata and controls
99 lines (91 loc) · 2.75 KB
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
import '@plone/volto/cypress/add-commands';
// --- DEEPL -------------------------------------------------------------------
// Configure the DeepL control panel with the API key and log in.
// Common setup for all block translation acceptance tests.
Cypress.Commands.add('setupDeepL', () => {
const apiKey = Cypress.env('DEEPL_API_KEY');
if (!apiKey) {
throw new Error('DEEPL_API_KEY environment variable is not set');
}
cy.request({
url: '/++api++/@controlpanels/DeepLSettings',
method: 'PATCH',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Basic YWRtaW46c2VjcmV0',
},
body: {
deepl_api_auth_token: apiKey,
deepl_api_timeout: 10,
},
}).then((response) => {
expect(response.status).to.eq(204);
});
cy.autologin();
});
// Open "Manage Translations" and trigger the automatic translation,
// landing on the German (/de) add form. Common to all block tests.
Cypress.Commands.add('createTranslation', () => {
cy.get('#toolbar-more').click();
cy.findByText('Manage Translations').should('be.visible').click();
cy.get('.manage-multilingual-tools .buttons a').eq(1).click();
});
// --- SOLR --------------------------------------------------------------------
Cypress.Commands.add('reindexSolr', () => {
const log = Cypress.log({
name: 'log',
displayName: `reindexSolr`,
});
const api_url = 'http://localhost:55001/plone';
const auth = {
user: 'admin',
pass: 'secret',
};
return cy
.request({
method: 'GET',
url: `${api_url}/@@solr-maintenance/reindex`,
auth: auth,
})
.then(() => log.set('message', 'solr reindex complete'));
});
Cypress.Commands.add('clearSolr', () => {
const log = Cypress.log({
name: 'log',
displayName: `clearSolr`,
});
const api_url = 'http://localhost:55001/plone';
const auth = {
user: 'admin',
pass: 'secret',
};
return cy
.request({
method: 'GET',
url: `${api_url}/@@solr-maintenance/clear`,
auth: auth,
})
.then(() => log.set('message', 'solr clear complete'));
});
Cypress.Commands.add(
'addPathQuerystring',
(option = 'Relative path', value) => {
cy.get('.block-editor-listing').click();
cy.get('.querystring-widget .fields').contains('Add criteria').click();
cy.get('.querystring-widget .react-select__menu .react-select__option')
.contains('Path')
.click();
cy.get('.querystring-widget .fields').contains('Absolute path').click();
cy.get(
'.querystring-widget .fields .react-select__menu .react-select__option',
)
.contains(option)
.click();
if (value) {
cy.get('.querystring-widget .fields .input')
.click()
.type(`${value}{enter}`);
}
},
);