-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathoutcome.js
More file actions
159 lines (126 loc) · 5.2 KB
/
Copy pathoutcome.js
File metadata and controls
159 lines (126 loc) · 5.2 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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import { Then as Alors, Step } from '@badeball/cypress-cucumber-preprocessor';
import { parseStrToObject } from './support';
Alors("la glose ouverte a le titre par défaut", () => {
Step(this, "'…' est la glose ouverte");
});
Alors("{string} est la glose ouverte", (title) => {
cy.get('.runningHead .scholium').should('contain', title);
});
Alors("je peux lire {string}", (text) => {
cy.get('body').should('contain', text);
});
Alors("je vois l'image {string} dans la glose", (alternative_text) => {
cy.get('.row:not(.runningHead)>.main').should('have.descendants', `img[alt='${alternative_text}']`);
});
Alors("{string} est le document principal", (title) => {
cy.get('.main .work').should('contain', title);
cy.title().should('contain', title);
});
Alors("{string} une des gloses", (title) => {
cy.get('.gloses').should('contain', title);
});
Alors("{string} une des sources", (title) => {
cy.get('.sources').should('contain', title);
});
Alors("le créateur est {string}", (name) => {
cy.get('.metadata > .work').first().should('contain', name);
});
Alors("l'année de publication est {string}", (year) => {
cy.get('.metadata > .edition').first().should('contain', year);
});
Alors("la langue est {string}", (language) => {
cy.get('.metadata > .edition').first().should('contain', language);
});
Alors("la glose contient {string}", (text) => {
cy.contains('.scholium .formatted-text', text).should('exist');
});
Alors("la glose contient :", (text) => {
cy.contains('.scholium .formatted-text', text.replaceAll('\n', ' ')).should('exist');
});
Alors("la glose est ouverte en mode édition", () => {
cy.get('.scholium').should('have.descendants', 'form');
});
Alors("le document apparaît dans ma bibliothèque", function() {
cy.get('[alt="Index"]').click();
cy.get('.bookshelf').contains(this.randomName);
});
Alors("je vois {string} dans la liste des éditeurs", (userName) => {
cy.get('.modal-dialog .list-group').should('contain', userName);
cy.get('.modal-dialog .btn-close').click();
});
Alors("{string} peut modifier le document", (userName) => {
cy.sign_out();
cy.sign_in('christophe');
cy.edit_content('My own');
cy.contains('.formatted-text', 'My own');
});
Alors("le document apparaît dans la bibliothèque de {string}", function(userName) {
cy.sign_out();
cy.sign_in(userName);
cy.get('[alt="Index"]').click();
cy.get('.bookshelf').contains(this.randomName);
});
Alors("le type {string} est le type de la glose", (name) => {
cy.contains('.typeSelected', name);
});
Alors("la glose n'a pas de type", () => {
cy.get('.typeSelected').should('not.exist');
});
Alors("le texte du document principal est en surbrillance :", (text) => {
cy.contains('mark', text.trim()).should('exist');
});
Alors("la vidéo du document principal se lance de {int} à {int} secondes", (start, end) => {
cy.get(`iframe[src*="start=${start}&end=${end}"]`).should('exist');
});
Alors("la glose est ouverte en mode édition et contient :", (text) => {
cy.get('.scholium textarea').should('contain', text);
});
Alors("la rubrique {string} est associée au passage {string}", (rubric, text) => {
cy.contains('.row', text).contains('.rubric', rubric);
});
Alors("{string} est la glose ouverte en mode édition", (title) => {
cy.get('.runningHead .scholium').should('contain', title);
cy.get('.scholium').should('have.descendants', 'form');
});
Alors("la glose ouverte a {string} parmi les éditeurs par défaut", (userName) => {
cy.get('.icon.edit').click()
cy.click_on_contextual_menu_item('.runningHead .scholium', 'Invite editors...');
cy.get('.list-group').should('contain', userName);
});
Alors("la glose ouverte a {string} et {string} parmi les éditeurs par défaut", (userName1, userName2) => {
cy.get('.icon.edit').click()
cy.click_on_contextual_menu_item('.runningHead .scholium', 'Invite editors...');
cy.get('.list-group').should('contain', userName1);
cy.get('.list-group').should('contain', userName2);
});
Alors("je peux voir les informations de création du document {string} et une date", (text) => {
cy.get('.text-document-creation')
.should('contain.text', text + ' on');
cy.get('.text-document-creation').invoke('text')
.then((fullText) => {
const date = new Date(fullText.split('on')[1].trim());
expect(date).not.to.be.NaN;
});
});
Alors("je ne vois aucune information de création du document", () => {
cy.get('.text-document-creation')
.should('contain.text', 'No information about the creator and creation date of this document');
});
Alors("la glose ouverte a les métadonnées", (metadata) => {
cy.get('.icon.edit').click();
cy.get('.editable.metadata').click();
cy.get('form textarea').invoke('val').then(actual => {
const expectedMetadata = parseStrToObject(metadata);
const actualMetadata = parseStrToObject(actual);
Object.entries(expectedMetadata).forEach(([key, value]) => {
expect(actualMetadata).to.have.property(key, value);
});
});
});
Alors("je vois que le code de la licence est {string}", (n_licence) => {
cy.get('.license-container').eq(1).find('.license img[alt="' + n_licence + '"]').should('exist');
});
Alors("je ne peux pas lire {string}", (text) => {
cy.get('.license-compatibility').should('not.exist');
}
);