summaryrefslogtreecommitdiffstats
path: root/cypress_test/integration_tests/desktop/calc
diff options
context:
space:
mode:
authorRash419 <rashesh.padia@collabora.com>2022-05-05 14:44:42 +0530
committerRashesh Padia <rasheshpadia419@gmail.com>2022-05-10 22:31:16 +0530
commit0a203ad91e93824f3168027b9645b6f14a31c422 (patch)
treedb68452edc6ca0cf5adaf7339a39fd5117909778 /cypress_test/integration_tests/desktop/calc
parentformulabr: remove reference marks after use (diff)
downloadonline-0a203ad91e93824f3168027b9645b6f14a31c422.tar.gz
online-0a203ad91e93824f3168027b9645b6f14a31c422.zip
cypress: added desktop calc/autofilter_spec.js
Signed-off-by: Rash419 <rashesh.padia@collabora.com> Change-Id: I48f4ceb591cbdf178b08b44ad1f833b52d5c004d
Diffstat (limited to 'cypress_test/integration_tests/desktop/calc')
-rw-r--r--cypress_test/integration_tests/desktop/calc/autofilter_spec.js145
1 files changed, 145 insertions, 0 deletions
diff --git a/cypress_test/integration_tests/desktop/calc/autofilter_spec.js b/cypress_test/integration_tests/desktop/calc/autofilter_spec.js
new file mode 100644
index 0000000000..5bb8b4081e
--- /dev/null
+++ b/cypress_test/integration_tests/desktop/calc/autofilter_spec.js
@@ -0,0 +1,145 @@
+/* global describe it cy expect beforeEach require afterEach */
+
+var helper = require('../../common/helper');
+var calcHelper = require('../../common/calc_helper');
+
+describe('AutoFilter', function() {
+ var origTestFileName = 'autofilter.ods';
+ var testFileName;
+
+ beforeEach(function() {
+ testFileName = helper.beforeAll(origTestFileName, 'calc');
+
+ toggleAutofilter();
+
+ calcHelper.selectEntireSheet();
+
+ calcHelper.assertDataClipboardTable(['Cypress Test', 'Status', 'Test 1', 'Pass', 'Test 2', 'Fail', 'Test 3', 'Pass', 'Test 4', '', 'Test 5', 'Fail']);
+ });
+
+ afterEach(function() {
+ helper.afterAll(testFileName, this.currentTest.state);
+ });
+
+ function toggleAutofilter() {
+ //enable/disable autofilter
+ helper.clickOnIdle('#menu-data');
+
+ cy.contains('#menu-data li', 'AutoFilter')
+ .click();
+ }
+
+ //If we select entire sheet , there is no data about table in copy-paste-container when autofilter
+ //is enabled
+ function assertDataOnFilter(arr1) {
+ cy.wait(500);
+
+ calcHelper.clickOnFirstCell();
+
+ for (let i=0; i < arr1.length; i+=2) {
+ helper.typeIntoDocument('{shift}{rightarrow}');
+
+ helper.waitUntilIdle('#copy-paste-container tbody');
+
+ var tableData = [];
+
+ cy.get('#copy-paste-container tbody').find('td').each(($el) => {
+ cy.wrap($el)
+ .invoke('text')
+ .then(text => {
+ tableData.push(text);
+ });
+ }).then(() => {
+ expect(tableData).to.deep.eq([arr1[i], arr1[i+1]]);
+ tableData = [];
+ });
+
+ helper.typeIntoDocument('{downarrow}');
+ }
+ calcHelper.clickOnFirstCell();
+ }
+
+ function openAutoFilterMenu(secondColumn) {
+ let x = 95;
+ if (secondColumn) {
+ x += 105;
+ }
+ cy.get('#map')
+ .then(function(items) {
+ expect(items).to.have.lengthOf(1);
+ var XPos = items[0].getBoundingClientRect().left + x;
+ var YPos = items[0].getBoundingClientRect().top + 10;
+ cy.get('body')
+ .click(XPos, YPos);
+ });
+ }
+
+ it('Enable/Disable autofilter', function() {
+ //it gets enable before the test body starts
+ //filter by pass
+ openAutoFilterMenu(true);
+
+ cy.get('.autofilter .vertical').should('be.visible');
+
+ cy.get('.autofilter .ui-treeview-checkbox').eq(0)
+ .uncheck();
+
+ cy.get('.autofilter .ui-treeview-checkbox').eq(1)
+ .uncheck();
+
+ cy.get('.autofilter .ui-button-box-right #ok')
+ .click();
+
+ assertDataOnFilter(['Cypress Test', 'Status', 'Test 1', 'Pass', 'Test 3', 'Pass']);
+
+ //disable autofilter
+ //all the data should be unfiltered
+ toggleAutofilter();
+
+ calcHelper.selectEntireSheet();
+
+ calcHelper.assertDataClipboardTable(['Cypress Test', 'Status', 'Test 1', 'Pass', 'Test 2', 'Fail', 'Test 3', 'Pass', 'Test 4', '', 'Test 5', 'Fail']);
+ });
+
+ it('Sort by ascending/descending', function() {
+ openAutoFilterMenu();
+
+ //sort by descending order
+ cy.contains('.autofilter', 'Sort Descending')
+ .click();
+
+ helper.waitUntilIdle('#copy-paste-container tbody');
+
+ calcHelper.assertDataClipboardTable(['Cypress Test', 'Status', 'Test 5', 'Fail', 'Test 4', '',
+ 'Test 3', 'Pass', 'Test 2', 'Fail', 'Test 1', 'Pass']);
+
+ //sort by ascending order
+ openAutoFilterMenu();
+
+ cy.contains('.autofilter', 'Sort Ascending')
+ .click();
+
+ helper.waitUntilIdle('#copy-paste-container tbody');
+
+ calcHelper.assertDataClipboardTable(['Cypress Test', 'Status', 'Test 1', 'Pass',
+ 'Test 2', 'Fail', 'Test 3', 'Pass', 'Test 4', '', 'Test 5', 'Fail']);
+ });
+
+ it('Filter empty/non-empty cells', function() {
+ //empty
+ openAutoFilterMenu(true);
+
+ cy.contains('.autofilter', 'Empty')
+ .click();
+
+ assertDataOnFilter(['Cypress Test', 'Status', 'Test 4', '']);
+
+ //non-empty
+ openAutoFilterMenu(true);
+
+ cy.contains('.autofilter', 'Not Empty')
+ .click();
+
+ assertDataOnFilter(['Cypress Test', 'Status', 'Test 1', 'Pass', 'Test 2', 'Fail', 'Test 3', 'Pass', 'Test 5', 'Fail']);
+ });
+});