cypress: change template files tests to assert readOnly

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ib557424de7407346ca947bfe06289b772ec46d10
This commit is contained in:
Rash419 2022-03-15 14:54:18 +05:30 committed by Andras Timar
parent a6456a1294
commit 23f0790413
3 changed files with 30 additions and 34 deletions

View file

@ -1,6 +1,6 @@
/* global cy require Cypress expect */
const { clickOnIdle, typeIntoDocument, waitUntilIdle } = require('./helper');
var helper = require('./helper');
// Make the sidebar visible by clicking on the corresponding toolbar item.
// We assume that the sidebar is hidden, when this method is called.
@ -213,7 +213,7 @@ function zoomOut() {
function selectZoomLevel(zoomLevel) {
makeZoomItemsVisible();
clickOnIdle('#tb_actionbar_item_zoom');
helper.clickOnIdle('#tb_actionbar_item_zoom');
cy.contains('.w2ui-drop-menu .menu-text', zoomLevel)
.click();
@ -256,9 +256,9 @@ function insertImage(docType) {
}
function deleteImage() {
typeIntoDocument('{del}');
helper.typeIntoDocument('{del}');
waitUntilIdle('.leaflet-pane.leaflet-overlay-pane');
helper.waitUntilIdle('.leaflet-pane.leaflet-overlay-pane');
cy.get('.leaflet-pane.leaflet-overlay-pane svg g')
.should('not.exist');
@ -358,11 +358,26 @@ function assertScrollbarPosition(type, lowerBound, upperBound) {
function pressKey(n, key) {
for (let i=0; i<n; i++) {
typeIntoDocument('{' + key + '}');
helper.typeIntoDocument('{' + key + '}');
cy.wait(500);
}
}
function openReadOnlyFile(type, filename) {
var testFileName = helper.loadTestDocNoIntegration(filename, type, false, false, false);
//check doc is loaded
cy.get('.leaflet-canvas-container canvas', {timeout : Cypress.config('defaultCommandTimeout') * 2.0});
helper.canvasShouldNotBeFullWhite('.leaflet-canvas-container canvas');
cy.get('#PermissionMode').should('be.visible')
.should('have.text', ' Read-only ');
return testFileName;
}
module.exports.showSidebar = showSidebar;
module.exports.hideSidebar = hideSidebar;
module.exports.showStatusBarIfHidden = showStatusBarIfHidden;
@ -383,3 +398,4 @@ module.exports.actionOnSelector = actionOnSelector;
module.exports.assertScrollbarPosition = assertScrollbarPosition;
module.exports.pressKey = pressKey;
module.exports.assertImageSize = assertImageSize;
module.exports.openReadOnlyFile = openReadOnlyFile;

View file

@ -1,6 +1,6 @@
/* global describe it cy require expect afterEach */
var helper = require('../../common/helper');
const { selectZoomLevel } = require('../../common/desktop_helper');
const { selectZoomLevel, openReadOnlyFile } = require('../../common/desktop_helper');
// const { selectTextShapeInTheCenter } = require('../../common/impress_helper');
describe('Open different file types', function() {
@ -80,21 +80,15 @@ describe('Open different file types', function() {
});
it('Open pot file', function() {
before('testfile.pot');
assertData();
testFileName = openReadOnlyFile('impress', 'testfile.pot');
});
it('Open potx file', function() {
before('testfile.potx');
assertData();
testFileName = openReadOnlyFile('impress', 'testfile.potx');
});
it('Open potm file', function() {
before('testfile.potm');
assertData();
testFileName = openReadOnlyFile('impress', 'testfile.potm');
});
it('Open fodp file', function() {

View file

@ -1,5 +1,5 @@
/* global describe it cy require Cypress afterEach */
const { assertImageSize } = require('../../common/desktop_helper');
/* global describe it cy require afterEach */
const { assertImageSize, openReadOnlyFile } = require('../../common/desktop_helper');
var helper = require('../../common/helper');
describe('Open different file types', function() {
@ -16,18 +16,6 @@ describe('Open different file types', function() {
helper.afterAll(testFileName, this.currentTest.state);
});
function openReadOnlyFile(filename) {
testFileName = helper.loadTestDocNoIntegration(filename, 'writer', false, false, false);
//check doc is loaded
cy.get('.leaflet-canvas-container canvas', {timeout : Cypress.config('defaultCommandTimeout') * 2.0});
helper.canvasShouldNotBeFullWhite('.leaflet-canvas-container canvas');
cy.get('#PermissionMode').should('be.visible')
.should('have.text', ' Read-only ');
}
function assertData() {
//select all the content of doc
helper.typeIntoDocument('{shift}{end}');
@ -102,16 +90,14 @@ describe('Open different file types', function() {
});
it('Open dot file', function() {
before('testfile.dot');
assertData();
testFileName = openReadOnlyFile('writer', 'testfile.dot');
});
it('Open dotm file', function() {
openReadOnlyFile('testfile.dotm');
testFileName = openReadOnlyFile('writer', 'testfile.dotm');
});
it('Open dotx file', function() {
openReadOnlyFile('testfile.dotx');
testFileName = openReadOnlyFile('writer','testfile.dotx');
});
});