forked from matrix-org/matrix-js-sdk
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve typing around event emitter handlers ([\matrix-org#2180](matrix-org#2180)). * Fix defer not supporting resolving with a Promise<T> ([\matrix-org#2216](matrix-org#2216)). * add LocationAssetType enum ([\matrix-org#2214](matrix-org#2214)). * Support for mid-call devices changes ([\matrix-org#2154](matrix-org#2154)). Contributed by @SimonBrandner. * Add new room state emit RoomStateEvent.Update for lower-frequency hits ([\matrix-org#2192](matrix-org#2192)). * Fix wrong event_id being sent for m.in_reply_to of threads ([\matrix-org#2213](matrix-org#2213)). * Fix wrongly asserting that PushRule::conditions is non-null ([\matrix-org#2217](matrix-org#2217)). * Make createThread more resilient when missing rootEvent ([\matrix-org#2207](matrix-org#2207)). Fixes element-hq/element-web#21130. * Fix bug with the /hierarchy API sending invalid requests ([\matrix-org#2201](matrix-org#2201)). Fixes element-hq/element-web#21170. * fix relation sender filter ([\matrix-org#2196](matrix-org#2196)). Fixes element-hq/element-web#20877. * Fix bug with one-way audio after a transfer ([\matrix-org#2193](matrix-org#2193)).
- Loading branch information
Showing
65 changed files
with
2,333 additions
and
1,308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
comment: | ||
layout: "diff, files" | ||
behavior: default | ||
require_changes: false | ||
require_base: no | ||
require_head: no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Test coverage | ||
on: | ||
pull_request: {} | ||
push: | ||
branches: [develop, main, master] | ||
jobs: | ||
test-coverage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run tests with coverage | ||
run: "yarn install && yarn build && yarn coverage" | ||
|
||
- name: Upload coverage | ||
uses: codecov/codecov-action@v2 | ||
with: | ||
verbose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { | ||
RelationType, | ||
UNSTABLE_FILTER_RELATED_BY_REL_TYPES, | ||
UNSTABLE_FILTER_RELATED_BY_SENDERS, | ||
} from "../../src"; | ||
import { FilterComponent } from "../../src/filter-component"; | ||
import { mkEvent } from '../test-utils'; | ||
|
||
describe("Filter Component", function() { | ||
describe("types", function() { | ||
it("should filter out events with other types", function() { | ||
const filter = new FilterComponent({ types: ['m.room.message'] }); | ||
const event = mkEvent({ | ||
type: 'm.room.member', | ||
content: { }, | ||
room: 'roomId', | ||
event: true, | ||
}); | ||
|
||
const checkResult = filter.check(event); | ||
|
||
expect(checkResult).toBe(false); | ||
}); | ||
|
||
it("should validate events with the same type", function() { | ||
const filter = new FilterComponent({ types: ['m.room.message'] }); | ||
const event = mkEvent({ | ||
type: 'm.room.message', | ||
content: { }, | ||
room: 'roomId', | ||
event: true, | ||
}); | ||
|
||
const checkResult = filter.check(event); | ||
|
||
expect(checkResult).toBe(true); | ||
}); | ||
|
||
it("should filter out events by relation participation", function() { | ||
const currentUserId = '@me:server.org'; | ||
const filter = new FilterComponent({ | ||
[UNSTABLE_FILTER_RELATED_BY_SENDERS.name]: [currentUserId], | ||
}, currentUserId); | ||
|
||
const threadRootNotParticipated = mkEvent({ | ||
type: 'm.room.message', | ||
content: {}, | ||
room: 'roomId', | ||
user: '@someone-else:server.org', | ||
event: true, | ||
unsigned: { | ||
"m.relations": { | ||
[RelationType.Thread]: { | ||
count: 2, | ||
current_user_participated: false, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(filter.check(threadRootNotParticipated)).toBe(false); | ||
}); | ||
|
||
it("should keep events by relation participation", function() { | ||
const currentUserId = '@me:server.org'; | ||
const filter = new FilterComponent({ | ||
[UNSTABLE_FILTER_RELATED_BY_SENDERS.name]: [currentUserId], | ||
}, currentUserId); | ||
|
||
const threadRootParticipated = mkEvent({ | ||
type: 'm.room.message', | ||
content: {}, | ||
unsigned: { | ||
"m.relations": { | ||
[RelationType.Thread]: { | ||
count: 2, | ||
current_user_participated: true, | ||
}, | ||
}, | ||
}, | ||
user: '@someone-else:server.org', | ||
room: 'roomId', | ||
event: true, | ||
}); | ||
|
||
expect(filter.check(threadRootParticipated)).toBe(true); | ||
}); | ||
|
||
it("should filter out events by relation type", function() { | ||
const filter = new FilterComponent({ | ||
[UNSTABLE_FILTER_RELATED_BY_REL_TYPES.name]: [RelationType.Thread], | ||
}); | ||
|
||
const referenceRelationEvent = mkEvent({ | ||
type: 'm.room.message', | ||
content: {}, | ||
room: 'roomId', | ||
event: true, | ||
unsigned: { | ||
"m.relations": { | ||
[RelationType.Reference]: {}, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(filter.check(referenceRelationEvent)).toBe(false); | ||
}); | ||
|
||
it("should keep events by relation type", function() { | ||
const filter = new FilterComponent({ | ||
[UNSTABLE_FILTER_RELATED_BY_REL_TYPES.name]: [RelationType.Thread], | ||
}); | ||
|
||
const threadRootEvent = mkEvent({ | ||
type: 'm.room.message', | ||
content: {}, | ||
unsigned: { | ||
"m.relations": { | ||
[RelationType.Thread]: { | ||
count: 2, | ||
current_user_participated: true, | ||
}, | ||
}, | ||
}, | ||
room: 'roomId', | ||
event: true, | ||
}); | ||
|
||
expect(filter.check(threadRootEvent)).toBe(true); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.