cypress_test/Makefile.am                                        |   47 
+++++++++-
 cypress_test/data/multiuser/userlist.odt                        |binary
 cypress_test/integration_tests/common/helper.js                 |    1 
 cypress_test/integration_tests/multiuser/userlist_user1_spec.js |   41 ++++++++
 cypress_test/integration_tests/multiuser/userlist_user2_spec.js |   32 ++++++
 5 files changed, 120 insertions(+), 1 deletion(-)

New commits:
commit 514aca9e0145e2dfda4b1cc35f526bdc00d3aa61
Author:     Tamás Zolnai <tamas.zol...@collabora.com>
AuthorDate: Fri Jul 17 14:03:33 2020 +0200
Commit:     Tamás Zolnai <tamas.zol...@collabora.com>
CommitDate: Thu Jul 23 17:29:03 2020 +0200

    cypress: multi-user test case.
    
    Change-Id: If2ee00c1e43b3cd854b83c762b74b2b8fee6d821
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99073
    Tested-by: Jenkins
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com>

diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am
index a17cfd7ee..39145115b 100644
--- a/cypress_test/Makefile.am
+++ b/cypress_test/Makefile.am
@@ -27,6 +27,11 @@ MOBILE_DATA_FOLDER = $(abs_srcdir)/data/mobile/
 MOBILE_WORKDIR = $(abs_builddir)/workdir/mobile/
 MOBILE_TRACK_FOLDER=$(abs_builddir)/workdir/track/mobile
 
+MULTIUSER_TEST_FOLDER = $(abs_srcdir)/integration_tests/multiuser
+MULTIUSER_DATA_FOLDER = $(abs_srcdir)/data/multiuser/
+MULTIUSER_WORKDIR = $(abs_builddir)/workdir/multiuser/
+MULTIUSER_TRACK_FOLDER=$(abs_builddir)/workdir/track/multiuser
+
 ALLOWED_PORTS = $(shell seq 9900 1 9980)
 KILL_COMMAND=pkill -F $(PID_FILE) || pkill --signal SIGKILL -F $(PID_FILE)
 PARALLEL_BUILD = $(findstring -j,$(MAKEFLAGS))
