Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1118df5

Browse files
committed
new: Initial commit
0 parents  commit1118df5

File tree

11 files changed

+521
-0
lines changed

11 files changed

+521
-0
lines changed

‎.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
playwrigth/node_modules/
2+
playwright/report

‎README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
###Build the image
2+
3+
4+
To build the image run:
5+
6+
```
7+
docker build -t lowcoder-tests -f docker/Dockerfile docker/ --no-cache
8+
```
9+
10+
If you need to change the default playwright version (currently v1.45) add build argument to the build:
11+
12+
```
13+
docker build -t lowcoder-tests --build-arg=PLAYWRIGHT_VERSION=1.40 -f docker/Dockerfile docker/ --no-cache
14+
```
15+
16+
###Running tests
17+
18+
**Using --ipc=host is recommended when using Chrome (Docker docs). Chrome can run out of memory without this flag.**
19+
20+
```
21+
docker run -it --rm --ipc=host -v ./playwright:/app lowcoder-tests
22+
```
23+
24+
To configure to which lowcoder instance playwright is connecting, set`LOWCODER_BASE_URL` in`playwright/.env` file.
25+
26+
Once tests are finished, you can find html reposrts and videos in`playwright/report` folder.
27+
28+
##Writing tests
29+
30+
To build and run and debug tests on your computer, you can use this setup:https://playwright.dev/docs/getting-started-vscode

‎docker/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM node:20-bookworm
2+
3+
# Set this build argument to change the playwright version
4+
ARG PLAYWRIGHT_VERSION=1.45
5+
6+
# Install gosu for dropping privileges
7+
ARG GOSU_VERSION=1.17
8+
RUN dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
9+
&& wget -O /usr/local/bin/gosu"https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \
10+
&& chmod +x /usr/local/bin/gosu \
11+
&& gosu nobody true
12+
13+
# Create user playwright - privileges will be dropped by entrypoint.sh
14+
RUN userdel -rf node \
15+
&& groupadd --gid=1001 playwright \
16+
&& useradd --system --uid=1001 --gid=1001 --create-home --home-dir=/home/playwright playwright
17+
18+
# Install playwright and all its dependencies (browsers etc...)
19+
USER playwright
20+
WORKDIR /home/playwright
21+
RUN npm install @playwright/test \
22+
&& npx -y playwright@${PLAYWRIGHT_VERSION} install
23+
24+
USER root
25+
RUN npx playwright install-deps
26+
27+
# Copy entrypoint script
28+
COPY --chmod=0755 entrypoint.sh /entrypoint.sh
29+
30+
# /app is the home folder of playwright tests root
31+
RUN mkdir -p /app
32+
WORKDIR /app
33+
34+
35+
ENTRYPOINT ["/entrypoint.sh" ]

‎docker/entrypoint.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
if ["$(id -u)"="0" ];then
4+
echo"Running as root, dropping privileges..."
5+
TESTS_UID=`ls -n /app/tests| tail -1| cut -f3 -d''`
6+
TESTS_GID=`ls -n /app/tests| tail -1| cut -f4 -d''`
7+
PUID=`id playwright -u`
8+
PGID=`id playwright -g`
9+
10+
if ["${TESTS_GID}"!="${PGID}" ];then
11+
echo" changing GID to${TESTS_GID}"
12+
groupmod --gid="${TESTS_GID}" -o playwright
13+
fi;
14+
15+
if ["${TESTS_UID}"!="${PUID}" ];then
16+
echo" changing UID to${TESTS_UID}"
17+
usermod --uid="${TESTS_UID}" -o playwright
18+
fi;
19+
fi;
20+
21+
cd /app
22+
if [!-e"/app/node_modules" ];then
23+
gosu playwright npm install
24+
fi;
25+
26+
gosu playwright npx playwrighttest

‎playwright/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
LOWCODER_BASE_URL=http://192.168.0.50:3003

