marcs

marcs

Programming Phoenix LiveView B11.0: Tests fail after adding login (Page 70)

Hi,
i followed the examples and generated the Catalog live ressource as described on page 67, added the /product routes in the corresponding /-Scope with the :require_authenticated_user plug. Now mix test fails as expected on page 69. Now, when i add the :register_and_log_in_user plug to the Index and Show test blocks, the tests should not fail anymore.
In my case, i get another 6 failures on running mix test:

  1) test Show displays product (PentoWeb.ProductLiveTest)
     test/pento_web/live/product_live_test.exs:88
     ** (UndefinedFunctionError) function PentoWeb.PentoWeb.ProductLive.Show.__live__/0 is undefined (module PentoWeb.PentoWeb.ProductLive.Show is not available)
     code: {:ok, _show_live, html} = live(conn, ~p"/products/#{product}")
     stacktrace:
       PentoWeb.PentoWeb.ProductLive.Show.__live__()
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:299: Phoenix.LiveView.Static.load_live!/2
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:128: Phoenix.LiveView.Static.do_render/4
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
       (phoenix 1.7.18) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
       (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
       (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
       (phoenix 1.7.18) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
       test/pento_web/live/product_live_test.exs:89: (test)



  2) test Index lists all products (PentoWeb.ProductLiveTest)
     test/pento_web/live/product_live_test.exs:24
     ** (UndefinedFunctionError) function PentoWeb.PentoWeb.ProductLive.Index.__live__/0 is undefined (module PentoWeb.PentoWeb.ProductLive.Index is not available)
     code: {:ok, _index_live, html} = live(conn, ~p"/products")
     stacktrace:
       PentoWeb.PentoWeb.ProductLive.Index.__live__()
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:299: Phoenix.LiveView.Static.load_live!/2
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:128: Phoenix.LiveView.Static.do_render/4
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
       (phoenix 1.7.18) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
       (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
       (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
       (phoenix 1.7.18) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
       test/pento_web/live/product_live_test.exs:25: (test)



  3) test Show updates product within modal (PentoWeb.ProductLiveTest)
     test/pento_web/live/product_live_test.exs:95
     ** (UndefinedFunctionError) function PentoWeb.PentoWeb.ProductLive.Show.__live__/0 is undefined (module PentoWeb.PentoWeb.ProductLive.Show is not available)
     code: {:ok, show_live, _html} = live(conn, ~p"/products/#{product}")
     stacktrace:
       PentoWeb.PentoWeb.ProductLive.Show.__live__()
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:299: Phoenix.LiveView.Static.load_live!/2
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:128: Phoenix.LiveView.Static.do_render/4
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
       (phoenix 1.7.18) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
       (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
       (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
       (phoenix 1.7.18) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
       test/pento_web/live/product_live_test.exs:96: (test)



  4) test Index saves new product (PentoWeb.ProductLiveTest)
     test/pento_web/live/product_live_test.exs:31
     ** (UndefinedFunctionError) function PentoWeb.PentoWeb.ProductLive.Index.__live__/0 is undefined (module PentoWeb.PentoWeb.ProductLive.Index is not available)
     code: {:ok, index_live, _html} = live(conn, ~p"/products")
     stacktrace:
       PentoWeb.PentoWeb.ProductLive.Index.__live__()
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:299: Phoenix.LiveView.Static.load_live!/2
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:128: Phoenix.LiveView.Static.do_render/4
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
       (phoenix 1.7.18) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
       (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
       (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
       (phoenix 1.7.18) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
       test/pento_web/live/product_live_test.exs:32: (test)



  5) test Index deletes product in listing (PentoWeb.ProductLiveTest)
     test/pento_web/live/product_live_test.exs:77
     ** (UndefinedFunctionError) function PentoWeb.PentoWeb.ProductLive.Index.__live__/0 is undefined (module PentoWeb.PentoWeb.ProductLive.Index is not available)
     code: {:ok, index_live, _html} = live(conn, ~p"/products")
     stacktrace:
       PentoWeb.PentoWeb.ProductLive.Index.__live__()
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:299: Phoenix.LiveView.Static.load_live!/2
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:128: Phoenix.LiveView.Static.do_render/4
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
       (phoenix 1.7.18) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
       (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
       (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
       (phoenix 1.7.18) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
       test/pento_web/live/product_live_test.exs:78: (test)



  6) test Index updates product in listing (PentoWeb.ProductLiveTest)
     test/pento_web/live/product_live_test.exs:54
     ** (UndefinedFunctionError) function PentoWeb.PentoWeb.ProductLive.Index.__live__/0 is undefined (module PentoWeb.PentoWeb.ProductLive.Index is not available)
     code: {:ok, index_live, _html} = live(conn, ~p"/products")
     stacktrace:
       PentoWeb.PentoWeb.ProductLive.Index.__live__()
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:299: Phoenix.LiveView.Static.load_live!/2
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/static.ex:128: Phoenix.LiveView.Static.do_render/4
       (phoenix_live_view 1.0.1) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
       (phoenix 1.7.18) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
       (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
       (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
       (phoenix 1.7.18) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
       test/pento_web/live/product_live_test.exs:55: (test)

...........................................................
Finished in 0.5 seconds (0.3s async, 0.2s sync)
142 tests, 6 failures

My guess is the PentoWeb.PentoWeb.ProductLive.Index part has one “PentoWeb” too much. But i cannot see where this should be defined.

Any ideas how to trace this down and fix it?

Marked As Solved

marcs

marcs

I already found the issue. There was an unnecessary Alias added to my routers.ex
Don‘t know if it was the generator or more likely the language server in conjunction with neovim. But now, after removing it, everything works as expected

Where Next?

Popular Pragmatic Bookshelf topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
New
telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
mikecargal
Title: Hands-on Rust: question about get_component (page 295) (feel free to respond. “You dug you’re own hole… good luck”) I have somet...
New
Charles
In general, the book isn’t yet updated for Phoenix version 1.6. On page 18 of the book, the authors indicate that an auto generated of ro...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New
s2k
Hi all, currently I wonder how the Tailwind colours work (or don’t work). For example, in app/views/layouts/application.html.erb I have...
New
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
New
New
ggerico
I got this error when executing the plot files on macOS Ventura 13.0.1 with Python 3.10.8 and matplotlib 3.6.1: programming_ML/code/03_...
New

Other popular topics Top

PragmaticBookshelf
Brace yourself for a fun challenge: build a photorealistic 3D renderer from scratch! In just a couple of weeks, build a ray tracer that r...
New
PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
PragmaticBookshelf
Programming Ruby is the most complete book on Ruby, covering both the language itself and the standard library as well as commonly used t...
New
hilfordjames
There appears to have been an update that has changed the terminology for what has previously been known as the Taskbar Overflow - this h...
New
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New
RobertRichards
Hair Salon Games for Girls Fun Girls Hair Saloon game is mainly developed for kids. This game allows users to select virtual avatars to ...
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New

Sub Categories: