Test setup for new web pages

This commit is contained in:
Cadence Ember 2025-02-04 17:23:46 +13:00
parent fa8ce28f88
commit f7e2c89e65
10 changed files with 233 additions and 37 deletions

View file

@ -18,6 +18,20 @@ module.exports = {
id: "112760669178241024",
default_thread_rate_limit_per_user: 0,
guild_id: "112760669178241024"
},
saving_the_world: {
type: 0,
topic: "Anything and everything archiving/preservation related",
rate_limit_per_user: 0,
position: 0,
permission_overwrites: [],
parent_id: "665289423482519566",
name: "saving-the-world",
last_pin_timestamp: "2021-04-14T18:39:41+00:00",
last_message_id: "1335828749479837750",
id: "665310973967597573",
flags: 0,
guild_id: "665289423482519565"
}
},
room: {
@ -252,6 +266,111 @@ module.exports = {
nsfw: false,
safety_alerts_channel_id: null,
lazy: true
},
data_horde: {
preferred_locale: "en-US",
afk_channel_id: null,
profile: null,
owner_id: "222343226990788609",
soundboard_sounds: [],
hub_type: null,
mfa_level: 0,
activity_instances: [],
inventory_settings: null,
voice_states: [],
system_channel_id: "675397790204952636",
id: "665289423482519565",
member_count: 138,
clan: null,
default_message_notifications: 1,
name: "Data Horde",
banner: null,
premium_subscription_count: 0,
max_stage_video_channel_users: 50,
max_members: 500000,
incidents_data: null,
joined_at: "2020-05-10T02:00:10.646000+00:00",
unavailable: false,
discovery_splash: null,
threads: [],
system_channel_flags: 0,
safety_alerts_channel_id: null,
nsfw: false,
nsfw_level: 0,
stage_instances: [],
large: false,
icon: "d7c4bdb35c10f21e475a50fb205d5c32",
roles: [
{
version: 1683238686112,
unicode_emoji: null,
tags: {},
position: 0,
permissions: "2221982107557441",
name: "@everyone",
mentionable: false,
managed: false,
id: "665289423482519565",
icon: null,
hoist: false,
flags: 0,
color: 0
},
{
version: 1683791258594,
unicode_emoji: null,
tags: {},
position: 22,
permissions: "7515668211",
name: "Founder",
mentionable: true,
managed: false,
id: "665290147377578005",
icon: null,
hoist: false,
flags: 0,
color: 1752220
},
{
version: 1683791258580,
unicode_emoji: null,
tags: {},
position: 19,
permissions: "6546775617",
name: "Gaming Alexandria",
mentionable: false,
managed: false,
id: "684524730274807911",
icon: null,
hoist: false,
flags: 0,
color: 15844367
}
],
description: null,
afk_timeout: 300,
verification_level: 1,
latest_onboarding_question_id: null,
guild_scheduled_events: [],
rules_channel_id: null,
embedded_activities: [],
region: "deprecated",
vanity_url_code: null,
application_id: null,
premium_tier: 0,
explicit_content_filter: 0,
stickers: [],
public_updates_channel_id: null,
splash: null,
premium_progress_bar_enabled: false,
features: [],
lazy: true,
max_video_channel_users: 25,
application_command_counts: {},
home_header: null,
version: 1717720047590,
emojis: [],
presences: []
}
},
user: {

View file

@ -1,7 +1,9 @@
BEGIN TRANSACTION;
INSERT INTO guild_active (guild_id, autocreate) VALUES
('112760669178241024', 1);
('112760669178241024', 1),
('66192955777486848', 1),
('665289423482519565', 0);
INSERT INTO guild_space (guild_id, space_id, privacy_level) VALUES
('112760669178241024', '!jjWAGMeQdNrVZSSfvz:cadence.moe', 0);
@ -171,4 +173,9 @@ INSERT INTO media_proxy (permitted_hash) VALUES
(-429802515645771439),
(4558604729745184757);
INSERT INTO invite (mxid, room_id, type, name, avatar, topic) VALUES
('@cadence:cadence.moe', '!zTMspHVUBhFLLSdmnS:cadence.moe', 'm.space', 'Data Horde', 'mxc://cadence.moe/TLqQOsTSrZkVKwBSWYTZNTrw', 'here is the space topic'),
('@cadence:cadence.moe', '!room:cadence.moe', NULL, 'some room', NULL, NULL),
('@rnl:cadence.moe', '!space:cadence.moe', NULL, 'somebody else''s space', NULL, NULL);
COMMIT;

View file

@ -6,7 +6,7 @@ const stp = require("stream").promises
const sqlite = require("better-sqlite3")
const migrate = require("../src/db/migrate")
const HeatSync = require("heatsync")
const {test} = require("supertape")
const {test, extend} = require("supertape")
const data = require("./data")
/** @type {import("node-fetch").default} */
// @ts-ignore
@ -31,10 +31,12 @@ const discord = {
guilds: new Map([
[data.guild.general.id, data.guild.general],
[data.guild.fna.id, data.guild.fna],
[data.guild.data_horde.id, data.guild.data_horde]
]),
guildChannelMap: new Map([
[data.guild.general.id, [data.channel.general.id]],
[data.guild.fna.id, []],
[data.guild.data_horde.id, [data.channel.saving_the_world.id]]
]),
application: {
id: "684280192553844747"
@ -47,7 +49,8 @@ const discord = {
["498323546729086986", {
guild_id: "497159726455455754",
name: "bad-boots-prison"
}]
}],
[data.channel.saving_the_world.id, data.channel.saving_the_world]
])
}

View file

@ -2,6 +2,35 @@ const passthrough = require("../src/passthrough")
const h3 = require("h3")
const http = require("http")
const {SnowTransfer} = require("snowtransfer")
const assert = require("assert").strict
const domino = require("domino")
const {extend} = require("supertape")
/**
* @param {string} html
*/
function getContent(html) {
const doc = domino.createDocument(html)
doc.querySelectorAll("svg").cache.forEach(e => e.remove())
const content = doc.getElementById("content")
assert(content)
return content.innerHTML.trim()
}
const test = extend({
has: operator => /** @param {string | RegExp} expected */ (html, expected, message = "should have substring in html content") => {
const content = getContent(html)
const is = expected instanceof RegExp ? content.match(expected) : content.includes(expected)
const {output, result} = operator.equal(content, expected.toString())
return {
expected: expected.toString(),
message,
is,
result: result,
output: output
}
}
})
class Router {
constructor() {
@ -67,3 +96,4 @@ const router = new Router()
passthrough.as = {router}
module.exports.router = router
module.exports.test = test