Add tests for all room privacy levels
This commit is contained in:
parent
a1710af542
commit
1ad1c6b525
3 changed files with 32 additions and 1 deletions
|
@ -5,7 +5,34 @@ const {kstateStripConditionals} = require("../../matrix/kstate")
|
||||||
const {test} = require("supertape")
|
const {test} = require("supertape")
|
||||||
const testData = require("../../test/data")
|
const testData = require("../../test/data")
|
||||||
|
|
||||||
test("channel2room: general", async t => {
|
const passthrough = require("../../passthrough")
|
||||||
|
const {db} = passthrough
|
||||||
|
|
||||||
|
test("channel2room: discoverable privacy room", async t => {
|
||||||
|
db.prepare("UPDATE guild_space SET privacy_level = 2").run()
|
||||||
|
t.deepEqual(
|
||||||
|
kstateStripConditionals(await channelToKState(testData.channel.general, testData.guild.general).then(x => x.channelKState)),
|
||||||
|
Object.assign({}, testData.room.general, {
|
||||||
|
"m.room.guest_access/": {guest_access: "forbidden"},
|
||||||
|
"m.room.join_rules/": {join_rule: "public"},
|
||||||
|
"m.room.history_visibility/": {history_visibility: "world_readable"}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("channel2room: linkable privacy room", async t => {
|
||||||
|
db.prepare("UPDATE guild_space SET privacy_level = 1").run()
|
||||||
|
t.deepEqual(
|
||||||
|
kstateStripConditionals(await channelToKState(testData.channel.general, testData.guild.general).then(x => x.channelKState)),
|
||||||
|
Object.assign({}, testData.room.general, {
|
||||||
|
"m.room.guest_access/": {guest_access: "forbidden"},
|
||||||
|
"m.room.join_rules/": {join_rule: "public"}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("channel2room: invite-only privacy room", async t => {
|
||||||
|
db.prepare("UPDATE guild_space SET privacy_level = 0").run()
|
||||||
t.deepEqual(
|
t.deepEqual(
|
||||||
kstateStripConditionals(await channelToKState(testData.channel.general, testData.guild.general).then(x => x.channelKState)),
|
kstateStripConditionals(await channelToKState(testData.channel.general, testData.guild.general).then(x => x.channelKState)),
|
||||||
testData.room.general
|
testData.room.general
|
||||||
|
|
|
@ -44,6 +44,9 @@ module.exports = {
|
||||||
"m.room.power_levels/": {
|
"m.room.power_levels/": {
|
||||||
events: {
|
events: {
|
||||||
"m.room.avatar": 0
|
"m.room.avatar": 0
|
||||||
|
},
|
||||||
|
users: {
|
||||||
|
"@test_auto_invite:example.org": 100
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"chat.schildi.hide_ui/read_receipts": {hidden: true},
|
"chat.schildi.hide_ui/read_receipts": {hidden: true},
|
||||||
|
|
|
@ -14,6 +14,7 @@ const db = new sqlite(":memory:")
|
||||||
|
|
||||||
const reg = require("../matrix/read-registration")
|
const reg = require("../matrix/read-registration")
|
||||||
reg.ooye.server_origin = "https://matrix.cadence.moe" // so that tests will pass even when hard-coded
|
reg.ooye.server_origin = "https://matrix.cadence.moe" // so that tests will pass even when hard-coded
|
||||||
|
reg.ooye.invite = ["@test_auto_invite:example.org"]
|
||||||
|
|
||||||
const sync = new HeatSync({watchFS: false})
|
const sync = new HeatSync({watchFS: false})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue