2021-06-09 12:39:38 +01:00
|
|
|
// Copyright (C) 2021 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package uitest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/go-rod/rod"
|
2021-10-14 12:27:03 +01:00
|
|
|
"github.com/spacemonkeygo/monkit/v3"
|
2021-06-09 12:39:38 +01:00
|
|
|
"go.uber.org/zap"
|
|
|
|
|
|
|
|
"storj.io/common/testcontext"
|
|
|
|
"storj.io/storj/private/testplanet"
|
|
|
|
"storj.io/storj/satellite"
|
|
|
|
)
|
|
|
|
|
2021-10-14 12:27:03 +01:00
|
|
|
var mon = monkit.Package()
|
|
|
|
|
2021-06-09 12:39:38 +01:00
|
|
|
// Test defines common services for uitests.
|
|
|
|
type Test func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet, browser *rod.Browser)
|
|
|
|
|
|
|
|
type zapWriter struct {
|
|
|
|
*zap.Logger
|
|
|
|
}
|
|
|
|
|
|
|
|
func (log zapWriter) Write(data []byte) (int, error) {
|
|
|
|
log.Logger.Info(string(data))
|
|
|
|
return len(data), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run starts a new UI test.
|
|
|
|
func Run(t *testing.T, test Test) {
|
|
|
|
testplanet.Run(t, testplanet.Config{
|
|
|
|
SatelliteCount: 1, StorageNodeCount: 4, UplinkCount: 1,
|
|
|
|
Reconfigure: testplanet.Reconfigure{
|
|
|
|
Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
|
2021-09-22 10:20:03 +01:00
|
|
|
if dir := os.Getenv("STORJ_TEST_SATELLITE_WEB"); dir != "" {
|
|
|
|
config.Console.StaticDir = dir
|
|
|
|
}
|
|
|
|
config.Console.NewOnboarding = true
|
2021-10-21 17:21:37 +01:00
|
|
|
config.Console.NewNavigation = true
|
2021-09-21 19:52:52 +01:00
|
|
|
config.Console.NewBrowser = true
|
2021-10-18 22:06:31 +01:00
|
|
|
config.Console.CouponCodeBillingUIEnabled = true
|
2021-11-02 17:04:30 +00:00
|
|
|
config.Console.NewObjectsFlow = true
|
2021-06-09 12:39:38 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
2021-11-12 11:02:55 +00:00
|
|
|
Browser(t, ctx, planet, func(browser *rod.Browser) {
|
2021-10-12 14:20:23 +01:00
|
|
|
test(t, ctx, planet, browser)
|
|
|
|
})
|
2021-06-09 12:39:38 +01:00
|
|
|
})
|
|
|
|
}
|