Skip to content

Commit ad616a9

Browse files
authored
Enhanced selenium tests + bugfixes (#101)
* next build * Production mode webapp builds * Enhaned selenium tests, fixed registration * Test improvements * made tests work maybe * increased sleep * dumb * wow * increase sleeps
1 parent 2023100 commit ad616a9

File tree

9 files changed

+133
-107
lines changed

9 files changed

+133
-107
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
run: echo "nginx" | ./up.sh
1515
if: always()
1616
- name: Run Selenium tests
17-
run: cd selenium && sleep 30 && sudo docker run --net horahora_default $(docker build -q .)
17+
run: cd selenium && sleep 90 && sudo docker run --net horahora_default $(docker build -q .)
1818
if: always()
1919
- name: Build the stack localhost
2020
run: echo "localhost" | ./up.sh

front_api/routes/routes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ func setCookie(c echo.Context, jwt string) error {
158158

159159
cookie.SameSite = http.SameSiteStrictMode
160160
//cookie.Secure = true // set this later
161+
cookie.HttpOnly = false
161162

162163
c.SetCookie(cookie)
163164

selenium/test.py

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,61 @@
44
import time
55

66
if __name__ == "__main__":
7-
chrome_options = webdriver.ChromeOptions()
7+
chrome_options = Options()
88
chrome_options.add_argument('--no-sandbox')
99
chrome_options.add_argument('--window-size=1920,1080')
1010
chrome_options.add_argument('--headless')
1111
chrome_options.add_argument('--disable-gpu')
12-
driver = webdriver.Chrome(chrome_options=chrome_options)
12+
13+
driver = webdriver.Chrome(options=chrome_options)
1314

1415
driver.get("http://nginx/authentication/login")
1516

16-
time.sleep(5)
17+
time.sleep(3)
1718
assert driver.title == "Log in"
1819

19-
time.sleep(5)
20+
time.sleep(3)
2021

2122
username_box = driver.find_element(by=By.ID, value="auth-login-name")
2223
password_box = driver.find_element(by=By.ID, value="auth-login-password")
2324
submit_button = driver.find_element(by=By.ID, value="auth-login")
2425
username_box.send_keys("admin")
2526
password_box.send_keys("admin")
2627
submit_button.submit()
27-
time.sleep(5)
28-
print(driver.get_cookies())
29-
30-
time.sleep(5)
31-
print(driver.current_url)
32-
print(driver.get_cookies())
28+
time.sleep(3)
3329

3430
assert driver.current_url == "http://nginx/"
3531
assert driver.title == "Videos"
3632

33+
driver.get('http://nginx/account/archives')
34+
time.sleep(3)
35+
assert driver.title == "View and manage your archives"
36+
video_box = driver.find_element(by=By.ID, value="new-video-url")
37+
video_form = driver.find_element(by=By.ID, value="new-video")
38+
video_box.send_keys("https://www.youtube.com/watch?v=GWAtnzcbfFQ")
39+
video_form.submit()
40+
41+
time.sleep(3)
42+
dl_card = driver.find_element(by=By.ID, value="download-request-1")
43+
assert dl_card is not None
44+
45+
# Search for author
46+
for i in range(1, 80):
47+
try:
48+
driver.get('http://nginx/search?search=%E3%82%82%E3%81%A1%E3%81%86%E3%81%A4%E3%81%AD&category=upload_date&order=desc')
49+
time.sleep(5) # why do we need...
50+
video_href = driver.find_element(by=By.ID, value="/videos/1")
51+
if video_href is None:
52+
print("Failed to find video 1 on page, attempt " + str(i))
53+
continue
54+
video_href.click()
55+
break
56+
except:
57+
print("Failed to find video 1 on page, attempt " + str(i))
58+
59+
time.sleep(3)
60+
assert driver.current_url == "http://nginx/videos/1"
61+
assert driver.title == 'Video "おくすり飲んで寝よう / 初音ミク - もちうつね" (1) by "もちうつね" (1)'
62+
3763
driver.quit()
3864
print("wow we did it")

user_service/migrations/V1___users_table.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ CREATE TABLE users (
55
pass_hash varchar(255),
66
foreign_user_ID varchar(255),
77
foreign_website varchar(255) -- Again, could use enum... lazy schema design...
8-
);
8+
);

user_service/protocol/userservice.pb.go

Lines changed: 89 additions & 90 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

user_service/protocol/userservice.pb.validate.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

user_service/protocol/userservice.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ message validateJWTResponse {
9696
message RegisterRequest {
9797
string email = 1 [(validate.rules).string.email = true];
9898
string username = 2 [(validate.rules).string = {
99-
pattern: "^[^[0-9]A-Za-z]+( [^[0-9]A-Za-z]+)*$",
99+
pattern: "^[a-zA-Z0-9]+$",
100100
max_bytes: 10,
101101
}];
102102
string password = 3;

webapp/src/entities/post/card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function Component({ post, headingLevel, ...blockProps }: IPostVideoCardProps) {
3535
return (
3636
<Card {...blockProps}>
3737
<CardHeader>
38-
<a href={`/videos/${VideoID}`}>
38+
<a id={`/videos/${VideoID}`} href={`/videos/${VideoID}`}>
3939
<Heading level={headingLevel}>{Title}</Heading>
4040
</a>
4141
</CardHeader>

webapp/src/pages/account/administrator/audits.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function AuditsPage() {
5858
}}
5959
/>
6060
<CardList>
61-
{pageData.Events.map((audit) => (
61+
{pageData.Events != null && pageData.Events.map((audit) => (
6262
<AuditCard key={audit.ID} audit={audit} />
6363
))}
6464
</CardList>

0 commit comments

Comments
 (0)