view mrjunejune/test/BUILD @ 264:04fee26ecce0

add authenticated JRPG conversation platform Add reusable auth/session storage, owned conversation recovery, guest quotas, admin workflows, URL-routed conversation UI, mobile frame support, and parallel browser acceptance. Co-authored-by: Copilot <[email protected]>
author MrJuneJune <me@mrjunejune.com>
date Fri, 07 Aug 2026 07:34:12 -0700
parents ee04e4e69fed
children 056790c4fb0d
line wrap: on
line source

load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_test.bzl", "cc_test")
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("//gui_ze:gui_ze.bzl", "move_files_into_dir", "bundle")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

# Files needed for test
filegroup(
  name = "test_snapshots",
  srcs = glob(["snapshots/**"]),
)

filegroup(
  name = "test_files",
  srcs = [
    "shiba.webp",
    "test_avi.avi",
  ],
)

# To create a snapsho to compare
cc_binary(
  name = "create_snapshots",
  srcs = ["auto_generated_test.c", "test.h"],
  deps = ["//seobeo:seobeo_tcp_client"],
  data = [
    "//mrjunejune:mrjunejune_server",
    "//mrjunejune:src_files",
  ],
  args = ["$(location //mrjunejune:mrjunejune_server)"],
)

# Tests
cc_test(
  name = "integration_test",
  srcs = [
    "integration_test.c",
    "test.h"
  ],
  deps = ["//seobeo:seobeo"],
  data = [
    "//mrjunejune:mrjunejune_server",
    "//mrjunejune:src_files",
    ":test_snapshots",
    ":test_files",
  ],
  size = "large",
  timeout = "long",
  args = ["$(location //mrjunejune:mrjunejune_server)"],
  env = {
    "AUTH_COOKIE_SECRET": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "AUTH_DEV_INSECURE_COOKIE": "true",
    "SERVER_HOST": "127.0.0.1",
  },
)

cc_test(
  name = "latex_renderer_test",
  srcs = ["latex_renderer_test.c"],
  deps = ["//mrjunejune:latex_renderer"],
  size = "medium",
  timeout = "moderate",
  target_compatible_with = ["@platforms//os:linux"],
)

cc_test(
  name = "conversation_store_test",
  srcs = ["conversation_store_test.c"],
  deps = [
    "//mrjunejune:conversation_store",
    "//deita:deita",
  ],
  size = "small",
)

cc_binary(
  name = "inference_bridge_fake_sidecar",
  srcs = ["inference_bridge_fake_sidecar.c"],
  deps = ["//dowa:dowa"],
)

cc_test(
  name = "inference_bridge_test",
  srcs = ["inference_bridge_test.c"],
  args = ["$(location :inference_bridge_fake_sidecar)"],
  data = [":inference_bridge_fake_sidecar"],
  deps = ["//mrjunejune:inference_bridge"],
  size = "small",
)

js_test(
  name = "hls_player_test",
  entry_point = "hls_player_test.js",
  data = ["//mrjunejune:hls_player_js"],
  size = "small",
  timeout = "short",
)

js_test(
  name = "latex_editor_test",
  entry_point = "latex_editor_test.js",
  data = [
    "//hg-web/e2e:node_modules/playwright-core",
    "//mrjunejune:mrjunejune_server",
    "@playwright_chromium_linux//:chrome",
    "@playwright_chromium_linux//:chromium",
  ],
  env = {
    "AUTH_COOKIE_SECRET": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "AUTH_DEV_INSECURE_COOKIE": "true",
    "SERVER_HOST": "127.0.0.1",
    "CHROMIUM_PATH": "$(rootpath @playwright_chromium_linux//:chrome)",
  },
  no_copy_to_bin = ["@playwright_chromium_linux//:chromium"],
  size = "large",
  target_compatible_with = [
    "@platforms//cpu:x86_64",
    "@platforms//os:linux",
  ],
  timeout = "long",
)

sh_test(
  name = "production_inference_bundle_test",
  srcs = ["production_inference_bundle_test.sh"],
  args = ["$(rootpath //mrjunejune:mrjunejune_server_bundle)"],
  data = ["//mrjunejune:mrjunejune_server_bundle"],
  size = "small",
)

