diff --git a/.gitignore b/.gitignore index d11830e816..04e1da56b8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ figwheel_server.log .nrepl-port .cpcache .rebel_readline_history +.nyc_output /vendor/**/target /cd.md node_modules @@ -32,6 +33,7 @@ node_modules /docker/images/bundle* /common/.shadow-cljs /common/target +/common/coverage /.clj-kondo/.cache /bundle* /media @@ -43,3 +45,4 @@ node_modules .calva .clj-kondo .lsp +/frontend/cypress/videos/*/ diff --git a/backend/test/app/test_helpers.clj b/backend/test/app/test_helpers.clj index f503e5d663..9161296d18 100644 --- a/backend/test/app/test_helpers.clj +++ b/backend/test/app/test_helpers.clj @@ -57,6 +57,7 @@ :app.http/server :app.http/router :app.notifications/handler + :app.loggers.sentry/reporter :app.http.oauth/google :app.http.oauth/gitlab :app.http.oauth/github diff --git a/common/package.json b/common/package.json index 4344351821..494c86655a 100644 --- a/common/package.json +++ b/common/package.json @@ -6,6 +6,12 @@ "dependencies": { "luxon": "^1.27.0" }, + "scripts": { + "compile-and-watch-test": "clojure -M:dev:shadow-cljs watch test", + "compile-test": "clojure -M:dev:shadow-cljs compile test --config-merge '{:autorun false}'", + "run-test": "node target/test.js", + "test": "yarn run compile-test && yarn run run-test" + }, "devDependencies": { "source-map-support": "^0.5.19", "ws": "^7.4.6" diff --git a/common/shadow-cljs.edn b/common/shadow-cljs.edn index e6bcd7175c..d7e55017c8 100644 --- a/common/shadow-cljs.edn +++ b/common/shadow-cljs.edn @@ -6,12 +6,17 @@ :builds {:test {:target :node-test - :output-to "target/tests.js" + :output-to "target/test.js" + :output-dir "target/test/" :ns-regexp "^app.common.*-test$" - ;; :autorun true + :autorun true :compiler-options {:output-feature-set :es-next :output-wrapper false + :source-map true + :source-map-include-sources-content true + :source-map-detail-level :all :warnings {:fn-deprecated false}}}}} + diff --git a/common/test/app/common/data_test.clj b/common/test/app/common/data_test.cljc similarity index 86% rename from common/test/app/common/data_test.clj rename to common/test/app/common/data_test.cljc index 8a85bb97b1..4cf9c661f2 100644 --- a/common/test/app/common/data_test.clj +++ b/common/test/app/common/data_test.cljc @@ -10,16 +10,11 @@ [clojure.test :as t])) (t/deftest concat-vec - (t/is (= [1 2 3] - (d/concat-vec [1] #{2} [3]))) - - (t/is (= [1 2] - (d/concat-vec '(1) [2]))) - - (t/is (= [1] - (d/concat-vec [1]))) - - (t/is (= [] (d/concat-vec)))) + (t/is (= [] (d/concat-vec))) + (t/is (= [1] (d/concat-vec [1]))) + (t/is (= [1] (d/concat-vec #{1}))) + (t/is (= [1 2] (d/concat-vec [1] #{2}))) + (t/is (= [1 2] (d/concat-vec '(1) [2])))) (t/deftest concat-set (t/is (= #{} (d/concat-set))) diff --git a/docker/devenv/Dockerfile b/docker/devenv/Dockerfile index 602c6aa6ba..f8f1283631 100644 --- a/docker/devenv/Dockerfile +++ b/docker/devenv/Dockerfile @@ -3,10 +3,10 @@ LABEL maintainer="Andrey Antukh " ARG DEBIAN_FRONTEND=noninteractive -ENV NODE_VERSION=v14.17.6 \ +ENV NODE_VERSION=v16.13.0 \ CLOJURE_VERSION=1.10.3.967 \ CLJKONDO_VERSION=2021.10.19 \ - BABASHKA_VERSION=0.6.1 \ + BABASHKA_VERSION=0.6.6 \ LANG=en_US.UTF-8 \ LC_ALL=en_US.UTF-8 @@ -97,6 +97,7 @@ RUN set -ex; \ libappindicator1 \ libnss3 \ libgbm1 \ + xvfb \ ; \ rm -rf /var/lib/apt/lists/*; @@ -108,16 +109,14 @@ RUN set -x; \ rm -rf /var/lib/apt/lists/*; \ rm -rf /tmp/chrome.deb; - RUN set -ex; \ - curl -LfsSo /tmp/openjdk.tar.gz https://github.com/AdoptOpenJDK/openjdk16-binaries/releases/download/jdk-16.0.1%2B9/OpenJDK16U-jdk_x64_linux_hotspot_16.0.1_9.tar.gz; \ - mkdir -p /usr/lib/jvm/openjdk16; \ - cd /usr/lib/jvm/openjdk16; \ + curl -LfsSo /tmp/openjdk.tar.gz https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.1%2B12/OpenJDK17U-jdk_x64_linux_hotspot_17.0.1_12.tar.gz; \ + mkdir -p /usr/lib/jvm/openjdk17; \ + cd /usr/lib/jvm/openjdk17; \ tar -xf /tmp/openjdk.tar.gz --strip-components=1; \ rm -rf /tmp/openjdk.tar.gz; -ENV PATH="/usr/lib/jvm/openjdk16/bin:/usr/local/nodejs/bin:$PATH" \ - JAVA_HOME=/usr/lib/jvm/openjdk16 +ENV PATH="/usr/lib/jvm/openjdk17/bin:/usr/local/nodejs/bin:$PATH" JAVA_HOME=/usr/lib/jvm/openjdk17 RUN set -ex; \ curl -LfsSo /tmp/clojure.sh https://download.clojure.org/install/linux-install-$CLOJURE_VERSION.sh; \ diff --git a/docker/devenv/files/bashrc b/docker/devenv/files/bashrc index c7c421504f..3ae8341c91 100644 --- a/docker/devenv/files/bashrc +++ b/docker/devenv/files/bashrc @@ -1,6 +1,6 @@ #!/usr/bin/env bash -export PATH=/usr/lib/jvm/openjdk16/bin:/usr/local/nodejs/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin +export PATH=/usr/lib/jvm/openjdk17/bin:/usr/local/nodejs/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin alias l='ls --color -GFlh' alias rm='rm -r' diff --git a/frontend/cypress.json b/frontend/cypress.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/frontend/cypress.json @@ -0,0 +1 @@ +{} diff --git a/frontend/cypress/fixtures/example.json b/frontend/cypress/fixtures/example.json new file mode 100644 index 0000000000..02e4254378 --- /dev/null +++ b/frontend/cypress/fixtures/example.json @@ -0,0 +1,5 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io", + "body": "Fixtures are a great way to mock data for responses to routes" +} diff --git a/frontend/cypress/integration-examples/1-getting-started/todo.spec.js b/frontend/cypress/integration-examples/1-getting-started/todo.spec.js new file mode 100644 index 0000000000..4768ff923e --- /dev/null +++ b/frontend/cypress/integration-examples/1-getting-started/todo.spec.js @@ -0,0 +1,143 @@ +/// + +// Welcome to Cypress! +// +// This spec file contains a variety of sample tests +// for a todo list app that are designed to demonstrate +// the power of writing tests in Cypress. +// +// To learn more about how Cypress works and +// what makes it such an awesome testing tool, +// please read our getting started guide: +// https://on.cypress.io/introduction-to-cypress + +describe('example to-do app', () => { + beforeEach(() => { + // Cypress starts out with a blank slate for each test + // so we must tell it to visit our website with the `cy.visit()` command. + // Since we want to visit the same URL at the start of all our tests, + // we include it in our beforeEach function so that it runs before each test + cy.visit('https://example.cypress.io/todo') + }) + + it('displays two todo items by default', () => { + // We use the `cy.get()` command to get all elements that match the selector. + // Then, we use `should` to assert that there are two matched items, + // which are the two default items. + cy.get('.todo-list li').should('have.length', 2) + + // We can go even further and check that the default todos each contain + // the correct text. We use the `first` and `last` functions + // to get just the first and last matched elements individually, + // and then perform an assertion with `should`. + cy.get('.todo-list li').first().should('have.text', 'Pay electric bill') + cy.get('.todo-list li').last().should('have.text', 'Walk the dog') + }) + + it('can add new todo items', () => { + // We'll store our item text in a variable so we can reuse it + const newItem = 'Feed the cat' + + // Let's get the input element and use the `type` command to + // input our new list item. After typing the content of our item, + // we need to type the enter key as well in order to submit the input. + // This input has a data-test attribute so we'll use that to select the + // element in accordance with best practices: + // https://on.cypress.io/selecting-elements + cy.get('[data-test=new-todo]').type(`${newItem}{enter}`) + + // Now that we've typed our new item, let's check that it actually was added to the list. + // Since it's the newest item, it should exist as the last element in the list. + // In addition, with the two default items, we should have a total of 3 elements in the list. + // Since assertions yield the element that was asserted on, + // we can chain both of these assertions together into a single statement. + cy.get('.todo-list li') + .should('have.length', 3) + .last() + .should('have.text', newItem) + }) + + it('can check off an item as completed', () => { + // In addition to using the `get` command to get an element by selector, + // we can also use the `contains` command to get an element by its contents. + // However, this will yield the