Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
11467f36
Commit
11467f36
authored
Oct 14, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for auth modal and user profile
parent
b8adbff7
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
129 additions
and
3 deletions
+129
-3
AuthModal.pw.tsx
ui/snippets/auth/AuthModal.pw.tsx
+64
-0
AuthModal.pwstory.tsx
ui/snippets/auth/AuthModal.pwstory.tsx
+30
-0
AuthModal.pw.tsx_default_email-login-1.png
..._screenshots__/AuthModal.pw.tsx_default_email-login-1.png
+0
-0
AuthModal.pw.tsx_default_email-login-2.png
..._screenshots__/AuthModal.pw.tsx_default_email-login-2.png
+0
-0
AuthModal.pw.tsx_default_email-login-3.png
..._screenshots__/AuthModal.pw.tsx_default_email-login-3.png
+0
-0
AuthModal.pw.tsx_default_email-login-4.png
..._screenshots__/AuthModal.pw.tsx_default_email-login-4.png
+0
-0
AuthModal.pw.tsx_default_link-email-to-account-1.png
...ts__/AuthModal.pw.tsx_default_link-email-to-account-1.png
+0
-0
AuthModal.pw.tsx_default_link-email-to-account-2.png
...ts__/AuthModal.pw.tsx_default_link-email-to-account-2.png
+0
-0
UserProfileButton.tsx
ui/snippets/user/profile/UserProfileButton.tsx
+1
-1
UserProfileContent.tsx
ui/snippets/user/profile/UserProfileContent.tsx
+2
-2
UserProfileDesktop.pw.tsx
ui/snippets/user/profile/UserProfileDesktop.pw.tsx
+32
-0
UserProfileDesktop.pw.tsx_default_without-address-1.png
..._/UserProfileDesktop.pw.tsx_default_without-address-1.png
+0
-0
UserProfileDesktop.pw.tsx_default_without-email-1.png
...s__/UserProfileDesktop.pw.tsx_default_without-email-1.png
+0
-0
No files found.
ui/snippets/auth/AuthModal.pw.tsx
0 → 100644
View file @
11467f36
import
type
{
BrowserContext
}
from
'
@playwright/test
'
;
import
React
from
'
react
'
;
import
*
as
profileMock
from
'
mocks/user/profile
'
;
import
{
contextWithAuth
}
from
'
playwright/fixtures/auth
'
;
import
{
test
,
expect
}
from
'
playwright/lib
'
;
import
AuthModalStory
from
'
./AuthModal.pwstory
'
;
test
(
'
email login
'
,
async
({
render
,
page
,
mockApiResponse
})
=>
{
await
render
(<
AuthModalStory
flow=
"email_login"
/>);
await
expect
(
page
.
getByText
(
'
Status: Not authenticated
'
)).
toBeVisible
();
await
page
.
getByText
(
'
Log in
'
).
click
();
await
expect
(
page
).
toHaveScreenshot
();
// fill email
await
page
.
getByText
(
'
Continue with email
'
).
click
();
await
page
.
getByLabel
(
/email/i
).
getByPlaceholder
(
'
'
).
fill
(
'
john.doe@example.com
'
);
await
expect
(
page
).
toHaveScreenshot
();
// send otp code
await
mockApiResponse
(
'
auth_send_otp
'
,
{}
as
never
);
await
page
.
getByText
(
'
Send a code
'
).
click
();
// fill otp code
await
page
.
getByLabel
(
/enter your pin code/i
).
nth
(
0
).
fill
(
'
123456
'
);
await
expect
(
page
).
toHaveScreenshot
();
// submit otp code
await
mockApiResponse
(
'
auth_confirm_otp
'
,
profileMock
.
base
as
never
);
await
page
.
getByText
(
'
Submit
'
).
click
();
await
expect
(
page
).
toHaveScreenshot
();
await
page
.
getByLabel
(
'
Close
'
).
click
();
await
expect
(
page
.
getByText
(
'
Status: Authenticated
'
)).
toBeVisible
();
});
const
linkEmailTest
=
test
.
extend
<
{
context
:
BrowserContext
}
>
({
context
:
contextWithAuth
,
});
linkEmailTest
(
'
link email to account
'
,
async
({
render
,
page
,
mockApiResponse
})
=>
{
await
mockApiResponse
(
'
user_info
'
,
profileMock
.
base
);
await
render
(<
AuthModalStory
flow=
"email_link"
/>);
await
expect
(
page
.
getByText
(
'
Status: Authenticated
'
)).
toBeVisible
();
// fill email
await
page
.
getByText
(
'
Link email
'
).
click
();
await
page
.
getByLabel
(
/email/i
).
getByPlaceholder
(
'
'
).
fill
(
'
john.doe@example.com
'
);
await
expect
(
page
).
toHaveScreenshot
();
// send and fill otp code
await
mockApiResponse
(
'
auth_send_otp
'
,
{}
as
never
);
await
page
.
getByText
(
'
Send a code
'
).
click
();
await
page
.
getByLabel
(
/enter your pin code/i
).
nth
(
0
).
fill
(
'
123456
'
);
await
mockApiResponse
(
'
auth_link_email
'
,
profileMock
.
base
as
never
);
await
page
.
getByText
(
'
Submit
'
).
click
();
await
expect
(
page
).
toHaveScreenshot
();
});
ui/snippets/auth/AuthModal.pwstory.tsx
0 → 100644
View file @
11467f36
import
{
Box
,
Button
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
AuthModal
from
'
./AuthModal
'
;
import
useIsAuth
from
'
./useIsAuth
'
;
interface
Props
{
flow
:
'
email_login
'
|
'
email_link
'
;
}
const
AuthModalStory
=
({
flow
}:
Props
)
=>
{
const
authModal
=
useDisclosure
();
const
isAuth
=
useIsAuth
();
const
initialScreen
=
flow
===
'
email_login
'
?
{
type
:
'
select_method
'
as
const
}
:
{
type
:
'
email
'
as
const
,
isAuth
:
true
};
const
handleClose
=
React
.
useCallback
(()
=>
{
authModal
.
onClose
();
},
[
authModal
]);
return
(
<>
<
Button
onClick=
{
authModal
.
onOpen
}
>
{
flow
===
'
email_login
'
?
'
Log in
'
:
'
Link email
'
}
</
Button
>
{
authModal
.
isOpen
&&
<
AuthModal
initialScreen=
{
initialScreen
}
onClose=
{
handleClose
}
/>
}
<
Box
>
Status:
{
isAuth
?
'
Authenticated
'
:
'
Not authenticated
'
}
</
Box
>
</>
);
};
export
default
AuthModalStory
;
ui/snippets/auth/__screenshots__/AuthModal.pw.tsx_default_email-login-1.png
0 → 100644
View file @
11467f36
19.4 KB
ui/snippets/auth/__screenshots__/AuthModal.pw.tsx_default_email-login-2.png
0 → 100644
View file @
11467f36
24.9 KB
ui/snippets/auth/__screenshots__/AuthModal.pw.tsx_default_email-login-3.png
0 → 100644
View file @
11467f36
26.1 KB
ui/snippets/auth/__screenshots__/AuthModal.pw.tsx_default_email-login-4.png
0 → 100644
View file @
11467f36
29.2 KB
ui/snippets/auth/__screenshots__/AuthModal.pw.tsx_default_link-email-to-account-1.png
0 → 100644
View file @
11467f36
23.2 KB
ui/snippets/auth/__screenshots__/AuthModal.pw.tsx_default_link-email-to-account-2.png
0 → 100644
View file @
11467f36
20.6 KB
ui/snippets/user/profile/UserProfileButton.tsx
View file @
11467f36
...
...
@@ -68,7 +68,7 @@ const UserProfileButton = ({ profileQuery, size, variant, onClick, isPending }:
isDisabled=
{
isMobile
||
isFetched
||
Boolean
(
data
)
}
openDelay=
{
500
}
>
<
Skeleton
isLoaded=
{
isFetched
}
borderRadius=
"base"
ref=
{
ref
}
>
<
Skeleton
isLoaded=
{
isFetched
}
borderRadius=
"base"
ref=
{
ref
}
w=
"fit-content"
>
<
Button
size=
{
size
}
variant=
{
variant
}
...
...
ui/snippets/user/profile/UserProfileContent.tsx
View file @
11467f36
...
...
@@ -86,14 +86,14 @@ const UserProfileContent = ({ data, onClose, onLogin, onAddEmail, onAddAddress }
<
Hint
label=
"Address"
boxSize=
{
4
}
ml=
{
1
}
mr=
"auto"
/>
{
data
?.
address_hash
?
<
Box
>
{
shortenString
(
data
?.
address_hash
)
}
</
Box
>
:
<
Link
onClick=
{
onAddAddress
}
color=
"text_secondary"
_hover=
{
{
color
:
'
link_hovered
'
,
textDecoration
:
'
none
'
}
}
>
Add
wallet
</
Link
>
<
Link
onClick=
{
onAddAddress
}
color=
"text_secondary"
_hover=
{
{
color
:
'
link_hovered
'
,
textDecoration
:
'
none
'
}
}
>
Add
address
</
Link
>
}
</
Flex
>
)
}
<
Flex
p=
{
2
}
columnGap=
{
4
}
>
<
Box
mr=
"auto"
>
Email
</
Box
>
{
data
?.
email
?
<
TruncatedValue
value=
{
data
.
email
+
data
.
email
}
/>
:
<
TruncatedValue
value=
{
data
.
email
}
/>
:
<
Link
onClick=
{
onAddEmail
}
color=
"text_secondary"
_hover=
{
{
color
:
'
link_hovered
'
,
textDecoration
:
'
none
'
}
}
>
Add email
</
Link
>
}
</
Flex
>
...
...
ui/snippets/user/profile/UserProfileDesktop.pw.tsx
0 → 100644
View file @
11467f36
import
type
{
BrowserContext
}
from
'
@playwright/test
'
;
import
React
from
'
react
'
;
import
*
as
profileMock
from
'
mocks/user/profile
'
;
import
{
contextWithAuth
}
from
'
playwright/fixtures/auth
'
;
import
{
test
as
base
,
expect
}
from
'
playwright/lib
'
;
import
UserProfileDesktop
from
'
./UserProfileDesktop
'
;
const
test
=
base
.
extend
<
{
context
:
BrowserContext
}
>
({
context
:
contextWithAuth
,
});
test
(
'
without address
'
,
async
({
render
,
page
,
mockApiResponse
})
=>
{
await
mockApiResponse
(
'
user_info
'
,
profileMock
.
base
);
await
render
(<
UserProfileDesktop
/>);
await
page
.
getByText
(
/tom/i
).
click
();
await
expect
(
page
).
toHaveScreenshot
({
clip
:
{
x
:
0
,
y
:
0
,
width
:
300
,
height
:
600
},
});
});
test
(
'
without email
'
,
async
({
render
,
page
,
mockApiResponse
})
=>
{
await
mockApiResponse
(
'
user_info
'
,
profileMock
.
withoutEmail
);
await
render
(<
UserProfileDesktop
/>);
await
page
.
getByText
(
/my profile/i
).
click
();
await
expect
(
page
).
toHaveScreenshot
({
clip
:
{
x
:
0
,
y
:
0
,
width
:
300
,
height
:
600
},
});
});
ui/snippets/user/profile/__screenshots__/UserProfileDesktop.pw.tsx_default_without-address-1.png
0 → 100644
View file @
11467f36
25.4 KB
ui/snippets/user/profile/__screenshots__/UserProfileDesktop.pw.tsx_default_without-email-1.png
0 → 100644
View file @
11467f36
26.2 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment