Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .semaphore/cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ blocks:
commands:
- checkout
- make test.build
- npm --prefix cli install
- make cli.node_modules
- cache store app-deps app/deps
- cache store app-build app/_build
- cache store app-node-modules app/node_modules
Expand Down
26 changes: 18 additions & 8 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,17 @@ blocks:
prologue:
commands:
- checkout
- cache restore app-deps
- cache restore app-build
- cache restore app-node-modules
- cache restore turboui-node-modules
- cache restore turboui-dist
- make test.build

jobs:
- name: Turbo Lint
commands:
- make test.setup.turboui
- make turboui.build

- name: Turbo Test
commands:
- make test.setup.turboui
- make turboui.test

epilogue:
Expand All @@ -74,14 +71,15 @@ blocks:
- cache restore app-deps
- cache restore app-build
- cache restore app-node-modules
- cache restore cli-node-modules
- cache restore turboui-node-modules
- cache restore turboui-dist
- ./scripts/cache-fix-for-erlang
- make test.build

jobs:
- name: Lint
commands:
- make test.setup.lint
- make test.js.dead.code
- make test.tsc.lint
- make test.cli.catalog.sync
Expand All @@ -91,17 +89,29 @@ blocks:

- name: Dialyzer
commands:
- make test.setup.dialyzer
- make test.dialyzer

- name: Unit Tests
parallelism: 2
commands:
- make test.mix.unit
- make test.setup.unit
- make test.mix.unit INDEX=$SEMAPHORE_JOB_INDEX TOTAL=$SEMAPHORE_JOB_COUNT

- name: EE Tests
commands:
- make test.setup.ee
- make test.ee

- name: JS Tests
commands:
- make test.setup.js
- make test.npm

- name: Features
parallelism: 16
parallelism: 18
commands:
- make test.setup.features
- make test.mix.features INDEX=$SEMAPHORE_JOB_INDEX TOTAL=$SEMAPHORE_JOB_COUNT

epilogue:
Expand Down
78 changes: 66 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SHELL := /bin/bash # Use bash syntax
MAKEFLAGS += -s # Silent mode

.PHONY: test cli.build cli.test cli.test.unit cli.test.e2e
.PHONY: test cli.build cli.test cli.test.unit cli.test.e2e app.node_modules turboui.node_modules cli.node_modules

REPORTS_DIR ?= $(PWD)/app/testreports
SCREENSHOTS_DIR ?= $(PWD)/app/screenshots
Expand Down Expand Up @@ -59,12 +59,21 @@ dev.up:
$(MAKE) dev.seed.env
./devenv up

app.node_modules:
./devenv bash -c "./scripts/ensure_node_modules.sh app app"

turboui.node_modules:
./devenv bash -c "./scripts/ensure_node_modules.sh turboui turboui"

cli.node_modules:
./scripts/ensure_node_modules.sh cli cli

dev.build:
$(MAKE) dev.up
./devenv bash -c "cd app && mix local.hex --force --if-missing"
./devenv bash -c "cd app && mix deps.get"
./devenv bash -c "cd app && mix compile"
./devenv bash -c "cd app && npm install"
$(MAKE) app.node_modules
$(MAKE) turboui.build
$(MAKE) dev.db.create
$(MAKE) test.db.create
Expand All @@ -76,22 +85,26 @@ dev.server:
./devenv bash -c "cd app && iex -S mix phx.server"

turboui.storybook:
$(MAKE) turboui.node_modules
./devenv bash -c "cd turboui && npm run storybook"

turboui.build:
@rm -rf turboui/dist
./devenv bash -c "cd turboui && npm install && npm run build"
$(MAKE) turboui.node_modules
./devenv bash -c "cd turboui && npm run build"

turboui.test:
./devenv bash -c "cd turboui && npm install && npm run test"
$(MAKE) turboui.node_modules
./devenv bash -c "cd turboui && npm run test"

cli.build:
./devenv bash -c "cd cli && npm install && npm run build"
$(MAKE) cli.node_modules
./devenv bash -c "cd cli && npm run build"

cli.test: cli.test.unit

cli.test.unit:
npm --prefix cli install
$(MAKE) cli.node_modules
npm --prefix cli test

cli.test.e2e: test.init
Expand All @@ -101,7 +114,8 @@ cli.test.e2e: test.init

gen.cli.catalog:
$(MAKE) gen.api.catalog
./devenv bash -c "cd cli && npm install && npm run gen:commands"
$(MAKE) cli.node_modules
./devenv bash -c "cd cli && npm run gen:commands"

dev.shell:
./devenv shell
Expand Down Expand Up @@ -161,6 +175,36 @@ test.build:
$(MAKE) test.db.create
$(MAKE) test.db.migrate

test.setup.turboui:
$(MAKE) test.up

test.setup.lint:
$(MAKE) test.up
$(MAKE) test.app.elixir.build
$(MAKE) test.app.node_modules
$(MAKE) test.turboui.node_modules

test.setup.dialyzer:
$(MAKE) test.up
$(MAKE) test.app.elixir.build

test.setup.unit:
$(MAKE) test.up
$(MAKE) test.app.elixir.build
$(MAKE) test.db.create
$(MAKE) test.db.migrate

