Basis for test, no actual assertion yet for UX
parent
3f2c1ae1dd
commit
6a1b2005bd
|
@ -1,5 +1,38 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
// This test is for https://github.com/ether/etherpad-lite/issues/1763
|
||||||
|
// Multiple browsers edit a pad and we check to ensure we can still perform
|
||||||
|
// a task quickly.
|
||||||
|
// We need to get up to 700 lines so the additional space breaks and enter keys
|
||||||
|
// in specialKeys are intentional.
|
||||||
|
|
||||||
|
const numberOfEdits = 100;
|
||||||
|
const specialKeys = ['{{}',
|
||||||
|
'{backspace}',
|
||||||
|
'{del}',
|
||||||
|
'{downarrow}',
|
||||||
|
'{end}',
|
||||||
|
'{enter}',
|
||||||
|
'{enter}',
|
||||||
|
'{enter}',
|
||||||
|
'{enter}',
|
||||||
|
'{esc}',
|
||||||
|
'{home}',
|
||||||
|
'{insert}',
|
||||||
|
'{leftarrow}',
|
||||||
|
'{movetoend}',
|
||||||
|
'{movetostart}',
|
||||||
|
'{pagedown}',
|
||||||
|
'{pageup}',
|
||||||
|
'{rightarrow}',
|
||||||
|
' ',
|
||||||
|
' ',
|
||||||
|
' ',
|
||||||
|
' ',
|
||||||
|
' ',
|
||||||
|
' ',
|
||||||
|
'{uparrow}']; // includes intentional white space
|
||||||
|
|
||||||
Cypress.Commands.add('iframe', {prevSubject: 'element'},
|
Cypress.Commands.add('iframe', {prevSubject: 'element'},
|
||||||
($iframe) => new Cypress.Promise((resolve) => {
|
($iframe) => new Cypress.Promise((resolve) => {
|
||||||
$iframe.ready(() => {
|
$iframe.ready(() => {
|
||||||
|
@ -8,23 +41,65 @@ Cypress.Commands.add('iframe', {prevSubject: 'element'},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe(__filename, () => {
|
describe(__filename, () => {
|
||||||
it('Pad content exists', () => {
|
it('Makes edits to pad', () => {
|
||||||
|
let originalLineCount;
|
||||||
cy.visit('http://127.0.0.1:9001/p/collab');
|
cy.visit('http://127.0.0.1:9001/p/collab');
|
||||||
cy.wait(10000); // wait for Minified JS to be built...
|
// Until we find a better way, this is required.
|
||||||
cy.get('iframe[name="ace_outer"]', {timeout: 10000}).iframe()
|
// cy.wait(10000); // wait for Minified JS to be built...
|
||||||
.find('.line-number:first')
|
cy.get('iframe[name="ace_outer"]', {timeout: 30000}).iframe()
|
||||||
.should('have.text', '1');
|
|
||||||
cy.get('iframe[name="ace_outer"]').iframe()
|
|
||||||
.find('iframe[name="ace_inner"]').iframe()
|
.find('iframe[name="ace_inner"]').iframe()
|
||||||
.find('.ace-line:first')
|
.find('.ace-line:first')
|
||||||
.should('be.visible');
|
.should('be.visible');
|
||||||
|
|
||||||
cy.get('iframe[name="ace_outer"]').iframe()
|
cy.get('iframe[name="ace_outer"]').iframe()
|
||||||
.find('iframe[name="ace_inner"]').iframe()
|
.find('iframe[name="ace_inner"]').iframe()
|
||||||
.find('.ace-line:first')
|
.find('div')
|
||||||
.type('Hello, World');
|
.should(($lines) => {
|
||||||
|
originalLineCount = $lines.length;
|
||||||
|
});
|
||||||
|
|
||||||
|
let i = 0;
|
||||||
|
let enterKeyCount = 0;
|
||||||
|
while (i < numberOfEdits) {
|
||||||
|
const specialKey = specialKeys[Math.floor(Math.random() * specialKeys.length)];
|
||||||
|
if (specialKey === '{enter}') enterKeyCount++;
|
||||||
|
|
||||||
|
cy.get('iframe[name="ace_outer"]').iframe()
|
||||||
|
.find('iframe[name="ace_inner"]').iframe()
|
||||||
|
.find('.ace-line:last')
|
||||||
|
.type(specialKey);
|
||||||
|
|
||||||
|
cy.get('iframe[name="ace_outer"]').iframe()
|
||||||
|
.find('iframe[name="ace_inner"]').iframe()
|
||||||
|
.find('.ace-line:last')
|
||||||
|
.type(randomString(16));
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now all pad content should exist we can assert some things..
|
||||||
cy.get('iframe[name="ace_outer"]').iframe()
|
cy.get('iframe[name="ace_outer"]').iframe()
|
||||||
.find('iframe[name="ace_inner"]').iframe()
|
.find('iframe[name="ace_inner"]').iframe()
|
||||||
.find('.ace-line:first')
|
.should('be.visible')
|
||||||
.type('Hello, World2');
|
.should(($inner) => {
|
||||||
|
// editor exists
|
||||||
|
expect($inner).to.have.length(1);
|
||||||
|
// and is visible
|
||||||
|
expect($inner).to.be.visible;
|
||||||
|
// line count has grown
|
||||||
|
expect($inner.find('div').length).to.be.at.least(enterKeyCount + originalLineCount);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const randomString = (stringLength) => {
|
||||||
|
let randomstring = '';
|
||||||
|
for (let i = 0; i < stringLength; i++) {
|
||||||
|
const charNumber = Math.random() * (300 - 1) + 1;
|
||||||
|
const str = String.fromCharCode(parseInt(charNumber));
|
||||||
|
// This method generates sufficient noise
|
||||||
|
// It also includes white space and non ASCII Chars
|
||||||
|
randomstring += str;
|
||||||
|
}
|
||||||
|
return randomstring;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue