libreoffice-online/cypress_test/integration_tests/mobile/calc/alignment_options_spec.js
Tamás Zolnai 8db4b19469 cypress: move includes of 3rd-party packages to support file.
Now we handle support file better for parallel test run too:
a13b1a93bc

Signed-off-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Change-Id: I4a88f815ddb1c4d79042134cc07e0c418d4ea10f
2020-12-28 15:11:06 +01:00

327 lines
7.6 KiB
JavaScript

/* global describe it cy beforeEach require afterEach expect*/
var helper = require('../../common/helper');
var calcHelper = require('../../common/calc_helper');
var mobileHelper = require('../../common/mobile_helper');
var calcMobileHelper = require('./calc_mobile_helper');
describe('Change alignment settings.', function() {
var testFileName = 'alignment_options.ods';
beforeEach(function() {
helper.beforeAll(testFileName, 'calc');
// Click on edit button
mobileHelper.enableEditingMobile();
});
afterEach(function() {
helper.afterAll(testFileName, this.currentTest.state);
});
function getTextEndPosForFirstCell() {
calcHelper.dblClickOnFirstCell();
helper.getCursorPos('left', 'currentTextEndPos');
calcHelper.removeTextSelection();
}
function openAlignmentPaneForFirstCell() {
calcHelper.clickOnFirstCell();
mobileHelper.openMobileWizard();
helper.clickOnIdle('#ScAlignmentPropertyPanel');
cy.get('#AlignLeft')
.should('be.visible');
}
it('Apply left/right alignment', function() {
openAlignmentPaneForFirstCell();
// Set right aligment first
helper.clickOnIdle('#AlignRight');
calcHelper.selectEntireSheet();
cy.get('#copy-paste-container table td')
.should('have.attr', 'align', 'right');
// Change alignment back
calcHelper.clickOnFirstCell();
mobileHelper.openMobileWizard();
helper.clickOnIdle('#ScAlignmentPropertyPanel');
helper.clickOnIdle('#AlignLeft');
calcHelper.selectEntireSheet();
cy.get('#copy-paste-container table td')
.should('have.attr', 'align', 'left');
});
it('Align to center horizontally.', function() {
openAlignmentPaneForFirstCell();
helper.clickOnIdle('#AlignHorizontalCenter');
calcHelper.selectEntireSheet();
cy.get('#copy-paste-container table td')
.should('have.attr', 'align', 'center');
});
it('Change to block alignment.', function() {
openAlignmentPaneForFirstCell();
helper.clickOnIdle('#AlignBlock');
calcHelper.selectEntireSheet();
cy.get('#copy-paste-container table td')
.should('have.attr', 'align', 'justify');
});
it('Right-to-left and left-to-right writing mode.', function() {
openAlignmentPaneForFirstCell();
helper.clickOnIdle('#ParaRightToLeft');
// TODO: we don't have a way of testing this
// copy container doesn't have info about this
cy.wait(500);
helper.clickOnIdle('#ParaLeftToRight');
cy.wait(500);
});
it('Align to the top and to bottom.', function() {
openAlignmentPaneForFirstCell();
helper.clickOnIdle('#AlignTop');
calcHelper.selectEntireSheet();
cy.get('#copy-paste-container table td')
.should('have.attr', 'valign', 'top');
// Change alignment back
calcHelper.clickOnFirstCell();
mobileHelper.openMobileWizard();
helper.clickOnIdle('#ScAlignmentPropertyPanel');
helper.clickOnIdle('#AlignBottom');
calcHelper.selectEntireSheet();
cy.get('#copy-paste-container table td')
.should('have.attr', 'valign', 'bottom');
});
it('Align to center vertically.', function() {
openAlignmentPaneForFirstCell();
helper.clickOnIdle('#AlignVCenter');
calcHelper.selectEntireSheet();
cy.get('#copy-paste-container table td')
.should('have.attr', 'valign', 'middle');
});
it('Increment / decrement text indent.', function() {
helper.initAliasToNegative('originalTextEndPos');
// Get text position first
getTextEndPosForFirstCell();
cy.get('@currentTextEndPos')
.as('originalTextEndPos');
cy.get('@originalTextEndPos')
.should('be.greaterThan', 0);
openAlignmentPaneForFirstCell();
// Increase indent
helper.clickOnIdle('#IncrementIndent');
// We use the text position as indicator
cy.get('body')
.should(function() {
getTextEndPosForFirstCell();
cy.get('@currentTextEndPos')
.then(function(currentTextEndPos) {
cy.get('@originalTextEndPos')
.then(function(originalTextEndPos) {
expect(originalTextEndPos).to.be.lessThan(currentTextEndPos);
});
});
});
helper.initAliasToNegative('originalTextEndPos');
cy.get('@currentTextEndPos')
.as('originalTextEndPos');
cy.get('@currentTextEndPos')
.should('be.greaterThan', 0);
// Decrease indent
openAlignmentPaneForFirstCell();
helper.clickOnIdle('#DecrementIndent');
// We use the text position as indicator
cy.get('body')
.should(function() {
getTextEndPosForFirstCell();
cy.get('@currentTextEndPos')
.then(function(currentTextEndPos) {
cy.get('@originalTextEndPos')
.then(function(originalTextEndPos) {
expect(originalTextEndPos).to.be.greaterThan(currentTextEndPos);
});
});
});
});
it.skip('Change text indent via input field.', function() {
// TODO: this fails, because the input field always becomes disabled.
helper.initAliasToNegative('originalTextEndPos');
getTextEndPosForFirstCell();
cy.get('@currentTextEndPos')
.as('originalTextEndPos');
cy.get('@currentTextEndPos')
.should('be.greaterThan', 0);
openAlignmentPaneForFirstCell();
// TODO: First we need to increase indent to make the input enabled
helper.clickOnIdle('#IncrementIndent');
cy.wait(300);
helper.clickOnIdle('#IncrementIndent');
calcHelper.removeTextSelection();
openAlignmentPaneForFirstCell();
cy.get('#leftindent .spinfield')
.should('not.have.attr', 'disabled');
// Increase indent
cy.get('#leftindent .spinfield')
.clear()
.type('20{enter}');
// We use the text position as indicator
cy.get('body')
.should(function() {
getTextEndPosForFirstCell();
cy.get('@currentTextEndPos')
.then(function(currentTextEndPos) {
cy.get('@originalTextEndPos')
.then(function(originalTextEndPos) {
expect(originalTextEndPos).to.be.lessThan(currentTextEndPos);
});
});
});
});
it('Enable text wrapping.', function() {
helper.initAliasToNegative('originalTextEndPos');
getTextEndPosForFirstCell();
cy.get('@currentTextEndPos')
.as('originalTextEndPos');
cy.get('@currentTextEndPos')
.should('be.greaterThan', 0);
openAlignmentPaneForFirstCell();
cy.get('input#wraptext')
.should('not.have.prop', 'checked', true);
helper.clickOnIdle('input#wraptext');
cy.get('input#wraptext')
.should('have.prop', 'checked', true);
// We use the text position as indicator
cy.waitUntil(function() {
getTextEndPosForFirstCell();
return cy.get('@currentTextEndPos')
.then(function(currentTextEndPos) {
return cy.get('@originalTextEndPos')
.then(function(originalTextEndPos) {
return originalTextEndPos > currentTextEndPos;
});
});
});
});
it('Apply stacked option.', function() {
openAlignmentPaneForFirstCell();
cy.get('input#stacked')
.should('not.have.prop', 'checked', true);
helper.clickOnIdle('input#stacked');
cy.get('input#stacked')
.should('have.prop', 'checked', true);
cy.wait(500);
// TODO: we don't have a good indicator here
// neither the text position nor the clipboard container helps here.
});
it('Merge cells.', function() {
// Select the full row
calcMobileHelper.selectFirstRow();
// Despite the selection is there, merge cells needs more time here.
cy.wait(1000);
mobileHelper.openMobileWizard();
helper.clickOnIdle('#ScAlignmentPropertyPanel');
cy.get('#AlignLeft')
.should('be.visible');
cy.get('input#mergecells')
.should('not.have.attr', 'disabled');
// Click merge cells
cy.get('input#mergecells')
.should('not.have.prop', 'checked', true);
helper.clickOnIdle('input#mergecells');
cy.get('input#mergecells')
.should('have.prop', 'checked', true);
// Check content
calcHelper.selectEntireSheet(false);
cy.get('#copy-paste-container table td')
.should('have.attr', 'colspan', '1024');
});
});