Skip to content

Commit 75b86d6

Browse files
committed
Better teaser cypress test
1 parent 4076c0a commit 75b86d6

1 file changed

Lines changed: 9 additions & 22 deletions

File tree

frontend/cypress/tests/core/blocks/blocks-teaser.js

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ context('Blocks Acceptance Tests', () => {
4545
cy.wait('@schema');
4646

4747
// WHEN I create a Teaser block
48-
cy.get('.block .slate-editor [contenteditable=true]').click();
49-
cy.get('.button .block-add-button').click({ force: true });
50-
cy.get('.blocks-chooser .mostUsed .button.teaser')
51-
.contains('Teaser')
52-
.click({ force: true });
48+
cy.addNewBlock('teaser');
5349
cy.get(
5450
'.objectbrowser-field[aria-labelledby="fieldset-default-field-label-href"] button[aria-label="Open object browser"]',
5551
).click();
@@ -89,20 +85,18 @@ context('Blocks Acceptance Tests', () => {
8985
});
9086

9187
cy.navigate('/document/edit');
88+
cy.wait('@schema');
9289
// WHEN I create a Teaser block and change the data of the referenced object
93-
cy.get('.block .slate-editor [contenteditable=true]').click();
94-
cy.get('.button .block-add-button').click({ force: true });
95-
cy.get('.blocks-chooser .mostUsed .button.teaser')
96-
.contains('Teaser')
97-
.click({ force: true });
90+
cy.addNewBlock('teaser');
9891
cy.get(
9992
'.objectbrowser-field[aria-labelledby="fieldset-default-field-label-href"] button[aria-label="Open object browser"]',
10093
).click();
10194
cy.get('[aria-label="Select Blue Orchids"]').dblclick();
102-
cy.wait(500);
10395
cy.get('#toolbar-save').click();
96+
cy.wait('@content');
10497

105-
cy.visit('/document');
98+
cy.navigate('/document');
99+
cy.wait('@content');
106100
cy.get('.block.teaser .card-summary h2').contains('Blue Orchids');
107101
cy.get('.block.teaser .card-summary p').contains(
108102
'are growing on the mountain tops',
@@ -118,6 +112,7 @@ context('Blocks Acceptance Tests', () => {
118112
cy.get('.documentFirstHeading').contains('Blue Orchids and Tulips');
119113
// THEN I can see the updated content in the teaser
120114
cy.navigate('/document');
115+
cy.wait('@content');
121116
cy.get('.block.teaser .card-summary h2').contains(
122117
'Blue Orchids and Tulips',
123118
);
@@ -140,11 +135,7 @@ context('Blocks Acceptance Tests', () => {
140135
});
141136
cy.visit('/document/edit');
142137
// WHEN I create a Teaser block and change the data of the referenced object
143-
cy.get('.block .slate-editor [contenteditable=true]').click();
144-
cy.get('.button .block-add-button').click({ force: true });
145-
cy.get('.blocks-chooser .mostUsed .button.teaser')
146-
.contains('Teaser')
147-
.click({ force: true });
138+
cy.addNewBlock('teaser');
148139
cy.get(
149140
'.objectbrowser-field[aria-labelledby="fieldset-default-field-label-href"] button[aria-label="Open object browser"]',
150141
).click();
@@ -185,11 +176,7 @@ context('Blocks Acceptance Tests', () => {
185176

186177
cy.navigate('/document/edit');
187178
// WHEN I create a Teaser block and change the data of the referenced object
188-
cy.get('.block .slate-editor [contenteditable=true]').click();
189-
cy.get('.button .block-add-button').click({ force: true });
190-
cy.get('.blocks-chooser .mostUsed .button.teaser')
191-
.contains('Teaser')
192-
.click({ force: true });
179+
cy.addNewBlock('teaser');
193180
cy.get(
194181
'.objectbrowser-field[aria-labelledby="fieldset-default-field-label-href"] button[aria-label="Open object browser"]',
195182
).click();

0 commit comments

Comments
 (0)