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
b324b4e5
Commit
b324b4e5
authored
Dec 13, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for desktop navigation
parent
4cd8bfec
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
134 additions
and
2 deletions
+134
-2
TestApp.tsx
playwright/TestApp.tsx
+16
-2
NavLink.tsx
ui/snippets/navigation/NavLink.tsx
+1
-0
NavigationDesktop.pw.tsx
ui/snippets/navigation/NavigationDesktop.pw.tsx
+116
-0
NavigationDesktop.tsx
ui/snippets/navigation/NavigationDesktop.tsx
+1
-0
NavigationDesktop.pw.tsx_dark-color-mode-desktop-xl_auth-desktop-xl-dark-mode-xl-1.png
...-color-mode-desktop-xl_auth-desktop-xl-dark-mode-xl-1.png
+0
-0
NavigationDesktop.pw.tsx_dark-color-mode-desktop-xl_no-auth-desktop-xl-dark-mode-xl-1.png
...lor-mode-desktop-xl_no-auth-desktop-xl-dark-mode-xl-1.png
+0
-0
NavigationDesktop.pw.tsx_dark-color-mode_auth-desktop-xl-dark-mode-xl-1.png
...pw.tsx_dark-color-mode_auth-desktop-xl-dark-mode-xl-1.png
+0
-0
NavigationDesktop.pw.tsx_dark-color-mode_no-auth-desktop-xl-dark-mode-xl-1.png
...tsx_dark-color-mode_no-auth-desktop-xl-dark-mode-xl-1.png
+0
-0
NavigationDesktop.pw.tsx_default_auth-desktop-xl-dark-mode-xl-1.png
...Desktop.pw.tsx_default_auth-desktop-xl-dark-mode-xl-1.png
+0
-0
NavigationDesktop.pw.tsx_default_no-auth-desktop-xl-dark-mode-xl-1.png
...ktop.pw.tsx_default_no-auth-desktop-xl-dark-mode-xl-1.png
+0
-0
NavigationDesktop.pw.tsx_desktop-xl_auth-desktop-xl-dark-mode-xl-1.png
...ktop.pw.tsx_desktop-xl_auth-desktop-xl-dark-mode-xl-1.png
+0
-0
NavigationDesktop.pw.tsx_desktop-xl_no-auth-desktop-xl-dark-mode-xl-1.png
...p.pw.tsx_desktop-xl_no-auth-desktop-xl-dark-mode-xl-1.png
+0
-0
NavigationDesktop.pw.tsx_desktop-xl_with-tooltips-desktop-xl---default-1.png
...w.tsx_desktop-xl_with-tooltips-desktop-xl---default-1.png
+0
-0
No files found.
playwright/TestApp.tsx
View file @
b324b4e5
...
...
@@ -2,6 +2,8 @@ import { ChakraProvider } from '@chakra-ui/react';
import
{
QueryClient
,
QueryClientProvider
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
{
AppContextProvider
}
from
'
lib/appContext
'
;
import
type
{
Props
as
PageProps
}
from
'
lib/next/getServerSideProps
'
;
import
{
SocketProvider
}
from
'
lib/socket/context
'
;
import
{
PORT
}
from
'
playwright/fixtures/socketServer
'
;
import
theme
from
'
theme
'
;
...
...
@@ -9,9 +11,19 @@ import theme from 'theme';
type
Props
=
{
children
:
React
.
ReactNode
;
withSocket
?:
boolean
;
appContext
?:
{
pageProps
:
PageProps
;
};
}
const
TestApp
=
({
children
,
withSocket
}:
Props
)
=>
{
const
defaultAppContext
=
{
pageProps
:
{
cookies
:
''
,
referrer
:
''
,
},
};
const
TestApp
=
({
children
,
withSocket
,
appContext
=
defaultAppContext
}:
Props
)
=>
{
const
[
queryClient
]
=
React
.
useState
(()
=>
new
QueryClient
({
defaultOptions
:
{
queries
:
{
...
...
@@ -25,7 +37,9 @@ const TestApp = ({ children, withSocket }: Props) => {
<
ChakraProvider
theme=
{
theme
}
>
<
QueryClientProvider
client=
{
queryClient
}
>
<
SocketProvider
url=
{
withSocket
?
`ws://localhost:${ PORT }`
:
undefined
}
>
<
AppContextProvider
{
...
appContext
}
>
{
children
}
</
AppContextProvider
>
</
SocketProvider
>
</
QueryClientProvider
>
</
ChakraProvider
>
...
...
ui/snippets/navigation/NavLink.tsx
View file @
b324b4e5
...
...
@@ -33,6 +33,7 @@ const NavLink = ({ text, url, icon, isCollapsed, isActive, px, isNewUi }: Props)
_hover=
{
{
color
:
isActive
?
colors
.
text
.
active
:
colors
.
text
.
hover
}
}
borderRadius=
"base"
whiteSpace=
"nowrap"
aria
-
label=
{
`${ text } link`
}
{
...
getDefaultTransitionProps
({
transitionProperty
:
'
width
,
padding
'
})
}
>
<
Tooltip
...
...
ui/snippets/navigation/NavigationDesktop.pw.tsx
0 → 100644
View file @
b324b4e5
import
{
Box
,
Flex
}
from
'
@chakra-ui/react
'
;
import
{
test
,
expect
}
from
'
@playwright/experimental-ct-react
'
;
import
React
from
'
react
'
;
import
TestApp
from
'
playwright/TestApp
'
;
import
NavigationDesktop
from
'
./NavigationDesktop
'
;
const
hooksConfig
=
{
router
:
{
route
:
'
/blocks
'
,
query
:
{
id
:
'
0xd789a607CEac2f0E14867de4EB15b15C9FFB5859
'
},
},
};
test
(
'
no auth +@desktop-xl +@dark-mode-xl
'
,
async
({
mount
})
=>
{
const
component
=
await
mount
(
<
TestApp
>
<
Flex
w=
"100%"
minH=
"100vh"
alignItems=
"stretch"
>
<
NavigationDesktop
/>
<
Box
bgColor=
"lightpink"
w=
"100%"
/>
</
Flex
>
</
TestApp
>,
{
hooksConfig
},
);
await
expect
(
component
).
toHaveScreenshot
();
});
test
.
describe
(
'
auth
'
,
()
=>
{
const
extendedTest
=
test
.
extend
({
context
:
({
context
},
use
)
=>
{
context
.
addCookies
([
{
name
:
'
_explorer_key
'
,
value
:
'
foo
'
,
domain
:
'
localhost
'
,
path
:
'
/
'
}
]);
use
(
context
);
},
});
extendedTest
(
'
+@desktop-xl +@dark-mode-xl
'
,
async
({
mount
})
=>
{
const
component
=
await
mount
(
<
TestApp
>
<
Flex
w=
"100%"
minH=
"100vh"
alignItems=
"stretch"
>
<
NavigationDesktop
/>
<
Box
bgColor=
"lightpink"
w=
"100%"
/>
</
Flex
>
</
TestApp
>,
{
hooksConfig
},
);
await
expect
(
component
).
toHaveScreenshot
();
});
});
test
(
'
with tooltips +@desktop-xl -@default
'
,
async
({
mount
,
page
})
=>
{
const
component
=
await
mount
(
<
TestApp
>
<
Flex
w=
"100%"
minH=
"100vh"
alignItems=
"stretch"
>
<
NavigationDesktop
/>
<
Box
bgColor=
"lightpink"
w=
"100%"
/>
</
Flex
>
</
TestApp
>,
{
hooksConfig
},
);
await
page
.
locator
(
'
svg[aria-label="Expand/Collapse menu"]
'
).
click
();
await
page
.
locator
(
'
a[aria-label="Tokens link"]
'
).
hover
();
await
expect
(
component
).
toHaveScreenshot
();
});
test
.
describe
(
'
cookie set to false
'
,
()
=>
{
const
extendedTest
=
test
.
extend
({
context
:
({
context
},
use
)
=>
{
context
.
addCookies
([
{
name
:
'
nav_bar_collapsed
'
,
value
:
'
false
'
,
domain
:
'
localhost
'
,
path
:
'
/
'
}
]);
use
(
context
);
},
});
extendedTest
(
'
navbar is opened +@desktop-xl
'
,
async
({
mount
})
=>
{
const
component
=
await
mount
(
<
TestApp
>
<
Flex
w=
"100%"
minH=
"100vh"
alignItems=
"stretch"
>
<
NavigationDesktop
/>
<
Box
bgColor=
"lightpink"
w=
"100%"
/>
</
Flex
>
</
TestApp
>,
{
hooksConfig
},
);
const
txLink
=
component
.
getByText
(
/transactions/i
);
expect
(
await
txLink
.
isVisible
()).
toBe
(
true
);
});
});
test
.
describe
(
'
cookie set to true
'
,
()
=>
{
const
extendedTest
=
test
.
extend
({
context
:
({
context
},
use
)
=>
{
context
.
addCookies
([
{
name
:
'
nav_bar_collapsed
'
,
value
:
'
true
'
,
domain
:
'
localhost
'
,
path
:
'
/
'
}
]);
use
(
context
);
},
});
extendedTest
(
'
navbar is collapsed +@desktop-xl
'
,
async
({
mount
})
=>
{
const
component
=
await
mount
(
<
TestApp
>
<
Flex
w=
"100%"
minH=
"100vh"
alignItems=
"stretch"
>
<
NavigationDesktop
/>
<
Box
bgColor=
"lightpink"
w=
"100%"
/>
</
Flex
>
</
TestApp
>,
{
hooksConfig
},
);
const
txLink
=
component
.
getByText
(
/transactions/i
);
expect
(
await
txLink
.
isVisible
()).
toBe
(
false
);
});
});
ui/snippets/navigation/NavigationDesktop.tsx
View file @
b324b4e5
...
...
@@ -105,6 +105,7 @@ const NavigationDesktop = () => {
left=
{
{
lg
:
isExpanded
?
'
216px
'
:
'
80px
'
,
xl
:
isCollapsed
?
'
80px
'
:
'
216px
'
}
}
cursor=
"pointer"
onClick=
{
handleTogglerClick
}
aria
-
label=
"Expand/Collapse menu"
/>
</
Flex
>
);
...
...
ui/snippets/navigation/__screenshots__/NavigationDesktop.pw.tsx_dark-color-mode-desktop-xl_auth-desktop-xl-dark-mode-xl-1.png
0 → 100644
View file @
b324b4e5
44.2 KB
ui/snippets/navigation/__screenshots__/NavigationDesktop.pw.tsx_dark-color-mode-desktop-xl_no-auth-desktop-xl-dark-mode-xl-1.png
0 → 100644
View file @
b324b4e5
32.9 KB
ui/snippets/navigation/__screenshots__/NavigationDesktop.pw.tsx_dark-color-mode_auth-desktop-xl-dark-mode-xl-1.png
0 → 100644
View file @
b324b4e5
18.6 KB
ui/snippets/navigation/__screenshots__/NavigationDesktop.pw.tsx_dark-color-mode_no-auth-desktop-xl-dark-mode-xl-1.png
0 → 100644
View file @
b324b4e5
13.6 KB
ui/snippets/navigation/__screenshots__/NavigationDesktop.pw.tsx_default_auth-desktop-xl-dark-mode-xl-1.png
0 → 100644
View file @
b324b4e5
18.5 KB
ui/snippets/navigation/__screenshots__/NavigationDesktop.pw.tsx_default_no-auth-desktop-xl-dark-mode-xl-1.png
0 → 100644
View file @
b324b4e5
13.4 KB
ui/snippets/navigation/__screenshots__/NavigationDesktop.pw.tsx_desktop-xl_auth-desktop-xl-dark-mode-xl-1.png
0 → 100644
View file @
b324b4e5
44.1 KB
ui/snippets/navigation/__screenshots__/NavigationDesktop.pw.tsx_desktop-xl_no-auth-desktop-xl-dark-mode-xl-1.png
0 → 100644
View file @
b324b4e5
32.9 KB
ui/snippets/navigation/__screenshots__/NavigationDesktop.pw.tsx_desktop-xl_with-tooltips-desktop-xl---default-1.png
0 → 100644
View file @
b324b4e5
18 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