diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 739e569f..adee20ef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -144,26 +144,32 @@ vitest: - js/junit.xml expire_in: 30 days -# cypress: -# stage: test -# services: -# - name: postgis/postgis:13.3 -# alias: postgres -# variables: -# MIX_ENV=e2e -# script: -# - mix ecto.create -# - mix ecto.migrate -# - mix run priv/repo/e2e.seed.exs -# - mix phx.server & -# - cd js -# - npx wait-on http://localhost:4000 -# - if [ -z "$CYPRESS_KEY" ]; then npx cypress run; else npx cypress run --record --parallel --key $CYPRESS_KEY; fi -# artifacts: -# expire_in: 2 day -# paths: -# - js/tests/e2e/screenshots/**/*.png -# - js/tests/e2e/videos/**/*.mp4 +e2e: + stage: test + services: + - name: postgis/postgis:14-3.2 + alias: postgres + variables: + MIX_ENV: "e2e" + before_script: + - mix deps.get + - mix ecto.create + - mix ecto.migrate + - mix run priv/repo/e2e.seed.exs + - cd js && yarn run build && npx playwright install && cd ../ + - mix phx.digest + script: + - mix phx.server & + - cd js + - npx wait-on http://localhost:4000 + - npx playwright test --project $BROWSER + parallel: + matrix: + - BROWSER: ['firefox', 'chromium'] + artifacts: + expire_in: 2 days + paths: + - js/playwright-report pages: stage: deploy diff --git a/config/e2e.exs b/config/e2e.exs index cbb64310..7135ea44 100644 --- a/config/e2e.exs +++ b/config/e2e.exs @@ -19,19 +19,39 @@ config :mobilizon, Mobilizon.Web.Endpoint, yarn: [cd: Path.expand("../js", __DIR__)] ] -require Logger +config :vite_phx, + release_app: :mobilizon, + # Hard code :prod as an environment as :e2e will not be recongnized + environment: :prod, + vite_manifest: "priv/static/manifest.json", + phx_manifest: "priv/static/cache_manifest.json", + dev_server_address: "http://localhost:5173" -cond do - System.get_env("INSTANCE_CONFIG") && - File.exists?("./config/#{System.get_env("INSTANCE_CONFIG")}") -> - import_config System.get_env("INSTANCE_CONFIG") +config :mobilizon, :instance, + name: "E2E Testing instance", + description: "E2E is safety", + hostname: "mobilizon1.com", + registrations_open: true, + registration_email_denylist: ["gmail.com", "deny@tcit.fr"], + demo: false, + default_language: "en", + allow_relay: true, + federating: true, + email_from: "mobilizon@mobilizon1.com", + email_reply_to: nil, + enable_instance_feeds: true, + koena_connect_link: true, + extra_categories: [ + %{ + id: :something_else, + label: "Quelque chose d'autre" + } + ] - System.get_env("DOCKER", "false") == "false" && File.exists?("./config/e2e.secret.exs") -> - import_config "e2e.secret.exs" - - System.get_env("DOCKER", "false") == "true" -> - Logger.info("Using environment configuration for Docker") - - true -> - Logger.error("No configuration file found") -end +config :mobilizon, Mobilizon.Storage.Repo, + adapter: Ecto.Adapters.Postgres, + username: System.get_env("MOBILIZON_DATABASE_USERNAME", "mobilizon_e2e"), + password: System.get_env("MOBILIZON_DATABASE_PASSWORD", "mobilizon_e2e"), + database: System.get_env("MOBILIZON_DATABASE_DBNAME", "mobilizon_e2e"), + hostname: System.get_env("MOBILIZON_DATABASE_HOST", "localhost"), + port: System.get_env("MOBILIZON_DATABASE_PORT") || "5432" diff --git a/js/.gitignore b/js/.gitignore index 5c5176c4..11369d99 100644 --- a/js/.gitignore +++ b/js/.gitignore @@ -2,8 +2,6 @@ node_modules /dist -/tests/e2e/videos/ -/tests/e2e/screenshots/ /coverage stats.html diff --git a/js/README.md b/js/README.md deleted file mode 100644 index e4cb29da..00000000 --- a/js/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# mobilizon - -## Project setup - -``` -yarn install -``` - -### Compiles and hot-reloads for development - -``` -yarn serve -``` - -### Compiles and minifies for production - -``` -yarn build -``` - -### Run your unit tests - -``` -yarn test:unit -``` - -### Run your end-to-end tests - -``` -yarn test:e2e -``` - -### Lints and fixes files - -``` -yarn lint -``` - -### Customize configuration - -See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/js/cypress.json b/js/cypress.json deleted file mode 100644 index 17b7cd74..00000000 --- a/js/cypress.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "pluginsFile": "tests/e2e/plugins/index.js", - "projectId": "86dpkx", - "baseUrl": "http://localhost:4000", - "viewportWidth": 1920, - "viewportHeight": 1080 -} diff --git a/js/playwright.config.ts b/js/playwright.config.ts index c3da6c26..03e0bf45 100644 --- a/js/playwright.config.ts +++ b/js/playwright.config.ts @@ -13,7 +13,7 @@ import { devices } from "@playwright/test"; const config: PlaywrightTestConfig = { testDir: "./tests/e2e", /* Maximum time one test can run for. */ - timeout: 30 * 1000, + timeout: 10 * 1000, expect: { /** * Maximum time expect() should wait for the condition to be met. @@ -36,7 +36,7 @@ const config: PlaywrightTestConfig = { /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ actionTimeout: 0, /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: "http://localhost:4005", + baseURL: "http://localhost:4000", /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: "on-first-retry", diff --git a/js/src/App.vue b/js/src/App.vue index 175d22d4..b27d71ea 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -57,13 +57,17 @@ import { } from "vue"; import { LocationType } from "@/types/user-location.model"; import { useMutation, useQuery } from "@vue/apollo-composable"; -import { initializeCurrentActor } from "@/utils/identity"; +import { + initializeCurrentActor, + NoIdentitiesException, +} from "@/utils/identity"; import { useI18n } from "vue-i18n"; import { Snackbar } from "@/plugins/snackbar"; import { Notifier } from "@/plugins/notifier"; import { CONFIG } from "@/graphql/config"; import { IConfig } from "@/types/config.model"; import { useRouter } from "vue-router"; +import RouteName from "@/router/name"; const { result: configResult } = useQuery<{ config: IConfig }>(CONFIG); @@ -130,7 +134,19 @@ interval.value = setInterval(async () => { onBeforeMount(async () => { if (initializeCurrentUser()) { - await initializeCurrentActor(); + try { + await initializeCurrentActor(); + } catch (err) { + if (err instanceof NoIdentitiesException) { + await router.push({ + name: RouteName.REGISTER_PROFILE, + params: { + email: localStorage.getItem(AUTH_USER_EMAIL), + userAlreadyActivated: "true", + }, + }); + } + } } }); diff --git a/js/src/components/Event/EventCard.vue b/js/src/components/Event/EventCard.vue index bcf92c9b..8b14a2a8 100644 --- a/js/src/components/Event/EventCard.vue +++ b/js/src/components/Event/EventCard.vue @@ -26,13 +26,13 @@ variant="info" v-if="event.status === EventStatus.TENTATIVE" > - {{ $t("Tentative") }} + {{ t("Tentative") }} - {{ $t("Cancelled") }} + {{ t("Cancelled") }}