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
8bcc9ad9
Commit
8bcc9ad9
authored
Dec 02, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reassign envs in pw tests
parent
4032c901
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
6 deletions
+78
-6
.env.pw
configs/envs/.env.pw
+2
-0
contextWithEnvs.ts
playwright/fixtures/contextWithEnvs.ts
+23
-0
socketServer.ts
playwright/fixtures/socketServer.ts
+2
-4
make-envs-script.sh
playwright/make-envs-script.sh
+1
-1
Stats.pw.tsx
ui/home/Stats.pw.tsx
+50
-1
Stats.pw.tsx_mobile_3-items-default-view-mobile---default-1.png
...pw.tsx_mobile_3-items-default-view-mobile---default-1.png
+0
-0
Stats.pw.tsx_mobile_4-items-default-view-mobile---default-1.png
...pw.tsx_mobile_4-items-default-view-mobile---default-1.png
+0
-0
No files found.
configs/envs/.env.pw
View file @
8bcc9ad9
...
@@ -9,6 +9,8 @@ NEXT_PUBLIC_APP_ENV=testing
...
@@ -9,6 +9,8 @@ NEXT_PUBLIC_APP_ENV=testing
NEXT_PUBLIC_BLOCKSCOUT_VERSION=v4.1.7-beta
NEXT_PUBLIC_BLOCKSCOUT_VERSION=v4.1.7-beta
NEXT_PUBLIC_FOOTER_GITHUB_LINK=https://github.com/blockscout/blockscout
NEXT_PUBLIC_FOOTER_GITHUB_LINK=https://github.com/blockscout/blockscout
NEXT_PUBLIC_FOOTER_TWITTER_LINK=https://www.twitter.com/blockscoutcom
NEXT_PUBLIC_FOOTER_TWITTER_LINK=https://www.twitter.com/blockscoutcom
NEXT_PUBLIC_HOMEPAGE_SHOW_AVG_BLOCK_TIME=true
NEXT_PUBLIC_HOMEPAGE_SHOW_GAS_TRACKER=true
# api config
# api config
NEXT_PUBLIC_API_HOST=blockscout.com
NEXT_PUBLIC_API_HOST=blockscout.com
playwright/fixtures/contextWithEnvs.ts
0 → 100644
View file @
8bcc9ad9
import
type
{
test
}
from
'
@playwright/experimental-ct-react
'
;
interface
Env
{
name
:
string
;
value
:
string
;
}
// keep in mind that all passed variables here should be present in env config files (.env.pw or .env.poa)
export
default
function
createContextWithEnvs
(
envs
:
Array
<
Env
>
):
Parameters
<
typeof
test
.
extend
>
[
0
][
'
context
'
]
{
return
async
({
browser
},
use
)
=>
{
const
context
=
await
browser
.
newContext
({
storageState
:
{
origins
:
[
{
origin
:
'
http://localhost:3100
'
,
localStorage
:
envs
},
],
cookies
:
[],
},
});
await
use
(
context
);
await
context
.
close
();
};
}
playwright/fixtures/socketServer.ts
View file @
8bcc9ad9
import
type
{
TestFixture
}
from
'
@playwright/test
'
;
import
type
{
TestFixture
,
Page
}
from
'
@playwright/test
'
;
import
type
{
WebSocket
}
from
'
ws
'
;
import
type
{
WebSocket
}
from
'
ws
'
;
import
{
WebSocketServer
}
from
'
ws
'
;
import
{
WebSocketServer
}
from
'
ws
'
;
import
type
{
NewBlockSocketResponse
}
from
'
types/api/block
'
;
import
type
{
NewBlockSocketResponse
}
from
'
types/api/block
'
;
type
ReturnType
=
()
=>
Promise
<
WebSocket
>
;
type
ReturnType
=
()
=>
Promise
<
WebSocket
>
;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type
ArgsType
=
any
;
type
Channel
=
[
string
,
string
,
string
];
type
Channel
=
[
string
,
string
,
string
];
...
@@ -17,7 +15,7 @@ export interface SocketServerFixture {
...
@@ -17,7 +15,7 @@ export interface SocketServerFixture {
export
const
PORT
=
3200
;
export
const
PORT
=
3200
;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export
const
createSocket
:
TestFixture
<
ReturnType
,
ArgsType
>
=
async
({
page
},
use
)
=>
{
export
const
createSocket
:
TestFixture
<
ReturnType
,
{
page
:
Page
}
>
=
async
({
page
},
use
)
=>
{
const
socketServer
=
new
WebSocketServer
({
port
:
PORT
});
const
socketServer
=
new
WebSocketServer
({
port
:
PORT
});
const
connectionPromise
=
new
Promise
<
WebSocket
>
((
resolve
)
=>
{
const
connectionPromise
=
new
Promise
<
WebSocket
>
((
resolve
)
=>
{
...
...
playwright/make-envs-script.sh
View file @
8bcc9ad9
...
@@ -27,7 +27,7 @@ do
...
@@ -27,7 +27,7 @@ do
# if there is a value, escape it and add line to target file
# if there is a value, escape it and add line to target file
if
[
-n
"
$configValue
"
]
;
then
if
[
-n
"
$configValue
"
]
;
then
escapedConfigValue
=
$(
echo
$configValue
|
sed
s/
\'
/
\"
/g
)
;
escapedConfigValue
=
$(
echo
$configValue
|
sed
s/
\'
/
\"
/g
)
;
echo
"window.process.env.
${
configName
}
= '
${
escapedConfigValue
}
';"
>>
$targetFile
;
echo
"window.process.env.
${
configName
}
=
localStorage.getItem('
${
configName
}
') ||
'
${
escapedConfigValue
}
';"
>>
$targetFile
;
fi
fi
done
<
$envFile
done
<
$envFile
done
done
...
...
ui/home/Stats.pw.tsx
View file @
8bcc9ad9
...
@@ -2,6 +2,7 @@ import { test, expect } from '@playwright/experimental-ct-react';
...
@@ -2,6 +2,7 @@ import { test, expect } from '@playwright/experimental-ct-react';
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
*
as
statsMock
from
'
mocks/stats/index
'
;
import
*
as
statsMock
from
'
mocks/stats/index
'
;
import
contextWithEnvs
from
'
playwright/fixtures/contextWithEnvs
'
;
import
TestApp
from
'
playwright/TestApp
'
;
import
TestApp
from
'
playwright/TestApp
'
;
import
Stats
from
'
./Stats
'
;
import
Stats
from
'
./Stats
'
;
...
@@ -19,7 +20,55 @@ test('all items +@mobile +@dark-mode +@desktop-xl', async({ mount, page }) => {
...
@@ -19,7 +20,55 @@ test('all items +@mobile +@dark-mode +@desktop-xl', async({ mount, page }) => {
<
Stats
/>
<
Stats
/>
</
TestApp
>,
</
TestApp
>,
);
);
await
page
.
waitForResponse
(
API_URL
),
await
expect
(
component
).
toHaveScreenshot
();
await
expect
(
component
).
toHaveScreenshot
();
});
});
test
.
describe
(
'
4 items
'
,
()
=>
{
const
extendedTest
=
test
.
extend
({
context
:
contextWithEnvs
([
{
name
:
'
NEXT_PUBLIC_HOMEPAGE_SHOW_AVG_BLOCK_TIME
'
,
value
:
'
false
'
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
])
as
any
,
});
extendedTest
(
'
default view +@mobile -@default
'
,
async
({
mount
,
page
})
=>
{
await
page
.
route
(
API_URL
,
(
route
)
=>
route
.
fulfill
({
status
:
200
,
body
:
JSON
.
stringify
(
statsMock
.
base
),
}));
const
component
=
await
mount
(
<
TestApp
>
<
Stats
/>
</
TestApp
>,
);
await
expect
(
component
).
toHaveScreenshot
();
});
});
test
.
describe
(
'
3 items
'
,
()
=>
{
const
extendedTest
=
test
.
extend
({
context
:
contextWithEnvs
([
{
name
:
'
NEXT_PUBLIC_HOMEPAGE_SHOW_AVG_BLOCK_TIME
'
,
value
:
'
false
'
},
{
name
:
'
NEXT_PUBLIC_HOMEPAGE_SHOW_GAS_TRACKER
'
,
value
:
'
false
'
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
])
as
any
,
});
extendedTest
(
'
default view +@mobile -@default
'
,
async
({
mount
,
page
})
=>
{
await
page
.
route
(
API_URL
,
(
route
)
=>
route
.
fulfill
({
status
:
200
,
body
:
JSON
.
stringify
(
statsMock
.
base
),
}));
const
component
=
await
mount
(
<
TestApp
>
<
Stats
/>
</
TestApp
>,
);
await
expect
(
component
).
toHaveScreenshot
();
});
});
ui/home/__screenshots__/Stats.pw.tsx_mobile_3-items-default-view-mobile---default-1.png
0 → 100644
View file @
8bcc9ad9
8.89 KB
ui/home/__screenshots__/Stats.pw.tsx_mobile_4-items-default-view-mobile---default-1.png
0 → 100644
View file @
8bcc9ad9
11.3 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