Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit 76964f3

Browse files
author
thekiiingbob
committed
improve performance of waiting for new posts under bad network conditions
1 parent 7dca4bf commit 76964f3

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

cypress/integration/markdown/markdown_spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('Markdown message', () => {
7171

7272
// # Navigate to app and wait for posts request to finish
7373
cy.visit('/');
74-
cy.wait('@getPosts', {timeout: 20000}).should('have.property', 'status', 200);
74+
cy.wait('@getPosts', {timeout: 45000}).should('have.property', 'status', 200);
7575
});
7676

7777
testCases.forEach((testCase) => {

cypress/support/ui_commands.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,16 @@ Cypress.Commands.add('getLastPost', () => {
137137
});
138138

139139
Cypress.Commands.add('getLastPostId', (opts = {force: false}) => {
140-
cy.get('#postListContent #postContent', {timeout: 30000}).last().parent().as('_lastPost');
140+
cy.get('#postListContent #postContent', {timeout: 30000}).
141+
last().
142+
parent().as('parent');
141143

142-
if (!opts.force) {
143-
cy.get('@_lastPost').should('have.attr', 'id').and('not.include', ':');
144+
if (opts.force) {
145+
cy.get('@parent').should('have.attr', 'id').invoke('replace', 'post_', '');
146+
} else {
147+
cy.get('@parent').should('have.attr', 'id').and('not.include', ':').
148+
invoke('replace', 'post_', '');
144149
}
145-
146-
return cy.get('@_lastPost').invoke('attr', 'id').then((divPostId) => {
147-
return divPostId.replace('post_', '');
148-
});
149150
});
150151

151152
/**
@@ -182,9 +183,7 @@ Cypress.Commands.add('compareLastPostHTMLContentFromFile', (file) => {
182183
const postMessageTextId = `#postMessageText_${postId}`;
183184

184185
cy.fixture(file, 'utf-8').then((expectedHtml) => {
185-
cy.get(postMessageTextId).then((content) => {
186-
assert.equal(content[0].innerHTML, expectedHtml.replace(/\n$/, ''));
187-
});
186+
cy.get(postMessageTextId, {timeout: 150000}).should('have.html', expectedHtml.replace(/\n$/, ''));
188187
});
189188
});
190189
});

0 commit comments

Comments
 (0)