diff --git a/.github/workflows/js_test.yml b/.github/workflows/js_test.yml new file mode 100644 index 000000000..82a843ac4 --- /dev/null +++ b/.github/workflows/js_test.yml @@ -0,0 +1,56 @@ +name: Cypress E2E tests for Sphinx Needs +on: [pull_request] +jobs: + js_tests: + runs-on: ubuntu-latest + env: + ON_CI: true + FAST_BUILD: true + steps: + - name: Set Up Python 3.10.8 + uses: actions/setup-python@v3 + with: + python-version: 3.10.8 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + - uses: actions/checkout@v3.1.0 + - name: Update pip + run: | + pip install -U wheel + pip install -U setuptools + python -m pip install -U pip + - name: Get pip cache dir + id: pip-cache + run: | + echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT + - name: Pip cache + uses: actions/cache@v2 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install Python dependencies + run: | + pip install -r docs/requirements.txt + - name: Install Sphinx-Needs from master + run: | + pip install -e . + - name: Install Node dependencies + run: npm install cypress + - name: Build Docs + id: sphinx-build-docs + run: sphinx-build -a -T -E -j 4 -b html -d /tmp/sphinx_build/doctrees ./docs /tmp/sphinx_build/html + - name: E2E Cypress Test on Chrome + uses: cypress-io/github-action@v4 + with: + browser: chrome + config-file: tests/js_test/cypress.config.js + start: npm start + # quote the url to be safe against YML parsing surprises + wait-on: 'http://localhost:8080' + + + diff --git a/.gitignore b/.gitignore index bf44d4597..1e3c050a1 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,3 @@ mem_out.* pyinstrument* *.prof - -package-lock.json -package.json diff --git a/docs/changelog.rst b/docs/changelog.rst index c72149b5a..3c6536575 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -110,7 +110,7 @@ Released: 22.09.2022 * Improvement: Renamed jinja function `need` to `flow` for :ref:`needuml`. * Improvement: Added directive :ref:`needarch`. * Improvement: Added configuration option :ref:`needs_ide_snippets_id` to support custom need ID for :ref:`ide` snippets. -* Improvement: Provides jinja function :ref:`needarch_jinja_import` for :ref:`needarch` to execute :ref:`jinja_uml` +* Improvement: Provides jinja function :ref:`needarch_jinja_import` for :ref:`needarch` to execute :ref:`needuml_jinja_uml` automatically for all the links defined in the need :ref:`need_links` options. * Improvement: Added configuration :ref:`needs_ide_directive_snippets` to support custom directive snippets for IDE features. (`#640 `_) diff --git a/docs/directives/needuml.rst b/docs/directives/needuml.rst index 2ad2a9ba4..5d3c45b68 100644 --- a/docs/directives/needuml.rst +++ b/docs/directives/needuml.rst @@ -345,10 +345,10 @@ Finds a list of Sphinx-Need objects that pass the given filter string. {% endfor %} -.. _needuml_jinja_ref +.. _needuml_jinja_ref: ref(id, option, text) -~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~ Allows to create an hyperlink to a Sphinx-Need object in a PlantUML schema. The text associated to the hyperlink is either defined by `option` (in this case, @@ -368,8 +368,8 @@ Sphinx-Need picks the text of the field specified by `option`), or by the free t .. needuml:: - Alice -> Bob: {{ref("FEATURE_1", option="title")}} - Bob -> Alice: {{ref("FEATURE_2", text="A completely free text")}} + Alice -> Bob: {{ref("FEATURE_1", option="title")}} + Bob -> Alice: {{ref("FEATURE_2", text="A completely free text")}} .. _needuml_jinja_uml: diff --git a/noxfile.py b/noxfile.py index d1554f449..f69c57bd7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -59,7 +59,7 @@ def tests(session, sphinx, docutils): def linkcheck(session): session.install(".") # LinkCheck can handle rate limits since Sphinx 3.4, which is needed as - # our doc has to many links to GitHub. + # our doc has too many links to GitHub. session.run("pip", "install", "sphinx==3.5.4", silent=True) session.run("pip", "install", "-r", "docs/requirements.txt", silent=True) diff --git a/package.json b/package.json new file mode 100644 index 000000000..7bbcca436 --- /dev/null +++ b/package.json @@ -0,0 +1,7 @@ +{ + "name": "test-sphinx-needs", + "description": "E2E tests for Sphinx Needs", + "scripts": { + "start": "python3 -m http.server --directory='/tmp/sphinx_build/html' 8080" + } +} \ No newline at end of file diff --git a/tests/js_test/cypress.config.js b/tests/js_test/cypress.config.js index fd7b8efe3..394f07605 100644 --- a/tests/js_test/cypress.config.js +++ b/tests/js_test/cypress.config.js @@ -3,6 +3,9 @@ module.exports = { setupNodeEvents(on, config) { // implement node event listeners here }, - baseUrl: 'http://localhost:8000' + baseUrl: 'http://localhost:8080', + specPattern: 'tests/js_test/cypress/e2e/test-*.js', + fixturesFolder: false, + supportFile: 'tests/js_test/cypress/support/e2e.js', }, }; diff --git a/tests/js_test/cypress/e2e/test_collapse_button.cy.js b/tests/js_test/cypress/e2e/test-collapse-button.cy.js similarity index 100% rename from tests/js_test/cypress/e2e/test_collapse_button.cy.js rename to tests/js_test/cypress/e2e/test-collapse-button.cy.js