sh_test(
  name = "production_bundle_exclusion_test",
  srcs = ["production_bundle_exclusion_test.sh"],
  args = ["$(rootpath //mrjunejune:mrjunejune_server_bundle)"],
  data = ["//mrjunejune:mrjunejune_server_bundle"],
  size = "small",
)

sh_test(
  name = "config_validation_test",
  srcs = ["config_validation_test.sh"],
  args = ["$(rootpath //mrjunejune:mrjunejune_server)"],
  data = ["//mrjunejune:mrjunejune_server"],
  size = "medium",
  timeout = "moderate",
)

_JRPG_BROWSER_DATA = [
  "//hg-web/e2e:node_modules/playwright-core",
  "//mrjunejune:mrjunejune_server_debug",
  ":inference_bridge_fake_sidecar",
  "shiba.webp",
  "@playwright_chromium_linux//:chrome",
  "@playwright_chromium_linux//:chromium",
]

_JRPG_BROWSER_ENV = {
  "AUTH_COOKIE_SECRET": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
  "AUTH_DEV_INSECURE_COOKIE": "true",
  "SERVER_HOST": "127.0.0.1",
  "CHROMIUM_PATH": "$(rootpath @playwright_chromium_linux//:chrome)",
}

[
  js_test(
    name = "jrpg_{}_test".format(suite),
    entry_point = "theme_and_webp_test.js",
    data = _JRPG_BROWSER_DATA,
    env = dict(_JRPG_BROWSER_ENV, MJJ_BROWSER_SUITE = suite),
    no_copy_to_bin = ["@playwright_chromium_linux//:chromium"],
    size = "large",
    target_compatible_with = [
      "@platforms//cpu:x86_64",
      "@platforms//os:linux",
    ],
    timeout = "long",
  )
  for suite in [
    "core",
    "jrpg",
    "routing",
    "hls",
  ]
]

test_suite(
  name = "theme_and_webp_test",
  tests = [
    ":jrpg_core_test",
    ":jrpg_hls_test",
    ":jrpg_jrpg_test",
    ":jrpg_routing_test",
  ],
)

js_test(
  name = "conversation_api_test",
  entry_point = "conversation_api_test.js",
  data = [
    "//mrjunejune:mrjunejune_server",
    ":inference_bridge_fake_sidecar",
  ],
  env = {
    "AUTH_COOKIE_SECRET": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "AUTH_DEV_INSECURE_COOKIE": "true",
    "SERVER_HOST": "127.0.0.1",
  },
  size = "large",
  timeout = "long",
)

cc_test(
  name = "template_renderer_test",
  srcs = ["template_renderer_test.c"],
  deps = [
    "//mrjunejune:template_renderer",
    "//dowa:dowa",
  ],
  data = ["//mrjunejune:html_src_files"],
  size = "small",
  timeout = "short",
)

cc_test(
  name = "auth_api_test",
  srcs = ["auth_api_test.c"],
  copts = ["-DAUTH_API_TEST_HOOKS"],
  deps = [
    "//mrjunejune:auth_api_with_test_hooks",
    "//auth:auth_crypto",
    "//auth:auth_store",
    "//dowa:dowa",
    "//seobeo:seobeo",
    "@openssl//:crypto",
  ],
  data = ["//mrjunejune:html_src_files"],
  size = "medium",
  timeout = "moderate",
)

cc_test(
  name = "admin_api_test",
  srcs = ["admin_api_test.c"],
  copts = [
    "-DAUTH_API_TEST_HOOKS",
    "-DADMIN_API_TEST_HOOKS",
  ],
  deps = [
    "//mrjunejune:admin_api_with_test_hooks",
    "//auth:auth_crypto",
    "//auth:auth_store",
    "//deita:deita",
    "//dowa:dowa",
    "//seobeo:seobeo",
    "@openssl//:crypto",
  ],
  data = ["//mrjunejune:html_src_files"],
  size = "medium",
  timeout = "moderate",
)