-
Notifications
You must be signed in to change notification settings - Fork 0
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
Updating Tests on Main to Compile #4
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
defmodule TheronsErp.Factory do | ||
use ExMachina.Ecto, repo: TheronsErp.Repo | ||
|
||
def product_factory() do | ||
%TheronsErp.Inventory.Product{ | ||
id: Faker.UUID.v4(), | ||
name: Faker.Commerce.En.product_name(), | ||
identifier: Faker.random_between(1, 10_000_000_000), | ||
sales_price: Money.new(500, :USD), | ||
type: TheronsErp.Inventory.Product.Types.values() |> Enum.random(), | ||
inserted_at: Faker.DateTime.backward(7), | ||
updated_at: Faker.DateTime.backward(7) | ||
} | ||
|> AshPostgres.DataLayer.to_ecto() | ||
end | ||
|
||
def product_category_factory() do | ||
%TheronsErp.Inventory.ProductCategory{ | ||
id: Faker.UUID.v4(), | ||
name: Faker.Commerce.En.product_name(), | ||
product_category_id: Faker.UUID.v4(), | ||
full_name: Faker.Commerce.En.product_name(), | ||
inserted_at: Faker.DateTime.backward(7), | ||
updated_at: Faker.DateTime.backward(7) | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
{:ok, _} = Application.ensure_all_started(:ex_machina) | ||
|
||
ExUnit.start() | ||
Ecto.Adapters.SQL.Sandbox.mode(TheronsErp.Repo, :manual) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
defmodule TheronsErp.Inventory.ProductTest do | ||
use ExUnit.Case | ||
|
||
test "can make a product" do | ||
TheronsErp.Inventory.Product | ||
|> Ash.Changeset.for_create(:create) | ||
end | ||
end |
119 changes: 119 additions & 0 deletions
119
test/therons_erp_web/live/product_category_live_test.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,122 @@ | ||
defmodule TheronsErpWeb.ProductCategoryLiveTest do | ||
use TheronsErpWeb.ConnCase | ||
|
||
import Phoenix.LiveViewTest | ||
import TheronsErp.Factory | ||
import TheronsErp.InventoryFixtures | ||
|
||
@create_attrs %{name: "some name"} | ||
@update_attrs %{name: "some updated name"} | ||
@invalid_attrs %{name: nil} | ||
|
||
defp create_product_category(_) do | ||
product_category = build(:product_category) | ||
%{product_category: product_category} | ||
end | ||
|
||
describe "Index" do | ||
setup [:create_product_category] | ||
|
||
test "lists all product_categories", %{conn: conn, product_category: product_category} do | ||
{:ok, _index_live, html} = live(conn, ~p"/product_categories") | ||
|
||
assert html =~ "Listing Product categories" | ||
assert html =~ product_category.name | ||
end | ||
|
||
test "saves new product_category", %{conn: conn} do | ||
{:ok, index_live, _html} = live(conn, ~p"/product_categories") | ||
|
||
assert index_live |> element("a", "New Product category") |> render_click() =~ | ||
"New Product category" | ||
|
||
assert_patch(index_live, ~p"/product_categories/new") | ||
|
||
assert index_live | ||
|> form("#product_category-form", product_category: @invalid_attrs) | ||
|> render_change() =~ "can't be blank" | ||
|
||
assert index_live | ||
|> form("#product_category-form", product_category: @create_attrs) | ||
|> render_submit() | ||
|
||
assert_patch(index_live, ~p"/product_categories") | ||
|
||
html = render(index_live) | ||
assert html =~ "Product category created successfully" | ||
assert html =~ "some name" | ||
end | ||
|
||
test "updates product_category in listing", %{conn: conn, product_category: product_category} do | ||
{:ok, index_live, _html} = live(conn, ~p"/product_categories") | ||
|
||
assert index_live | ||
|> element("#product_categories-#{product_category.id} a", "Edit") | ||
|> render_click() =~ | ||
"Edit Product category" | ||
|
||
assert_patch(index_live, ~p"/product_categories/#{product_category}/edit") | ||
|
||
assert index_live | ||
|> form("#product_category-form", product_category: @invalid_attrs) | ||
|> render_change() =~ "can't be blank" | ||
|
||
assert index_live | ||
|> form("#product_category-form", product_category: @update_attrs) | ||
|> render_submit() | ||
|
||
assert_patch(index_live, ~p"/product_categories") | ||
|
||
html = render(index_live) | ||
assert html =~ "Product category updated successfully" | ||
assert html =~ "some updated name" | ||
end | ||
|
||
test "deletes product_category in listing", %{conn: conn, product_category: product_category} do | ||
{:ok, index_live, _html} = live(conn, ~p"/product_categories") | ||
|
||
assert index_live | ||
|> element("#product_categories-#{product_category.id} a", "Delete") | ||
|> render_click() | ||
|
||
refute has_element?(index_live, "#product_categories-#{product_category.id}") | ||
end | ||
end | ||
|
||
describe "Show" do | ||
setup [:create_product_category] | ||
|
||
test "displays product_category", %{conn: conn, product_category: product_category} do | ||
{:ok, _show_live, html} = live(conn, ~p"/product_categories/#{product_category}") | ||
|
||
assert html =~ "Show Product category" | ||
assert html =~ product_category.name | ||
end | ||
|
||
test "updates product_category within modal", %{ | ||
conn: conn, | ||
product_category: product_category | ||
} do | ||
{:ok, show_live, _html} = live(conn, ~p"/product_categories/#{product_category}") | ||
|
||
assert show_live |> element("a", "Edit") |> render_click() =~ | ||
"Edit Product category" | ||
|
||
assert_patch(show_live, ~p"/product_categories/#{product_category}/show/edit") | ||
|
||
assert show_live | ||
|> form("#product_category-form", product_category: @invalid_attrs) | ||
|> render_change() =~ "can't be blank" | ||
|
||
assert show_live | ||
|> form("#product_category-form", product_category: @update_attrs) | ||
|> render_submit() | ||
|
||
assert_patch(show_live, ~p"/product_categories/#{product_category}") | ||
|
||
html = render(show_live) | ||
assert html =~ "Product category updated successfully" | ||
assert html =~ "some updated name" | ||
end | ||
end | ||
end |
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. I believe I deleted these from |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,116 @@ | ||
defmodule TheronsErpWeb.ProductLiveTest do | ||
use TheronsErpWeb.ConnCase | ||
|
||
import Phoenix.LiveViewTest | ||
import TheronsErp.Factory | ||
import TheronsErp.InventoryFixtures | ||
|
||
@create_attrs %{name: "some name", tags: ["option1", "option2"]} | ||
@update_attrs %{name: "some updated name", tags: ["option1"]} | ||
@invalid_attrs %{name: nil, tags: []} | ||
|
||
defp create_product(_) do | ||
product = insert(:product) | ||
%{product: product} | ||
end | ||
|
||
describe "Index" do | ||
setup [:create_product] | ||
|
||
test "shows product page", %{conn: conn, product: product} do | ||
{:ok, _index_live, html} = live(conn, ~p"/products") | ||
|
||
assert html =~ "Listing Products" | ||
assert html =~ product.name | ||
end | ||
|
||
test "saves new product", %{conn: conn} do | ||
{:ok, index_live, html} = live(conn, ~p"/products") | ||
|
||
dbg(html) | ||
|
||
assert index_live |> element("a", "New Product") |> render_click() =~ | ||
"New Product" | ||
|
||
assert_patch(index_live, ~p"/products/new") | ||
|
||
assert index_live | ||
|> form("#product-form", product: @invalid_attrs) | ||
|> render_change() =~ "can't be blank" | ||
|
||
assert index_live | ||
|> form("#product-form", product: @create_attrs) | ||
|> render_submit() | ||
|
||
assert_patch(index_live, ~p"/products") | ||
|
||
html = render(index_live) | ||
assert html =~ "Product created successfully" | ||
assert html =~ "some name" | ||
end | ||
|
||
test "updates product in listing", %{conn: conn, product: product} do | ||
{:ok, index_live, _html} = live(conn, ~p"/products") | ||
|
||
assert index_live |> element("#products-#{product.id} a", "Edit") |> render_click() =~ | ||
"Edit Product" | ||
|
||
assert_patch(index_live, ~p"/products/#{product}/edit") | ||
|
||
assert index_live | ||
|> form("#product-form", product: @invalid_attrs) | ||
|> render_change() =~ "can't be blank" | ||
|
||
assert index_live | ||
|> form("#product-form", product: @update_attrs) | ||
|> render_submit() | ||
|
||
assert_patch(index_live, ~p"/products") | ||
|
||
html = render(index_live) | ||
assert html =~ "Product updated successfully" | ||
assert html =~ "some updated name" | ||
end | ||
|
||
test "deletes product in listing", %{conn: conn, product: product} do | ||
{:ok, index_live, _html} = live(conn, ~p"/products") | ||
|
||
assert index_live |> element("#products-#{product.id} a", "Delete") |> render_click() | ||
refute has_element?(index_live, "#products-#{product.id}") | ||
end | ||
end | ||
|
||
describe "Show" do | ||
setup [:create_product] | ||
|
||
test "displays product", %{conn: conn, product: product} do | ||
{:ok, _show_live, html} = live(conn, ~p"/products/#{product}") | ||
|
||
assert html =~ "Show Product" | ||
assert html =~ product.name | ||
end | ||
|
||
test "updates product within modal", %{conn: conn, product: product} do | ||
{:ok, show_live, _html} = live(conn, ~p"/products/#{product}") | ||
|
||
assert show_live |> element("a", "Edit") |> render_click() =~ | ||
"Edit Product" | ||
|
||
assert_patch(show_live, ~p"/products/#{product}/show/edit") | ||
|
||
assert show_live | ||
|> form("#product-form", product: @invalid_attrs) | ||
|> render_change() =~ "can't be blank" | ||
|
||
assert show_live | ||
|> form("#product-form", product: @update_attrs) | ||
|> render_submit() | ||
|
||
assert_patch(show_live, ~p"/products/#{product}") | ||
|
||
html = render(show_live) | ||
assert html =~ "Product updated successfully" | ||
assert html =~ "some updated name" | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I believe I deleted these from
sales_orders
bc they were broken.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.
I can take a look into these, including #4
I'm looking at them now and at the moment what they're doing is returning some HTML and I assume it is the product live and product category live pages, but right now it's my first time laying my eyes on it so we'll see.
What they're doing ultimately might need to be rewritten but a lot of it might be similar. This was all pregenerated boilerplate right? Give me a bit to work on this.
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.
Delete them for now. The UI is highly customize. I'll add a comment to the PR with some code you'll need.