-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Prevent special goal renames #6468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -332,6 +332,38 @@ defmodule PlausibleWeb.Live.GoalSettings.FormTest do | |
| assert updated.id == g.id | ||
| end | ||
|
|
||
| test "renders error when trying to rename event_name of an automated goal", %{ | ||
| conn: conn, | ||
| site: site | ||
| } do | ||
| {:ok, goal} = Plausible.Goals.create(site, %{"event_name" => "File Download"}) | ||
| lv = get_liveview(conn, site) | ||
|
|
||
| lv |> element(~s/button#edit-goal-#{goal.id}/) |> render_click() | ||
|
|
||
| lv | ||
| |> element("#goals-form-modalseq0 form") | ||
| |> render_submit(%{goal: %{event_name: "My File Download"}}) | ||
|
|
||
| assert render(lv) =~ "cannot be changed for an automated goal" | ||
| end | ||
|
|
||
| test "renders error when trying to rename display_name of an automated goal", %{ | ||
| conn: conn, | ||
| site: site | ||
| } do | ||
| {:ok, goal} = Plausible.Goals.create(site, %{"event_name" => "File Download"}) | ||
| lv = get_liveview(conn, site) | ||
|
|
||
| lv |> element(~s/button#edit-goal-#{goal.id}/) |> render_click() | ||
|
|
||
| lv | ||
| |> element("#goals-form-modalseq0 form") | ||
| |> render_submit(%{goal: %{event_name: "File Download", display_name: "My Downloads"}}) | ||
|
|
||
| assert render(lv) =~ "cannot be changed for an automated goal" | ||
| end | ||
|
|
||
| test "renders error when goal is invalid", %{conn: conn, site: site} do | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. meganitpick, non-blocking: I see now that there's several ways for the goal to be invalid, this test could be renamed to something like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO at the form level, it does not matter, we only care if the changeset error shows up, whatever that might be. The test is fine. Lower level tests can go into details. |
||
| {:ok, [g, g2, _]} = setup_goals(site) | ||
| lv = get_liveview(conn, site) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question, non-blocking: I know it's allowed right now, but now that we're looking into special goals, should we keep allowing this? Special goals with some user-defined properties seem likely to bite us in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bite us how?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say we want to make File Download dashboard component more special. Instead of relying on the system-defined setup for the goal that's the same for everyone, we need to take into account variants where the otherwise system-defined goal has arbitrary custom props defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or ignore any unrecognizable configuration. Nothing prevents you from sending ANY goal data. There is no way to tell whether this is legitimate event from the tracker, matching an auto-created goal or just random payload that happens to be named "File Download" with any custom props attached. We are relying on display names to recognize special goals, nothing is guaranteed in such setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, special goals with custom props work fine, granted there's data. If you use the seeded db and attach
logged_in: trueto "Outbound Link: Click", the report will render narrowed down to that. I don't see why should we prevent that based on pure speculation.