‎playwright/fixtures.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import{testasbase}from'@playwright/test';
2+
import{LoginPage}from'./pages/login-page';
3+
4+
// Declare the types of your fixtures.
5+
typeMyFixtures={
6+
loginPage:LoginPage;
7+
};
8+

‎playwright/package-lock.json

Lines changed: 159 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎playwright/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name":"playwright",
3+
"version":"1.0.0",
4+
"description":"",
5+
"main":"index.js",
6+
"scripts": {},
7+
"keywords": [],
8+
"author":"",
9+
"license":"ISC",
10+
"devDependencies": {
11+
"@playwright/test":"^1.45.1",
12+
"@types/node":"^20.14.10"
13+
},
14+
"dependencies": {
15+
"dotenv":"^16.4.5"
16+
}
17+
}

‎playwright/pages/login-page.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
importtype{Page,Locator}from'@playwright/test';
2+
3+
exportclassLoginPage{
4+
privatereadonlyemailInput:Locator;
5+
privatereadonlypasswordInput:Locator;
6+
privatereadonlyconfirmPasswordInput:Locator;
7+
privatereadonlysignInButton:Locator;
8+
privatereadonlysignUpButton:Locator;
9+
privatereadonlysignInLink:Locator;
10+
privatereadonlysignUpLink:Locator;
11+
12+
constructor(publicreadonlypage:Page){
13+
this.emailInput=this.page.getByPlaceholder(/^Pleaseenteryouremail$/);
14+
this.passwordInput=this.page.getByPlaceholder(/^Pleaseenteryourpassword$/);
15+
this.confirmPasswordInput=this.page.getByPlaceholder(/^PleaseConfirmPassword$/);
16+
this.signInButton=this.page.getByRole('button',{name:'Sign In'});
17+
this.signUpButton=this.page.getByRole('button',{name:'Sign Up'});
18+
this.signUpLink=this.page.getByRole('link',{name:'Sign In'});
19+
this.signUpLink=this.page.getByRole('link',{name:'Sign Up'});
20+
}
21+
22+
asyncloadPage(){
23+
awaitthis.page.goto('/user/auth/login');
24+
}
25+
26+
asyncfillEmail(text:string){
27+
awaitthis.emailInput.click();
28+
awaitthis.emailInput.fill(text);
29+
}
30+
31+
asyncfillPassword(text:string){
32+
awaitthis.passwordInput.click();
33+
awaitthis.passwordInput.fill(text);
34+
}
35+
36+
asyncfillConfirmPassword(text:string){
37+
awaitthis.confirmPasswordInput.click();
38+
awaitthis.confirmPasswordInput.fill(text);
39+
}
40+
41+
asyncclickSignIn(){
42+
awaitthis.signInButton.click();
43+
}
44+
45+
asyncclickSignUp(){
46+
awaitthis.signUpButton.click();
47+
}
48+
49+
asyncclickSignUpLink(){
50+
awaitthis.signUpLink.click();
51+
}
52+
53+
asyncsignUp(username:string,password:string,repeatPassword:string){
54+
if(awaitthis.signUpLink.isVisible()){
55+
awaitthis.clickSignUpLink();
56+
}
57+
58+
awaitthis.fillEmail(username);
59+
60+
/* disabled because the placeholder is different between sign in and sign up */
61+
//await this.fillPassword(password);
62+
awaitthis.page.getByPlaceholder(/^PleaseEnterPassword$/).click();
63+
awaitthis.page.getByPlaceholder(/^PleaseEnterPassword$/).fill(password);
64+
65+
awaitthis.fillConfirmPassword(repeatPassword);
66+
awaitthis.clickSignUp();
67+
}
68+
69+
asynclogIn(username:string,password:string){
70+
awaitthis.loadPage();
71+
awaitthis.fillEmail(username);
72+
awaitthis.fillPassword(password);
73+
awaitthis.clickSignIn();
74+
}
75+
76+
asynclogOut(username:string){
77+
awaitthis.page.getByTitle(username,{exact:true}).click();
78+
awaitthis.page.getByText('Log Out').click({delay:1000});
79+
}
80+
81+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp