Skip to content

Commit

Permalink
Fix draft page creation bug (#333)
Browse files Browse the repository at this point in the history
* Fix draft page creation bug

* update test

* fix test
  • Loading branch information
APB9785 authored Jan 15, 2025
1 parent 1f5c0b8 commit d6885ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ defmodule Beacon.LiveAdmin.PageEditorLive.FormComponent do
|> assign(page: page, show_modal: nil)
|> update(:page_status, &if(user_action == "publish", do: :published, else: &1))
|> put_flash(:info, "Page #{String.trim_trailing(user_action, "e")}ed successfully")
|> push_patch(to: beacon_live_admin_path(socket, site, "/pages/#{page.id}"))}
|> push_navigate(to: beacon_live_admin_path(socket, site, "/pages/#{page.id}"))}
else
{:error, changeset} ->
changeset = Map.put(changeset, :action, :save)
Expand Down
8 changes: 4 additions & 4 deletions test/beacon/live_admin/live/page_editor_live/new_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ defmodule Beacon.LiveAdmin.PageEditorLive.NewTest do
|> form("#page-form", page: %{path: "/my/page", title: "My Page", format: "heex"})
|> render_submit(%{page: %{"template" => "<div>test</div>"}, save: "save"})

assert_patch(live)
assert has_element?(live, "#flash", "Page saved successfully")
assert has_element?(live, "h1", "Edit Page")
assert has_element?(live, "button", "Save Changes")
{path, flash} = assert_redirect(live)

assert path =~ ~r"^/admin/site_a/pages/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
assert flash["info"] == "Page saved successfully"
end

describe "extra page fields" do
Expand Down

0 comments on commit d6885ed

Please sign in to comment.