Skip to content

Commit 1cd10df

Browse files
toil(e2e): user management and project creation (#267)
## 📝 Description <!-- Describe your changes in detail --> ## ✅ Checklist - [ ] I have tested this change - [ ] This change requires documentation update
1 parent a57dc42 commit 1cd10df

File tree

8 files changed

+469
-22
lines changed

8 files changed

+469
-22
lines changed

e2e/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ e2e-*.tar
2525
# Temporary files, for example, from tests.
2626
/tmp/
2727
.envrc
28+
/out/

e2e/config/config.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ if System.get_env("START_WALLABY") do
4747
"--no-sandbox",
4848
"--disable-gpu",
4949
"--disable-dev-shm-usage",
50-
"--disable-software-rasterizer",
51-
"--window-size=1280,800"
50+
"--window-size=1920,1200"
5251
]
5352
]
5453
end

e2e/mix.exs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ defmodule E2E.MixProject do
2424
if System.get_env("START_WALLABY") do
2525
base
2626
else
27-
# Exclude ui_test_case.ex if Wallaby is not available
27+
ui_test_files = [
28+
"test/support/ui_test_case.ex",
29+
"test/support/user_action.ex"
30+
]
31+
2832
["lib", "test/support"]
29-
|> Enum.flat_map(fn path ->
30-
if path == "test/support" do
33+
|> Enum.flat_map(fn
34+
"test/support" ->
3135
Path.wildcard("test/support/*.ex")
32-
|> Enum.reject(&(&1 =~ "ui_test_case.ex"))
33-
else
36+
|> Enum.reject(&(&1 in ui_test_files))
37+
38+
path ->
3439
[path]
35-
end
3640
end)
3741
end
3842
end

e2e/test/e2e/ui/login_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ defmodule E2E.UI.LoginTest do
4141
|> assert_has(Query.css("#kc-login[type='submit'][value='Sign In']"))
4242
|> fill_in(Query.text_field("username"), with: root_email)
4343
|> fill_in(Query.text_field("password"), with: root_password)
44+
|> then(fn s ->
45+
s |> find(Query.css("#kc-form-buttons"))
46+
s
47+
end)
4448
|> click(Query.css("#kc-login"))
4549
|> assert_has(
4650
Query.css("h1.f2.f1-m.lh-title.mb1",
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
defmodule E2E.UI.ProjectCreationFlowTest do
2+
use E2E.UI.UserTestCase
3+
require Logger
4+
5+
describe "Project Creation Flow" do
6+
@tag timeout: 600_000
7+
test "complete project creation flow", %{session: session} do
8+
Logger.info("Starting Project Creation Flow test")
9+
10+
# Step 1: Navigate to project creation page
11+
Logger.info("Step 1: Navigating to project creation page")
12+
session = click(session, Wallaby.Query.link("Create new"))
13+
14+
# Verify we're on the project creation page
15+
Logger.info("Verifying project creation page")
16+
session = assert_has(session, Wallaby.Query.css("h1", text: "Project type"))
17+
18+
# Step 2: Select GitHub integration using a specific CSS selector
19+
Logger.info("Step 2: Selecting GitHub integration")
20+
session = click(session, Wallaby.Query.css(".f3.b", text: "GitHub"))
21+
22+
# Take screenshot to see what happened
23+
take_screenshot(session, name: "after_github_click")
24+
25+
# Verify we're on the repository selection page
26+
Logger.info("Verifying repository selection page")
27+
session = assert_has(session, Wallaby.Query.css("h2", text: "Repository"))
28+
29+
# Step 3: Search for repositories
30+
Logger.info("Step 3: Searching for repositories")
31+
32+
session =
33+
fill_in(session, Wallaby.Query.fillable_field("Search repositories..."), with: "e2e-tests")
34+
35+
# Give the search some time to complete
36+
:timer.sleep(1000)
37+
38+
session = assert_has(session, Wallaby.Query.css(".option"))
39+
40+
# Try to find and click the "Choose" button if available
41+
Logger.info("Clicking 'Choose' button")
42+
session = click(session, Wallaby.Query.css(".green", text: "Choose"))
43+
44+
# Take screenshot after repository selection
45+
take_screenshot(session, name: "after_repository_selection")
46+
# Give some time to check for duplicates
47+
:timer.sleep(1000)
48+
take_screenshot(session, name: "after_repository_selection_with_duplicates")
49+
50+
session = maybe_enable_duplicate(session)
51+
52+
Logger.info("Clicking create project button")
53+
session = wait_for(session, Wallaby.Query.css("button.btn.btn-primary"), 30_000)
54+
click(session, Wallaby.Query.button("✓"))
55+
56+
# Take screenshot after clicking continue
57+
take_screenshot(session, name: "after_continue")
58+
59+
:timer.sleep(15_000)
60+
# Verify we moved to the analysis page and check for the analysis steps checklist
61+
take_screenshot(session, name: "analysis_page")
62+
63+
# wait for project creation to complete (until webhook readonly input is visible)
64+
# This can take up to 15 seconds
65+
Logger.info("Waiting for project creation to complete (up to 15 seconds)...")
66+
67+
# click continue button
68+
session = click(session, Wallaby.Query.link("Continue"))
69+
70+
# Click on the "I want to configure this project from scratch" link
71+
Logger.info("Clicking 'I want to configure this project from scratch' link")
72+
73+
session =
74+
click(session, Wallaby.Query.link("I want to configure this project from scratch"))
75+
76+
# Take a screenshot after clicking the link
77+
take_screenshot(session, name: "configure_from_scratch")
78+
79+
# Click continue button again after selecting "configure from scratch"
80+
Logger.info("Clicking Continue button again")
81+
session = assert_has(session, Wallaby.Query.button("Continue"))
82+
session = click(session, Wallaby.Query.button("Continue"))
83+
84+
# Take a screenshot after clicking continue again
85+
take_screenshot(session, name: "after_second_continue")
86+
87+
# Click "Looks good, start →" button
88+
Logger.info("Clicking 'Looks good, start →' button")
89+
session = assert_has(session, Wallaby.Query.button("Looks good, start →"))
90+
session = click(session, Wallaby.Query.button("Looks good, start →"))
91+
92+
# Take a screenshot after clicking the start button
93+
take_screenshot(session, name: "after_start_button")
94+
95+
Logger.info("Waiting 15 seconds for page transition...")
96+
:timer.sleep(15_000)
97+
98+
# Verify the URL path starts with "/workflows/"
99+
Logger.info("Verifying we are on the workflows page")
100+
current_url = current_url(session)
101+
102+
assert String.contains?(current_url, "/workflows/"),
103+
"Expected URL to contain '/workflows/', but got: #{current_url}"
104+
105+
# Take a final screenshot of the workflows page
106+
take_screenshot(session, name: "workflows_page")
107+
108+
Logger.info("Project Creation completed successfully, flow test is complete")
109+
end
110+
end
111+
112+
defp maybe_enable_duplicate(session) do
113+
duplicate_button = Wallaby.Query.button("Make a duplicate project")
114+
115+
if has?(session, duplicate_button) do
116+
click(session, duplicate_button)
117+
else
118+
session
119+
end
120+
end
121+
122+
defp wait_for(session, query, timeout_ms, interval_ms \\ 200)
123+
defp wait_for(session, query, timeout_ms, _interval_ms) when timeout_ms <= 0 do
124+
assert_has(session, query)
125+
end
126+
127+
defp wait_for(session, query, timeout_ms, interval_ms) do
128+
if has?(session, query) do
129+
session
130+
else
131+
Process.sleep(interval_ms)
132+
wait_for(session, query, timeout_ms - interval_ms, interval_ms)
133+
end
134+
end
135+
136+
end

0 commit comments

Comments
 (0)