From 89a661b448301e296aef8fb6debde67c29817bee Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 13 Mar 2021 16:46:14 +0000 Subject: [PATCH] tests: test to see if I can have multiple cypress clients collaborating at once --- .github/workflows/collaboration.yml | 46 +++++++++++++++++++ .../cypress/integration/collaborate.js | 23 ++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/collaboration.yml create mode 100644 src/tests/frontend/cypress/integration/collaborate.js diff --git a/.github/workflows/collaboration.yml b/.github/workflows/collaboration.yml new file mode 100644 index 000000000..75c3744fd --- /dev/null +++ b/.github/workflows/collaboration.yml @@ -0,0 +1,46 @@ +name: "Multiple clients collaborating on a single pad" + +# any branch is useful for testing before a PR is submitted +on: [push, pull_request] + +jobs: + build: + # run on pushes to any branch + # run on PRs from external forks + if: | + (github.event_name != 'pull_request') + || (github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id) + name: Test + runs-on: windows-latest + + steps: + - uses: msys2/setup-msys2@v2 + with: + path-type: inherit + install: >- + zip + + - name: Checkout repository + uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: 12 + + - name: Install all dependencies and symlink for ep_etherpad-lite + shell: msys2 {0} + run: src/bin/installDeps.sh + + - name: Install Cypress + run: npm install cypress -g + + - name: Run Etherpad + run: | + cd etherpad + node node_modules\ep_etherpad-lite\node\server.js & + curl --connect-timeout 10 --max-time 20 --retry 5 --retry-delay 10 --retry-max-time 60 --retry-connrefused http://127.0.0.1:9001/p/test + cd src\tests\frontend + cypress run --spec cypress\integration\collaborate.js --config-file cypress\cypress.json > client1.txt & + cypress run --spec cypress\integration\collaborate.js --config-file cypress\cypress.json > client2.txt & + cypress run --spec cypress\integration\collaborate.js --config-file cypress\cypress.json > client3.txt & + cypress run --spec cypress\integration\collaborate.js --config-file cypress\cypress.json > client4.txt & diff --git a/src/tests/frontend/cypress/integration/collaborate.js b/src/tests/frontend/cypress/integration/collaborate.js new file mode 100644 index 000000000..bd6eda105 --- /dev/null +++ b/src/tests/frontend/cypress/integration/collaborate.js @@ -0,0 +1,23 @@ +'use strict'; + +Cypress.Commands.add('iframe', {prevSubject: 'element'}, + ($iframe) => new Cypress.Promise((resolve) => { + $iframe.ready(() => { + resolve($iframe.contents().find('body')); + }); + })); + +describe(__filename, () => { + it('Pad content exists', () => { + cy.visit('http://127.0.0.1:9001/p/collab'); + cy.wait(10000); // wait for Minified JS to be built... + cy.get('iframe[name="ace_outer"]', {timeout: 10000}).iframe() + .find('.line-number:first') + .should('have.text', '1'); + cy.get('iframe[name="ace_outer"]').iframe() + .find('iframe[name="ace_inner"]').iframe() + .find('.ace-line:first') + .should('be.visible') + .should('have.text', 'Welcome to Etherpad!'); + }); +});