@@ -53,16 +58,22 @@ MOBILE_TEST_FILES=$(subst 
$(MOBILE_TEST_FOLDER)/,,$(wildcard $(MOBILE_TEST_FOLDE
 
 DEKSTOP_TEST_FILES=$(subst $(DESKTOP_TEST_FOLDER)/,,$(wildcard 
$(DESKTOP_TEST_FOLDER)/*_spec.js) $(wildcard 
$(DESKTOP_TEST_FOLDER)/*/*_spec.js))
 
+MULTIUSER_TEST_FILES= $(subst $(MULTIUSER_TEST_FOLDER)/,,$(wildcard 
$(MULTIUSER_TEST_FOLDER)/*_spec.js) $(wildcard 
$(MULTIUSER_TEST_FOLDER)/*/*_spec.js))
+
+
 MOBILE_TEST_FILES_DONE= \
        $(foreach 
test_file,$(MOBILE_TEST_FILES),$(MOBILE_TRACK_FOLDER)/$(test_file).done)
 
 DESKTOP_TEST_FILES_DONE= \
        $(foreach 
test_file,$(DEKSTOP_TEST_FILES),$(DESKTOP_TRACK_FOLDER)/$(test_file).done)
 
+MULTIUSER_TEST_FILES_DONE= \
+       $(foreach 
test_file,$(MULTIUSER_TEST_FILES),$(MULTIUSER_TRACK_FOLDER)/$(test_file).done)
+
 check-local: do-check
        $(if $(wildcard $(ERROR_LOG)),$(error CypressError: some tests failed!))
 
-do-check: $(DESKTOP_TEST_FILES_DONE) $(MOBILE_TEST_FILES_DONE)
+do-check: $(DESKTOP_TEST_FILES_DONE) $(MOBILE_TEST_FILES_DONE) 
$(MULTIUSER_TEST_FILES_DONE)
        @$(KILL_COMMAND) || true
        $(if $(HEADLESS_BUILD),@pkill Xvfb,)
        $(if $(wildcard $(ERROR_LOG)),@cat $(ERROR_LOG))
@@ -93,6 +104,13 @@ $(DESKTOP_TEST_FILES_DONE): $(PID_FILE)
                @$(foreach done_file,$(DESKTOP_TEST_FILES_DONE),mkdir -p $(dir 
$(done_file)) && touch $(done_file) &&) true\
        )
 
+# Multi-user tests are run only during parallel build.
+$(MULTIUSER_TRACK_FOLDER)/userlist_user%_spec.js.done: $(PID_FILE) 
$(MOBILE_TEST_FILES_DONE)
+       $(if $(PARALLEL_BUILD),\
+               $(call run_multiuser_tests,$(subst 
$(MULTIUSER_TRACK_FOLDER)/,,$(basename $@)),$(basename $@).log)\
+               ,)
+       @mkdir -p $(dir $@) && touch $@
+
 check-desktop: @JAILS_PATH@ $(NODE_BINS)
        $(call run_JS_error_check)
        $(call start_loolwsd)
@@ -189,6 +207,10 @@ MOBILE_CONFIG = \
        --config 
integrationFolder=$(MOBILE_TEST_FOLDER),supportFile=$(SUPPORT_FILE),userAgent=$(MOBILE_USER_AGENT)
 \
        --env 
DATA_FOLDER=$(MOBILE_DATA_FOLDER),WORKDIR=$(MOBILE_WORKDIR),WSD_VERSION_HASH=$(WSD_VERSION_HASH),SERVER_PORT=$(FREE_PORT),LO_CORE_VERSION="$(CORE_VERSION)"
 
+MULTIUSER_CONFIG = \
+       --config 
integrationFolder=$(MULTIUSER_TEST_FOLDER),supportFile=$(SUPPORT_FILE),userAgent=$(DESKTOP_USER_AGENT),defaultCommandTimeout=30000
 \
+       --env 
DATA_FOLDER=$(MULTIUSER_DATA_FOLDER),WORKDIR=$(MULTIUSER_WORKDIR),WSD_VERSION_HASH=$(WSD_VERSION_HASH),SERVER_PORT=$(FREE_PORT),LO_CORE_VERSION="$(CORE_VERSION)"
+
 define run_interactive_test
        $(if $(2),\
                $(CYPRESS_BINARY) run \
@@ -237,6 +259,19 @@ define run_mobile_tests
        )
 endef
 
+define run_multiuser_tests
+       @echo "Running cypress multi-user test: $(1)"
+       @echo
+       $(eval RUN_COMMAND = \
+               $(CYPRESS_BINARY) run \
+                       --browser $(CHROME) \
+                       --headless \
+                       $(MULTIUSER_CONFIG)$(if $(3),$(COMMA)$(3)) \
+                       $(if $(1), 
--spec=$(abs_dir)/integration_tests/multiuser/$(1)) \
+                       )
+       $(call 
execute_run_parallel_no_second_chance,$(RUN_COMMAND),$(2),desktop,$(1))
+endef
+
 ERROR_MATCHER = "Error:\|Command failed:\|Timed out retrying\|The error was:"
 
 define execute_run_parallel
@@ -257,6 +292,16 @@ define execute_run_parallel
        fi;
 endef
 
+define execute_run_parallel_no_second_chance
+       @mkdir -p $(dir $(2)) && touch $(2) && \
+       echo "`echo $(1) && $(1)`" > $(2) 2>&1 && \
+       if [ -z `grep -o -m 1 $(ERROR_MATCHER) $(2)` ];\
+               then cat $(2);\
+               else cat $(2) >> $(ERROR_LOG) && \
+                    echo -e $(call error_output_string,$(3),$(4)) >> 
$(ERROR_LOG); \
+       fi;
+endef
+
 define error_output_string
 "\n\
 CypressError: a test failed, please do one of the following:\n\n\
diff --git a/cypress_test/data/multiuser/userlist.odt 
b/cypress_test/data/multiuser/userlist.odt
new file mode 100644
index 000000000..f7494e82f
Binary files /dev/null and b/cypress_test/data/multiuser/userlist.odt differ
diff --git a/cypress_test/integration_tests/common/helper.js 
b/cypress_test/integration_tests/common/helper.js
index c31ebd64a..2452e5956 100644
--- a/cypress_test/integration_tests/common/helper.js
+++ b/cypress_test/integration_tests/common/helper.js
@@ -409,3 +409,4 @@ module.exports.getLOVersion = getLOVersion;
 module.exports.imageShouldBeFullWhiteOrNot = imageShouldBeFullWhiteOrNot;
 module.exports.clickOnIdle = clickOnIdle;
 module.exports.inputOnIdle = inputOnIdle;
+module.exports.waitUntilIdle = waitUntilIdle;
diff --git a/cypress_test/integration_tests/multiuser/userlist_user1_spec.js 
b/cypress_test/integration_tests/multiuser/userlist_user1_spec.js
new file mode 100644
index 000000000..c40f4af9b
--- /dev/null
+++ b/cypress_test/integration_tests/multiuser/userlist_user1_spec.js
@@ -0,0 +1,41 @@
+/* global describe it cy beforeEach require afterEach */
+
+var helper = require('../common/helper');
+
+describe('Check user list with user-1.', function() {
+       var testFileName = 'userlist.odt';
+
+       beforeEach(function() {
+               helper.beforeAllDesktop(testFileName);
+       });
+
+       afterEach(function() {
+               helper.afterAll(testFileName);
+       });
+
+       it('Userlist visibility.', function() {
+               // user-2 loads the same document
+
+               cy.get('#tb_actionbar_item_userlist')
+                       .should('be.visible');
+
+               cy.get('#tb_actionbar_item_userlist .w2ui-tb-caption')
+                       .should('have.text', '2 users');
+
+               // Leave a comment for user-2, that we finished
+               cy.get('#menu-insert')
+                       .click();
+
+               cy.get('#menu-insertcomment')
+                       .click();
+
+               cy.get('.loleaflet-annotation-edit:nth-of-type(2) 
.loleaflet-annotation-textarea')
+                       .type('Done');
+
+               helper.waitUntilIdle('#annotation-save');
+
+               cy.get('#annotation-save')
+                       .click({force: true});
+       });
+
+});
diff --git a/cypress_test/integration_tests/multiuser/userlist_user2_spec.js 
b/cypress_test/integration_tests/multiuser/userlist_user2_spec.js
new file mode 100644
index 000000000..9a8de655e
--- /dev/null
+++ b/cypress_test/integration_tests/multiuser/userlist_user2_spec.js
@@ -0,0 +1,32 @@
+/* global describe it cy beforeEach require afterEach */
+
+var helper = require('../common/helper');
+
+describe('Check user list with user-2.', function() {
+       var testFileName = 'userlist.odt';
+
+       beforeEach(function() {
+               // Wait here, before loading the document.
+               // Opening two clients at the same time causes an issue.
+               cy.wait(5000);
+               helper.beforeAllDesktop(testFileName);
+       });
+
+       afterEach(function() {
+               helper.afterAll(testFileName);
+       });
+
+       it('Userlist visibility.', function() {
+               // user-1 loads the same document
+
+               cy.get('#tb_actionbar_item_userlist')
+                       .should('be.visible');
+
+               cy.get('#tb_actionbar_item_userlist .w2ui-tb-caption')
+                       .should('have.text', '2 users');
+
+               // user-1 adds a comment, so we can close this view
+               cy.get('.loleaflet-annotation-content-wrapper')
+                       .should('exist');
+       });
+});
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to