diff --git a/config/e2e.exs b/config/e2e.exs index dff740272..42ecc0ef7 100644 --- a/config/e2e.exs +++ b/config/e2e.exs @@ -20,5 +20,9 @@ config :mobilizon, MobilizonWeb.Endpoint, ] config :mobilizon, sql_sandbox: true -config :mobilizon, Oban, queues: false, prune: :disabled + +config :mobilizon, Oban, + queues: false, + prune: :disabled + config :mobilizon, Mobilizon.Storage.Repo, pool: Ecto.Adapters.SQL.Sandbox diff --git a/js/tests/e2e/specs/dashboard.js b/js/tests/e2e/specs/dashboard.js index 8d738429b..9a8a13b5a 100644 --- a/js/tests/e2e/specs/dashboard.js +++ b/js/tests/e2e/specs/dashboard.js @@ -1,5 +1,5 @@ // https://docs.cypress.io/api/introduction/api.html -import { onBeforeLoad } from './browser-language'; +import { onBeforeLoad } from '../support/browser-language'; describe('Homepage', () => { it('Checks the footer', () => { diff --git a/js/tests/e2e/specs/event.js b/js/tests/e2e/specs/event.js index b87d389a5..737f5a542 100644 --- a/js/tests/e2e/specs/event.js +++ b/js/tests/e2e/specs/event.js @@ -1,4 +1,4 @@ -import { onBeforeLoad } from './browser-language'; +import { onBeforeLoad } from '../support/browser-language'; beforeEach(() => { cy.clearLocalStorage(); @@ -29,6 +29,7 @@ describe('Events', () => { cy.get('.field').eq(3).contains('.datepicker-cell', '15').click(); cy.contains('.button.is-primary', 'Create my event').click(); + cy.drainQueues(); cy.url().should('include', '/events/'); cy.contains('.title', EVENT.title); cy.contains('.title-and-informations span small', 'You\'re the only one going to this event'); @@ -41,4 +42,4 @@ describe('Events', () => { cy.contains('.title-wrapper .date-component .datetime-container .month', 'Sep'); cy.contains('.title-wrapper .date-component .datetime-container .day', '15'); }); -}); \ No newline at end of file +}); diff --git a/js/tests/e2e/specs/login.js b/js/tests/e2e/specs/login.js index 3f5fece19..d32d46e2c 100644 --- a/js/tests/e2e/specs/login.js +++ b/js/tests/e2e/specs/login.js @@ -1,4 +1,4 @@ -import { onBeforeLoad } from './browser-language'; +import { onBeforeLoad } from '../support/browser-language'; beforeEach(() => { cy.clearLocalStorage(); diff --git a/js/tests/e2e/specs/register.js b/js/tests/e2e/specs/register.js index f161663e7..f6780e654 100644 --- a/js/tests/e2e/specs/register.js +++ b/js/tests/e2e/specs/register.js @@ -1,4 +1,4 @@ -import { onBeforeLoad } from './browser-language'; +import { onBeforeLoad } from '../support/browser-language'; beforeEach(() => { cy.checkoutSession(); @@ -35,9 +35,16 @@ describe('Registration', () => { cy.get('input[type=email]').type('user2register@email.com'); cy.get('input[type=password]').type('userPassword'); cy.get('form').contains('button.button.is-primary', 'Register').click(); + console.log('click on register'); + cy.wait(1500); + console.log('waited a little'); + cy.drainQueues(); + console.log('drained queues'); cy.url().should('include', '/register/profile'); + console.log('url is ok'); cy.wait(1000); + console.log('finished waiting'); cy.get('form .field').first().contains('label', 'Username').parent().find('input').type('tester'); cy.get('form .field').eq(2).contains('label', 'Displayed name').parent().find('input').type('tester account'); cy.get('form .field').eq(3).contains('label', 'Description').parent().find('textarea').type('This is a test account'); @@ -68,4 +75,4 @@ describe('Registration', () => { cy.get('.navbar-link span.icon i').should('have.class', 'mdi-account-circle'); cy.contains('article.message.is-info', 'Welcome to Mobilizon, tester account!'); }); -}); \ No newline at end of file +}); diff --git a/js/tests/e2e/specs/browser-language.js b/js/tests/e2e/support/browser-language.js similarity index 100% rename from js/tests/e2e/specs/browser-language.js rename to js/tests/e2e/support/browser-language.js diff --git a/js/tests/e2e/support/commands.js b/js/tests/e2e/support/commands.js index 596aad51c..092fe82c9 100644 --- a/js/tests/e2e/support/commands.js +++ b/js/tests/e2e/support/commands.js @@ -116,7 +116,15 @@ Cypress.Commands.add('dropSession', () => { } ); +Cypress.Commands.add('drainQueues', async () => { + console.log('Drain queues'); + const response = await fetch('/drain_queue', { + cache: 'no-store', + }); + const responseText = await response.text(); + //console.log(responseText); +}); const increaseFetches = () => { const count = Cypress.env('fetchCount') || 0; @@ -179,10 +187,10 @@ const increaseFetches = () => { }) } }) - }) + }); Cypress.Commands.add( 'getInDocument', { prevSubject: 'document' }, (document, selector) => Cypress.$(selector, document) - ) + ); diff --git a/lib/mobilizon/events/event.ex b/lib/mobilizon/events/event.ex index ce0b2b5ad..043dfbfb1 100644 --- a/lib/mobilizon/events/event.ex +++ b/lib/mobilizon/events/event.ex @@ -179,9 +179,9 @@ defmodule Mobilizon.Events.Event do defp put_tags(%Changeset{} = changeset, _), do: changeset - # We need a changeset instead of a raw struct because of slug which is generated in changeset - defp process_tag(%{id: _id} = tag), do: tag + # defp process_tag(%{id: _id} = tag), do: tag + # We need a changeset instead of a raw struct because of slug which is generated in changeset defp process_tag(tag) do Tag.changeset(%Tag{}, tag) end diff --git a/lib/mobilizon_web/router.ex b/lib/mobilizon_web/router.ex index 056b0be7f..6b36b5142 100644 --- a/lib/mobilizon_web/router.ex +++ b/lib/mobilizon_web/router.ex @@ -123,6 +123,7 @@ defmodule MobilizonWeb.Router do if Mix.env() in [:dev, :e2e] do # If using Phoenix forward("/sent_emails", Bamboo.SentEmailViewerPlug) + get("/drain_queue", MobilizonWeb.E2EController, :drain_queue) end scope "/", MobilizonWeb do diff --git a/mix.exs b/mix.exs index f53064471..4a676faae 100644 --- a/mix.exs +++ b/mix.exs @@ -44,6 +44,7 @@ defmodule Mobilizon.Mixfile do # Specifies which paths to compile per environment. defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(:dev), do: ["lib", "test/support/factory.ex"] + defp elixirc_paths(:e2e), do: ["lib", "test/support/E2EController.ex"] defp elixirc_paths(_), do: ["lib"] # Specifies your project dependencies. diff --git a/mix.lock b/mix.lock index 529217aa3..09c1ed2d8 100644 --- a/mix.lock +++ b/mix.lock @@ -88,7 +88,7 @@ "oban": {:hex, :oban, "0.10.1", "c2ca0a413fb66b21dd58c7cb67fd80b01e9d79a0fbb28573f110057e7fdc3807", [:mix], [{:ecto_sql, "~> 3.1", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, "phoenix": {:hex, :phoenix, "1.4.10", "619e4a545505f562cd294df52294372d012823f4fd9d34a6657a8b242898c255", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.8.1 or ~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_ecto": {:hex, :phoenix_ecto, "4.0.0", "c43117a136e7399ea04ecaac73f8f23ee0ffe3e07acfcb8062fe5f4c9f0f6531", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, + "phoenix_ecto": {:hex, :phoenix_ecto, "4.1.0", "a044d0756d0464c5a541b4a0bf4bcaf89bffcaf92468862408290682c73ae50d", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_html": {:hex, :phoenix_html, "2.13.3", "850e292ff6e204257f5f9c4c54a8cb1f6fbc16ed53d360c2b780a3d0ba333867", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.2.1", "274a4b07c4adbdd7785d45a8b0bb57634d0b4f45b18d2c508b26c0344bd59b8f", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.2", "496c303bdf1b2e98a9d26e89af5bba3ab487ba3a3735f74bf1f4064d2a845a3e", [:mix], [], "hexpm"}, diff --git a/test/support/E2EController.ex b/test/support/E2EController.ex new file mode 100644 index 000000000..fef299306 --- /dev/null +++ b/test/support/E2EController.ex @@ -0,0 +1,9 @@ +defmodule MobilizonWeb.E2EController do + use MobilizonWeb, :controller + + def drain_queue(conn, _) do + Oban.drain_queue(:default) + Oban.drain_queue(:search) + send_resp(conn, 200, "") + end +end