test.setup.ee:
$(MAKE) test.setup.unit

test.setup.js:
$(MAKE) test.up
$(MAKE) test.app.node_modules
$(MAKE) test.turboui.node_modules

test.setup.features:
$(MAKE) test.build

test.up:
$(MAKE) test.init
$(MAKE) test.seed.env
Expand All @@ -181,18 +225,27 @@ test.up:
fi; \
done

test.turboui.node_modules:
$(MAKE) turboui.node_modules

test.turboui.build:
./devenv bash -c "cd turboui && npm install"
$(MAKE) test.turboui.node_modules
./devenv bash -c "cd turboui && MIX_ENV=test npm run build"

test.app.build:
$(MAKE) test.app.elixir.build
$(MAKE) test.app.js.build

test.app.elixir.build:
./devenv bash -c "cd app && MIX_ENV=test mix local.hex --force --if-missing"
./devenv bash -c "cd app && MIX_ENV=test mix deps.get"
./devenv bash -c "cd app && MIX_ENV=test mix compile"
$(MAKE) test.app.js.build

test.app.node_modules:
$(MAKE) app.node_modules

test.app.js.build:
./devenv bash -c "cd app && MIX_ENV=test npm install"
$(MAKE) test.app.node_modules
./devenv bash -c "cd app && MIX_ENV=test npm run build"
./devenv bash -c "cd app && MIX_ENV=test mix assets.deploy"

Expand Down Expand Up @@ -221,7 +274,7 @@ test.ee:
./devenv bash -c "./scripts/run_ee_tests.js"

test.mix.unit: test.init
./devenv bash -c "./scripts/run_unit_tests.js"
./devenv bash -c "./scripts/run_unit_tests.js $(INDEX) $(TOTAL)"

test.mix.features: test.init
./devenv bash -c "./scripts/run_feature_tests.js $(INDEX) $(TOTAL)"
Expand Down Expand Up @@ -261,7 +314,8 @@ test.tsc.lint:

test.cli.catalog.sync:
$(MAKE) gen.api.catalog
./devenv bash -c "cd cli && npm install && npm run check:catalog"
$(MAKE) cli.node_modules
./devenv bash -c "cd cli && npm run check:catalog"

test.pr.name:
ruby scripts/pr-name-check
Expand Down
106 changes: 106 additions & 0 deletions app/test/features/company_admin/access_and_validation_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
defmodule Operately.Features.CompanyAdmin.AccessAndValidationTest do
use Operately.FeatureCase
alias Operately.Support.Features.CompanyAdminSteps, as: Steps

setup ctx, do: Steps.setup(ctx, as: ctx[:role])

set_app_config(:billing_enabled, true)

@tag role: :member
feature "member gets 404 when manually navigates to manage-people page", ctx do
ctx
|> Steps.assert_logged_in_user_has_edit_access_level()
|> Steps.visit_company_manage_people_page()
|> Steps.assert_404()
end

@tag role: :member
feature "member gets 404 when manually navigates to member type selection page", ctx do
ctx
|> Steps.assert_logged_in_user_has_edit_access_level()
|> Steps.visit_company_member_type_selection_page()
|> Steps.assert_404()
end

@tag role: :member
feature "member gets 404 when manually navigates to invite person page", ctx do
ctx
|> Steps.assert_logged_in_user_has_edit_access_level()
|> Steps.visit_company_invite_person_page()
|> Steps.assert_404()
end

describe "form validation" do
@tag role: :admin
feature "missing full name", ctx do
params = %{
full_name: "",
email: "m.scott@dmif.com",
title: "Regional Manager"
}

error = "Name is required"

ctx
|> Steps.assert_logged_in_user_has_admin_access_level()
|> Steps.open_company_team_page()
|> Steps.assert_error_message_not_visible(error)
|> Steps.invite_company_member(params)
|> Steps.assert_error_message(error)
end

@tag role: :admin
feature "missing email", ctx do
params = %{
full_name: "Michael Scott",
email: "",
title: "Regional Manager"
}

error = "Email is required"

ctx
|> Steps.assert_logged_in_user_has_admin_access_level()
|> Steps.open_company_team_page()
|> Steps.assert_error_message_not_visible(error)
|> Steps.invite_company_member(params)
|> Steps.assert_error_message(error)
end

@tag role: :admin
feature "missing title", ctx do
params = %{
full_name: "Michael Scott",
email: "m.scott@dmif.com",
title: ""
}

error = "Title is required"

ctx
|> Steps.assert_logged_in_user_has_admin_access_level()
|> Steps.open_company_team_page()
|> Steps.assert_error_message_not_visible(error)
|> Steps.invite_company_member(params)
|> Steps.assert_error_message(error)
end

@tag role: :admin
feature "invalid email", ctx do
params = %{
full_name: "Michael Scott",
email: "m.scott",
title: "Regional Manager"
}

error = "Enter a valid email address"

ctx
|> Steps.assert_logged_in_user_has_admin_access_level()
|> Steps.open_company_team_page()
|> Steps.assert_error_message_not_visible(error)
|> Steps.invite_company_member(params)
|> Steps.assert_error_message(error)
end
end
end
Loading