chore: add jest tests, cleanup rpc

This commit is contained in:
41666 2020-10-11 15:10:20 -04:00
parent 5977c35d38
commit ac830fc946
25 changed files with 2786 additions and 319 deletions

View file

@ -1,4 +1,5 @@
load("//:hack/react.bzl", "react_library")
load("//:hack/jest.bzl", "jest_test")
package(default_visibility = ["//visibility:public"])
@ -14,3 +15,7 @@ react_library(
"@types/styled-components",
],
)
jest_test(
src = ":button",
)

View file

@ -1,4 +1,5 @@
load("//:hack/react.bzl", "react_library")
load("//:hack/jest.bzl", "jest_test")
package(default_visibility = ["//visibility:public"])
@ -17,3 +18,8 @@ react_library(
"@types/styled-components",
],
)
jest_test(
src = ":role",
deps = ["//hack/fixtures"],
)

View file

@ -1,5 +1,5 @@
import { shallow } from 'enzyme';
import { roleCategory } from 'hack/fixtures/storyData';
import { roleCategory } from 'roleypoly/hack/fixtures/storyData';
import * as React from 'react';
import { Role } from './Role';

View file

@ -6,10 +6,8 @@ import { TabTitle, TabContent } from './TabView.styled';
const makeView = (props: Partial<TabViewProps> = {}) =>
shallow(
<TabView {...props}>
{{
'Tab 1': <Tab>{() => <div>tab 1</div>}</Tab>,
'Tab 2': <Tab>{() => <div>tab 2</div>}</Tab>,
}}
<Tab title="Tab 1">{() => <div>tab 1</div>}</Tab>
<Tab title="Tab 2">{() => <div>tab 2</div>}</Tab>,
</TabView>
);
@ -20,13 +18,13 @@ it('renders tab content correctly', () => {
});
it('automatically picks preselected tab content', () => {
const view = makeView({ initialTab: 'Tab 2' });
const view = makeView({ initialTab: 1 });
expect(view.find(Tab).renderProp('children')().text()).toBe('tab 2');
});
it('automatically uses the first tab when preselected tab is not present', () => {
const view = makeView({ initialTab: 'Not a Tab' });
const view = makeView({ initialTab: -1 });
view.find(TabContent).find('i').simulate('load');
expect(view.find(Tab).renderProp('children')().text()).toBe('tab 1');

View file

@ -1,4 +1,5 @@
load("//:hack/react.bzl", "react_library")
load("//:hack/jest.bzl", "jest_test")
package(default_visibility = ["//visibility:public"])
@ -9,3 +10,7 @@ react_library(
"@types/react",
],
)
jest_test(
src = ":timings",
)

View file

@ -1,28 +0,0 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("//:hack/tsproto.bzl", "ts_proto")
proto_library(
name = "auth_proto",
srcs = ["shared.proto"],
visibility = ["//visibility:public"],
)
go_proto_library(
name = "auth_go_proto",
importpath = "github.com/roleypoly/roleypoly/src/rpc/auth",
proto = ":auth_proto",
visibility = ["//visibility:public"],
)
go_library(
name = "auth",
embed = [":auth_go_proto"],
importpath = "github.com/roleypoly/roleypoly/src/rpc/auth",
visibility = ["//visibility:public"],
)
ts_proto(
proto = ":auth_proto",
)

View file

@ -1,37 +0,0 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("//:hack/tsproto.bzl", "ts_proto")
proto_library(
name = "backend_proto",
srcs = ["auth-backend.proto"],
visibility = ["//visibility:public"],
deps = [
"//src/rpc/auth:auth_proto",
"//src/rpc/shared:shared_proto",
],
)
go_proto_library(
name = "backend_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
importpath = "github.com/roleypoly/roleypoly/src/rpc/auth/backend",
proto = ":backend_proto",
visibility = ["//visibility:public"],
deps = [
"//src/rpc/auth",
"//src/rpc/shared",
],
)
go_library(
name = "backend",
embed = [":backend_go_proto"],
importpath = "github.com/roleypoly/roleypoly/src/rpc/auth/backend",
visibility = ["//visibility:public"],
)
ts_proto(
proto = ":backend_proto",
)

View file

@ -1,13 +0,0 @@
syntax = "proto3";
package roleypoly.auth.backend;
option go_package = "github.com/roleypoly/roleypoly/src/rpc/auth/backend";
import "src/rpc/shared/internal.proto";
import "src/rpc/shared/shared.proto";
import "src/rpc/auth/shared.proto";
service AuthBackend {
rpc GetNewAuthChallenge(roleypoly.IDQuery) returns (roleypoly.auth.AuthChallenge) {}
rpc GetSession(roleypoly.auth.Token) returns (roleypoly.RoleypolySession) {}
}

View file

@ -1,37 +0,0 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("//:hack/tsproto.bzl", "ts_proto")
proto_library(
name = "client_proto",
srcs = ["auth-client.proto"],
visibility = ["//visibility:public"],
deps = [
"//src/rpc/auth:auth_proto",
"//src/rpc/shared:shared_proto",
],
)
go_proto_library(
name = "client_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
importpath = "github.com/roleypoly/roleypoly/src/auth/client",
proto = ":client_proto",
visibility = ["//visibility:public"],
deps = [
"//src/rpc/auth",
"//src/rpc/shared",
],
)
go_library(
name = "client",
embed = [":client_go_proto"],
importpath = "github.com/roleypoly/roleypoly/src/auth/client",
visibility = ["//visibility:public"],
)
ts_proto(
proto = ":client_proto",
)

View file

@ -1,15 +0,0 @@
syntax = "proto3";
package roleypoly.auth.client;
option go_package = "github.com/roleypoly/roleypoly/src/auth/client";
import "src/rpc/shared/internal.proto";
import "src/rpc/shared/shared.proto";
import "src/rpc/auth/shared.proto";
service AuthClient {
rpc GetClientToken(roleypoly.Empty) returns (roleypoly.auth.Token) {}
rpc GetUserSession(roleypoly.Empty) returns (roleypoly.RoleypolySession) {}
rpc ResolveSessionKey(roleypoly.auth.Token) returns (roleypoly.auth.Token) {}
rpc AuthorizeChallenge(roleypoly.auth.AuthChallenge) returns (roleypoly.auth.Token) {}
}

View file

@ -1,22 +0,0 @@
syntax = "proto3";
package roleypoly.auth;
option go_package = "github.com/roleypoly/roleypoly/src/rpc/auth";
message Token {
string token = 1;
Type type = 2;
string state = 3;
enum Type {
unknown = 0;
sessionKey = 1;
clientToken = 2;
}
}
message AuthChallenge {
string userID = 1;
string magicUrl = 2;
string magicWords = 3;
}

View file

@ -1,31 +0,0 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("//:hack/tsproto.bzl", "ts_proto")
proto_library(
name = "ctf_proto",
srcs = ["ctf.proto"],
visibility = ["//visibility:public"],
deps = ["//src/rpc/shared:shared_proto"],
)
go_proto_library(
name = "ctf_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
importpath = "github.com/roleypoly/roleypoly/src/rpc/ctf",
proto = ":ctf_proto",
visibility = ["//visibility:public"],
deps = ["//src/rpc/shared"],
)
go_library(
name = "ctf",
embed = [":ctf_go_proto"],
importpath = "github.com/roleypoly/roleypoly/src/rpc/ctf",
visibility = ["//visibility:public"],
)
ts_proto(
proto = ":ctf_proto",
)

View file

@ -1,26 +0,0 @@
syntax = "proto3";
package roleypoly.ctf;
option go_package = "github.com/roleypoly/roleypoly/src/rpc/ctf";
import "src/rpc/shared/shared.proto";
service CTF {
rpc GetRingFlags (Ring) returns (Flags) {}
rpc CreateFlag (Flag) returns (Flag) {}
rpc PromoteFlag (Flag) returns (Flag) {}
rpc RemoveFlag (Flag) returns (roleypoly.Empty) {}
}
message Flags {
repeated Flag flags = 1;
}
message Flag {
string name = 1;
int32 ring = 2;
}
message Ring {
int32 ring = 1;
}

View file

@ -31,5 +31,6 @@ go_library(
)
ts_proto(
grpc = True,
proto = ":discord_proto",
)

View file

@ -33,5 +33,6 @@ go_library(
)
ts_proto(
grpc = True,
proto = ":platform_proto",
)

View file

@ -3,11 +3,6 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("//:hack/tsproto.bzl", "ts_proto")
package(default_visibility = [
"//hack/fixtures:__subpackages__",
"//src/design-system/atoms/role:__subpackages__",
])
proto_library(
name = "shared_proto",
srcs = [