hookshot/tests/connections/GitlabRepoTest.ts

361 lines
10 KiB
TypeScript
Raw Normal View History

import { createMessageQueue } from "../../src/MessageQueue";
import { UserTokenStore } from "../../src/tokens/UserTokenStore";
import { AppserviceMock } from "../utils/AppserviceMock";
import { ApiError, ErrCode, ValidatorApiError } from "../../src/api";
import { GitLabRepoConnection, GitLabRepoConnectionState } from "../../src/Connections";
import { expect } from "chai";
import { BridgeConfigGitLab } from "../../src/config/Config";
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
import { IBridgeStorageProvider } from "../../src/Stores/StorageProvider";
import { IntentMock } from "../utils/IntentMock";
import { IGitlabMergeRequest, IGitlabProject, IGitlabUser, IGitLabWebhookNoteEvent } from "../../src/Gitlab/WebhookTypes";
const ROOM_ID = "!foo:bar";
const GITLAB_ORG_REPO = {
org: "a-fake-org",
repo: "a-fake-repo",
};
const GITLAB_MR: IGitlabMergeRequest = {
author_id: 0,
labels: [],
state: "opened",
iid: 1234,
url: `https://gitlab.example.com/${GITLAB_ORG_REPO.org}/${GITLAB_ORG_REPO.repo}/issues/1234`,
title: "My MR",
};
const GITLAB_USER: IGitlabUser = {
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
name: "Alice",
username: "alice",
avatar_url: "",
email: "alice@example.org"
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
};
const GITLAB_PROJECT: IGitlabProject = {
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
path_with_namespace: `${GITLAB_ORG_REPO.org}/${GITLAB_ORG_REPO.repo}`,
web_url: `https://gitlab.example.com/${GITLAB_ORG_REPO.org}/${GITLAB_ORG_REPO.repo}`,
homepage: "",
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
};
const GITLAB_ISSUE_CREATED_PAYLOAD = {
object_kind: "merge_request",
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
user: GITLAB_USER,
object_attributes: GITLAB_MR,
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
project: GITLAB_PROJECT,
};
const GITLAB_MR_COMMENT: IGitLabWebhookNoteEvent = {
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
'object_kind': 'note',
'event_type': 'note',
'merge_request': GITLAB_MR,
'object_attributes': {
'discussion_id': '6babfc4ad3be2355db286ed50be111a5220d5751',
'note': 'I am starting a new thread',
'noteable_type': 'MergeRequest',
'url': 'https://gitlab.com/tadeuszs/my-awesome-project/-/merge_requests/2#note_1455087141',
'id': 1455087141,
'author_id': 12345,
'noteable_id': 1,
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
},
'project': GITLAB_PROJECT,
'user': GITLAB_USER,
repository: {
'description': 'A repo',
'homepage': 'https://gitlab.com/tadeuszs/my-awesome-project',
'name': 'a-repo',
'url': 'https://gitlab.com/tadeuszs/my-awesome-project'
},
};
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
const COMMENT_DEBOUNCE_MS = 25;
function createConnection(state: Partial<GitLabRepoConnectionState> = {}, isExistingState=false): { connection: GitLabRepoConnection, intent: IntentMock } {
const mq = createMessageQueue();
mq.subscribe('*');
const as = AppserviceMock.create();
Implement separate bot users per service (#573) * Add service bots config * Add joined rooms manager and keep track of joined rooms * Add bot users manager and ensure registration and profiles * Improve joined rooms manager and set up already joined rooms * Handle invites with service bots * Handle messages with service bots * Use service bots for connections * Use service bots in widget and provisioning APIs * Use service bots in setup connections * Use service bots for feed connections * Handle admin rooms for service bots * Fix confused event type and service type in provisioning and widget APIs * Fix generic webhooks service name * Fix enabled services config * Handle power level change * Create widgets with service scope * Use service bots for gitlab repo connections * Use service bots for gitlab issue connections * Use service bots for generic webhook connections * Use service bots for figma file connections * Use service bots when verifying state events * Use service bots for github repo connections * Use service bots for github discussion connections * Use service bots for github discussion space connections * Use service bots for github project connections * Use service bots for github issue connections * Use service bots for github user space connections * Use service bots for jira connections * Make sure ghost users are invited for gitlab issue comments * Configure one service per service bot * Add changelog * Update tests * Fix up following rebase * Fix comment * Use getter for enabled services * Ensure homeserver can be reached before registering bots * Add intent getter on bot user * Update config comment * Merge joined rooms manager with bot users manager * Remove unused localpart from bot user class * Refactor to pass in bot users manager * Improve priority sort function Co-authored-by: Christian Paul <christianp@matrix.org> * Fix priority sort Higher priority should come first * Add debug log when invites are rejected * Use different state key for scoped setup widgets * Use different subtitles to differentiate service bots setup widgets * Refactor bot user setup into bot users manager * Refactor to reduce duplication in widget API * Consistent room ID and intent args order * Add docs and update changelog * Add overrideUserId deprecation warning * Add service bots link Co-authored-by: Christian Paul <christianp@matrix.org> Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-13 10:32:09 -05:00
const intent = as.getIntentForUserId('@gitlab:example.test');
const connection = new GitLabRepoConnection(
ROOM_ID,
"state_key",
as,
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
{
commentDebounceMs: COMMENT_DEBOUNCE_MS,
} as BridgeConfigGitLab,
Implement separate bot users per service (#573) * Add service bots config * Add joined rooms manager and keep track of joined rooms * Add bot users manager and ensure registration and profiles * Improve joined rooms manager and set up already joined rooms * Handle invites with service bots * Handle messages with service bots * Use service bots for connections * Use service bots in widget and provisioning APIs * Use service bots in setup connections * Use service bots for feed connections * Handle admin rooms for service bots * Fix confused event type and service type in provisioning and widget APIs * Fix generic webhooks service name * Fix enabled services config * Handle power level change * Create widgets with service scope * Use service bots for gitlab repo connections * Use service bots for gitlab issue connections * Use service bots for generic webhook connections * Use service bots for figma file connections * Use service bots when verifying state events * Use service bots for github repo connections * Use service bots for github discussion connections * Use service bots for github discussion space connections * Use service bots for github project connections * Use service bots for github issue connections * Use service bots for github user space connections * Use service bots for jira connections * Make sure ghost users are invited for gitlab issue comments * Configure one service per service bot * Add changelog * Update tests * Fix up following rebase * Fix comment * Use getter for enabled services * Ensure homeserver can be reached before registering bots * Add intent getter on bot user * Update config comment * Merge joined rooms manager with bot users manager * Remove unused localpart from bot user class * Refactor to pass in bot users manager * Improve priority sort function Co-authored-by: Christian Paul <christianp@matrix.org> * Fix priority sort Higher priority should come first * Add debug log when invites are rejected * Use different state key for scoped setup widgets * Use different subtitles to differentiate service bots setup widgets * Refactor bot user setup into bot users manager * Refactor to reduce duplication in widget API * Consistent room ID and intent args order * Add docs and update changelog * Add overrideUserId deprecation warning * Add service bots link Co-authored-by: Christian Paul <christianp@matrix.org> Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-13 10:32:09 -05:00
intent,
GitLabRepoConnection.validateState({
instance: "bar",
path: "foo",
...state,
}, isExistingState),
{} as UserTokenStore,
{
url: "https://gitlab.example.com"
},
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
{
setGitlabDiscussionThreads: () => Promise.resolve(),
getGitlabDiscussionThreads: () => Promise.resolve([]),
} as unknown as IBridgeStorageProvider,
);
Implement separate bot users per service (#573) * Add service bots config * Add joined rooms manager and keep track of joined rooms * Add bot users manager and ensure registration and profiles * Improve joined rooms manager and set up already joined rooms * Handle invites with service bots * Handle messages with service bots * Use service bots for connections * Use service bots in widget and provisioning APIs * Use service bots in setup connections * Use service bots for feed connections * Handle admin rooms for service bots * Fix confused event type and service type in provisioning and widget APIs * Fix generic webhooks service name * Fix enabled services config * Handle power level change * Create widgets with service scope * Use service bots for gitlab repo connections * Use service bots for gitlab issue connections * Use service bots for generic webhook connections * Use service bots for figma file connections * Use service bots when verifying state events * Use service bots for github repo connections * Use service bots for github discussion connections * Use service bots for github discussion space connections * Use service bots for github project connections * Use service bots for github issue connections * Use service bots for github user space connections * Use service bots for jira connections * Make sure ghost users are invited for gitlab issue comments * Configure one service per service bot * Add changelog * Update tests * Fix up following rebase * Fix comment * Use getter for enabled services * Ensure homeserver can be reached before registering bots * Add intent getter on bot user * Update config comment * Merge joined rooms manager with bot users manager * Remove unused localpart from bot user class * Refactor to pass in bot users manager * Improve priority sort function Co-authored-by: Christian Paul <christianp@matrix.org> * Fix priority sort Higher priority should come first * Add debug log when invites are rejected * Use different state key for scoped setup widgets * Use different subtitles to differentiate service bots setup widgets * Refactor bot user setup into bot users manager * Refactor to reduce duplication in widget API * Consistent room ID and intent args order * Add docs and update changelog * Add overrideUserId deprecation warning * Add service bots link Co-authored-by: Christian Paul <christianp@matrix.org> Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-13 10:32:09 -05:00
return {connection, intent};
}
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
async function waitForDebouncing(): Promise<void> {
return new Promise(resolve => setTimeout(resolve, COMMENT_DEBOUNCE_MS * 2));
}
describe("GitLabRepoConnection", () => {
describe("validateState", () => {
it("can validate a completes state config", () => {
GitLabRepoConnection.validateState({
instance: "foo",
path: "bar/baz",
enableHooks: [
"merge_request.open",
"merge_request.reopen",
"merge_request.close",
"merge_request.merge",
"merge_request.review",
"merge_request.review.comments",
"merge_request",
"tag_push",
"push",
"wiki",
"release",
"release.created",
],
commandPrefix: "!gl",
pushTagsRegex: ".*",
includingLabels: ["me"],
excludingLabels: ["but-not-me"],
} as GitLabRepoConnectionState as unknown as Record<string, unknown>);
});
it("will convert ignoredHooks for existing state", () => {
const state = GitLabRepoConnection.validateState({
instance: "foo",
path: "bar/baz",
ignoreHooks: [
"merge_request",
],
commandPrefix: "!gl",
} as GitLabRepoConnectionState as unknown as Record<string, unknown>, true);
expect(state.enableHooks).to.not.contain('merge_request');
});
it("will disallow invalid state", () => {
try {
GitLabRepoConnection.validateState({
instance: "foo",
path: 123,
});
} catch (ex) {
if (ex instanceof ValidatorApiError === false || ex.errcode !== ErrCode.BadValue) {
throw ex;
}
}
});
it("will disallow enabledHooks to contains invalid enums if this is new state", () => {
try {
GitLabRepoConnection.validateState({
instance: "bar",
path: "foo",
enabledHooks: ["not-real"],
}, false);
} catch (ex) {
if (ex instanceof ApiError === false || ex.errcode !== ErrCode.BadValue) {
throw ex;
}
}
});
it("will allow enabledHooks to contains invalid enums if this is old state", () => {
GitLabRepoConnection.validateState({
instance: "bar",
path: "foo",
enabledHooks: ["not-real"],
}, true);
});
});
describe("onMergeRequestCommentCreated", () => {
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
it("will handle an MR comment", async () => {
const { connection, intent } = createConnection();
await connection.onMergeRequestCommentCreated(GITLAB_MR_COMMENT);
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
await waitForDebouncing();
intent.expectEventMatches(
(ev: any) => ev.content.body.includes('**Alice** commented on MR'),
'event body indicates MR comment'
);
});
it("will filter out issues not matching includingLabels.", async () => {
const { connection, intent } = createConnection({
includingLabels: ["include-me"]
});
// ..or issues with no labels
await connection.onMergeRequestCommentCreated(GITLAB_MR_COMMENT);
await waitForDebouncing();
intent.expectNoEvent();
});
it("will filter out issues matching excludingLabels.", async () => {
const { connection, intent } = createConnection({
excludingLabels: ["exclude-me"]
});
// ..or issues with no labels
await connection.onMergeRequestCommentCreated({
...GITLAB_MR_COMMENT,
merge_request: {
...GITLAB_MR,
labels: [{
id: 0,
title: 'exclude-me'
} as any]
}
});
await waitForDebouncing();
intent.expectNoEvent();
});
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
it("will debounce MR comments", async () => {
const { connection, intent } = createConnection();
await connection.onMergeRequestCommentCreated(GITLAB_MR_COMMENT);
await connection.onMergeRequestCommentCreated({
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
...GITLAB_MR_COMMENT,
'object_attributes': {
...GITLAB_MR_COMMENT.object_attributes,
'discussion_id': 'fa5d',
'note': 'different comment',
},
} as never);
await waitForDebouncing();
expect(intent.sentEvents.length).to.equal(1);
intent.expectEventMatches(
(ev: any) => ev.content.body.includes('with 2 comments'),
'one event sent for both comments',
0,
);
});
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
it("will add new comments in a Matrix thread", async () => {
const { connection, intent } = createConnection();
await connection.onMergeRequestCommentCreated(GITLAB_MR_COMMENT);
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
await waitForDebouncing();
await connection.onMergeRequestCommentCreated(GITLAB_MR_COMMENT);
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
await waitForDebouncing();
expect(intent.sentEvents.length).to.equal(2);
intent.expectEventMatches(
(ev: any) => ev.content['m.relates_to'].event_id === 'event_0',
'one event sent for both comments',
1,
);
});
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
it("will correctly map new comments to aggregated discussions", async () => {
const { connection, intent } = createConnection();
await connection.onMergeRequestCommentCreated({
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
...GITLAB_MR_COMMENT,
'object_attributes': {
...GITLAB_MR_COMMENT.object_attributes,
'discussion_id': 'disc1',
},
} as never);
await connection.onMergeRequestCommentCreated({
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
...GITLAB_MR_COMMENT,
'object_attributes': {
...GITLAB_MR_COMMENT.object_attributes,
'discussion_id': 'disc2',
},
} as never);
await waitForDebouncing();
expect(intent.sentEvents.length).to.equal(1);
await connection.onMergeRequestCommentCreated({
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
...GITLAB_MR_COMMENT,
'object_attributes': {
...GITLAB_MR_COMMENT.object_attributes,
'discussion_id': 'disc1',
},
} as never);
await waitForDebouncing();
expect(intent.sentEvents.length).to.equal(2);
intent.expectEventMatches(
(ev: any) => ev.content['m.relates_to'].event_id === 'event_0',
'disc1 reply goes to existing thread',
1
);
await connection.onMergeRequestCommentCreated({
Bridge Gitlab comment replies as Matrix threads (#758) * Bridge Gitlab comment replies as Matrix threads * Persistently store Gitlab Discussion-Thread mapping * Remove leftover debug line * Denoise comment descriptions when they happen in Matrix threads * Make comment debouncing time configurable * Add some tests for Gitlab comments * De-only Gitlab comment tests * Linting * Changelog * Map multiple Gitlab discussions to a single Matrix thread We debounce Gitlab comments, so multiple discussions can end up in one thread. This ensures that replies to *any* of these discussions end up in the same thread. * Add tests for the many-to-one reply case * Move SerializedGitlabDiscussionThreads to Types * Update changelog.d/758.feature Co-authored-by: Will Hunt <will@half-shot.uk> * Fix instructions for validating your config using Docker (#794) * Fix instructions for validating your config using Docker Fixes GH-787 * Changelog --------- Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Add more icons to GitHub messages (#795) * Add more icons to GitHub messages * Add merged icon * Lint * Add changelog * Bump word-wrap from 1.2.3 to 1.2.4 (#799) * Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Add changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Update matrix-appservice-bridge to 9.0.1 (#800) * Bump semver from 5.7.1 to 5.7.2 (#797) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> * 4.4.0 * 4.4.1 * Set the default commentDebouncMs for Gitlab in its Config * Rename `approvalState` to something more fitting * Update sample config --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Connor Davis <mail@connordav.is> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 14:58:21 +02:00
...GITLAB_MR_COMMENT,
'object_attributes': {
...GITLAB_MR_COMMENT.object_attributes,
'discussion_id': 'disc2',
},
} as never);
await waitForDebouncing();
expect(intent.sentEvents.length).to.equal(3);
intent.expectEventMatches(
(ev: any) => ev.content['m.relates_to'].event_id === 'event_0',
'disc2 reply also goes to existing thread',
2
);
});
});
describe("onIssueCreated", () => {
it("will handle a simple issue", async () => {
Implement separate bot users per service (#573) * Add service bots config * Add joined rooms manager and keep track of joined rooms * Add bot users manager and ensure registration and profiles * Improve joined rooms manager and set up already joined rooms * Handle invites with service bots * Handle messages with service bots * Use service bots for connections * Use service bots in widget and provisioning APIs * Use service bots in setup connections * Use service bots for feed connections * Handle admin rooms for service bots * Fix confused event type and service type in provisioning and widget APIs * Fix generic webhooks service name * Fix enabled services config * Handle power level change * Create widgets with service scope * Use service bots for gitlab repo connections * Use service bots for gitlab issue connections * Use service bots for generic webhook connections * Use service bots for figma file connections * Use service bots when verifying state events * Use service bots for github repo connections * Use service bots for github discussion connections * Use service bots for github discussion space connections * Use service bots for github project connections * Use service bots for github issue connections * Use service bots for github user space connections * Use service bots for jira connections * Make sure ghost users are invited for gitlab issue comments * Configure one service per service bot * Add changelog * Update tests * Fix up following rebase * Fix comment * Use getter for enabled services * Ensure homeserver can be reached before registering bots * Add intent getter on bot user * Update config comment * Merge joined rooms manager with bot users manager * Remove unused localpart from bot user class * Refactor to pass in bot users manager * Improve priority sort function Co-authored-by: Christian Paul <christianp@matrix.org> * Fix priority sort Higher priority should come first * Add debug log when invites are rejected * Use different state key for scoped setup widgets * Use different subtitles to differentiate service bots setup widgets * Refactor bot user setup into bot users manager * Refactor to reduce duplication in widget API * Consistent room ID and intent args order * Add docs and update changelog * Add overrideUserId deprecation warning * Add service bots link Co-authored-by: Christian Paul <christianp@matrix.org> Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-13 10:32:09 -05:00
const { connection, intent } = createConnection();
await connection.onMergeRequestOpened(GITLAB_ISSUE_CREATED_PAYLOAD as never);
// Statement text.
Implement separate bot users per service (#573) * Add service bots config * Add joined rooms manager and keep track of joined rooms * Add bot users manager and ensure registration and profiles * Improve joined rooms manager and set up already joined rooms * Handle invites with service bots * Handle messages with service bots * Use service bots for connections * Use service bots in widget and provisioning APIs * Use service bots in setup connections * Use service bots for feed connections * Handle admin rooms for service bots * Fix confused event type and service type in provisioning and widget APIs * Fix generic webhooks service name * Fix enabled services config * Handle power level change * Create widgets with service scope * Use service bots for gitlab repo connections * Use service bots for gitlab issue connections * Use service bots for generic webhook connections * Use service bots for figma file connections * Use service bots when verifying state events * Use service bots for github repo connections * Use service bots for github discussion connections * Use service bots for github discussion space connections * Use service bots for github project connections * Use service bots for github issue connections * Use service bots for github user space connections * Use service bots for jira connections * Make sure ghost users are invited for gitlab issue comments * Configure one service per service bot * Add changelog * Update tests * Fix up following rebase * Fix comment * Use getter for enabled services * Ensure homeserver can be reached before registering bots * Add intent getter on bot user * Update config comment * Merge joined rooms manager with bot users manager * Remove unused localpart from bot user class * Refactor to pass in bot users manager * Improve priority sort function Co-authored-by: Christian Paul <christianp@matrix.org> * Fix priority sort Higher priority should come first * Add debug log when invites are rejected * Use different state key for scoped setup widgets * Use different subtitles to differentiate service bots setup widgets * Refactor bot user setup into bot users manager * Refactor to reduce duplication in widget API * Consistent room ID and intent args order * Add docs and update changelog * Add overrideUserId deprecation warning * Add service bots link Co-authored-by: Christian Paul <christianp@matrix.org> Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-13 10:32:09 -05:00
intent.expectEventBodyContains('**alice** opened a new MR', 0);
intent.expectEventBodyContains(GITLAB_ISSUE_CREATED_PAYLOAD.object_attributes.url, 0);
intent.expectEventBodyContains(GITLAB_ISSUE_CREATED_PAYLOAD.object_attributes.title, 0);
});
it("will filter out issues not matching includingLabels.", async () => {
Implement separate bot users per service (#573) * Add service bots config * Add joined rooms manager and keep track of joined rooms * Add bot users manager and ensure registration and profiles * Improve joined rooms manager and set up already joined rooms * Handle invites with service bots * Handle messages with service bots * Use service bots for connections * Use service bots in widget and provisioning APIs * Use service bots in setup connections * Use service bots for feed connections * Handle admin rooms for service bots * Fix confused event type and service type in provisioning and widget APIs * Fix generic webhooks service name * Fix enabled services config * Handle power level change * Create widgets with service scope * Use service bots for gitlab repo connections * Use service bots for gitlab issue connections * Use service bots for generic webhook connections * Use service bots for figma file connections * Use service bots when verifying state events * Use service bots for github repo connections * Use service bots for github discussion connections * Use service bots for github discussion space connections * Use service bots for github project connections * Use service bots for github issue connections * Use service bots for github user space connections * Use service bots for jira connections * Make sure ghost users are invited for gitlab issue comments * Configure one service per service bot * Add changelog * Update tests * Fix up following rebase * Fix comment * Use getter for enabled services * Ensure homeserver can be reached before registering bots * Add intent getter on bot user * Update config comment * Merge joined rooms manager with bot users manager * Remove unused localpart from bot user class * Refactor to pass in bot users manager * Improve priority sort function Co-authored-by: Christian Paul <christianp@matrix.org> * Fix priority sort Higher priority should come first * Add debug log when invites are rejected * Use different state key for scoped setup widgets * Use different subtitles to differentiate service bots setup widgets * Refactor bot user setup into bot users manager * Refactor to reduce duplication in widget API * Consistent room ID and intent args order * Add docs and update changelog * Add overrideUserId deprecation warning * Add service bots link Co-authored-by: Christian Paul <christianp@matrix.org> Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-13 10:32:09 -05:00
const { connection, intent } = createConnection({
includingLabels: ["include-me"]
});
await connection.onMergeRequestOpened({
...GITLAB_ISSUE_CREATED_PAYLOAD,
labels: [{
title: "foo",
}],
} as never);
// ..or issues with no labels
await connection.onMergeRequestOpened(GITLAB_ISSUE_CREATED_PAYLOAD as never);
Implement separate bot users per service (#573) * Add service bots config * Add joined rooms manager and keep track of joined rooms * Add bot users manager and ensure registration and profiles * Improve joined rooms manager and set up already joined rooms * Handle invites with service bots * Handle messages with service bots * Use service bots for connections * Use service bots in widget and provisioning APIs * Use service bots in setup connections * Use service bots for feed connections * Handle admin rooms for service bots * Fix confused event type and service type in provisioning and widget APIs * Fix generic webhooks service name * Fix enabled services config * Handle power level change * Create widgets with service scope * Use service bots for gitlab repo connections * Use service bots for gitlab issue connections * Use service bots for generic webhook connections * Use service bots for figma file connections * Use service bots when verifying state events * Use service bots for github repo connections * Use service bots for github discussion connections * Use service bots for github discussion space connections * Use service bots for github project connections * Use service bots for github issue connections * Use service bots for github user space connections * Use service bots for jira connections * Make sure ghost users are invited for gitlab issue comments * Configure one service per service bot * Add changelog * Update tests * Fix up following rebase * Fix comment * Use getter for enabled services * Ensure homeserver can be reached before registering bots * Add intent getter on bot user * Update config comment * Merge joined rooms manager with bot users manager * Remove unused localpart from bot user class * Refactor to pass in bot users manager * Improve priority sort function Co-authored-by: Christian Paul <christianp@matrix.org> * Fix priority sort Higher priority should come first * Add debug log when invites are rejected * Use different state key for scoped setup widgets * Use different subtitles to differentiate service bots setup widgets * Refactor bot user setup into bot users manager * Refactor to reduce duplication in widget API * Consistent room ID and intent args order * Add docs and update changelog * Add overrideUserId deprecation warning * Add service bots link Co-authored-by: Christian Paul <christianp@matrix.org> Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-13 10:32:09 -05:00
intent.expectNoEvent();
});
it("will filter out issues matching excludingLabels.", async () => {
Implement separate bot users per service (#573) * Add service bots config * Add joined rooms manager and keep track of joined rooms * Add bot users manager and ensure registration and profiles * Improve joined rooms manager and set up already joined rooms * Handle invites with service bots * Handle messages with service bots * Use service bots for connections * Use service bots in widget and provisioning APIs * Use service bots in setup connections * Use service bots for feed connections * Handle admin rooms for service bots * Fix confused event type and service type in provisioning and widget APIs * Fix generic webhooks service name * Fix enabled services config * Handle power level change * Create widgets with service scope * Use service bots for gitlab repo connections * Use service bots for gitlab issue connections * Use service bots for generic webhook connections * Use service bots for figma file connections * Use service bots when verifying state events * Use service bots for github repo connections * Use service bots for github discussion connections * Use service bots for github discussion space connections * Use service bots for github project connections * Use service bots for github issue connections * Use service bots for github user space connections * Use service bots for jira connections * Make sure ghost users are invited for gitlab issue comments * Configure one service per service bot * Add changelog * Update tests * Fix up following rebase * Fix comment * Use getter for enabled services * Ensure homeserver can be reached before registering bots * Add intent getter on bot user * Update config comment * Merge joined rooms manager with bot users manager * Remove unused localpart from bot user class * Refactor to pass in bot users manager * Improve priority sort function Co-authored-by: Christian Paul <christianp@matrix.org> * Fix priority sort Higher priority should come first * Add debug log when invites are rejected * Use different state key for scoped setup widgets * Use different subtitles to differentiate service bots setup widgets * Refactor bot user setup into bot users manager * Refactor to reduce duplication in widget API * Consistent room ID and intent args order * Add docs and update changelog * Add overrideUserId deprecation warning * Add service bots link Co-authored-by: Christian Paul <christianp@matrix.org> Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-13 10:32:09 -05:00
const { connection, intent } = createConnection({
excludingLabels: ["exclude-me"]
});
await connection.onMergeRequestOpened({
...GITLAB_ISSUE_CREATED_PAYLOAD,
labels: [{
title: "exclude-me",
}],
} as never);
Implement separate bot users per service (#573) * Add service bots config * Add joined rooms manager and keep track of joined rooms * Add bot users manager and ensure registration and profiles * Improve joined rooms manager and set up already joined rooms * Handle invites with service bots * Handle messages with service bots * Use service bots for connections * Use service bots in widget and provisioning APIs * Use service bots in setup connections * Use service bots for feed connections * Handle admin rooms for service bots * Fix confused event type and service type in provisioning and widget APIs * Fix generic webhooks service name * Fix enabled services config * Handle power level change * Create widgets with service scope * Use service bots for gitlab repo connections * Use service bots for gitlab issue connections * Use service bots for generic webhook connections * Use service bots for figma file connections * Use service bots when verifying state events * Use service bots for github repo connections * Use service bots for github discussion connections * Use service bots for github discussion space connections * Use service bots for github project connections * Use service bots for github issue connections * Use service bots for github user space connections * Use service bots for jira connections * Make sure ghost users are invited for gitlab issue comments * Configure one service per service bot * Add changelog * Update tests * Fix up following rebase * Fix comment * Use getter for enabled services * Ensure homeserver can be reached before registering bots * Add intent getter on bot user * Update config comment * Merge joined rooms manager with bot users manager * Remove unused localpart from bot user class * Refactor to pass in bot users manager * Improve priority sort function Co-authored-by: Christian Paul <christianp@matrix.org> * Fix priority sort Higher priority should come first * Add debug log when invites are rejected * Use different state key for scoped setup widgets * Use different subtitles to differentiate service bots setup widgets * Refactor bot user setup into bot users manager * Refactor to reduce duplication in widget API * Consistent room ID and intent args order * Add docs and update changelog * Add overrideUserId deprecation warning * Add service bots link Co-authored-by: Christian Paul <christianp@matrix.org> Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-13 10:32:09 -05:00
intent.expectNoEvent();
});
it("will include issues matching includingLabels.", async () => {
Implement separate bot users per service (#573) * Add service bots config * Add joined rooms manager and keep track of joined rooms * Add bot users manager and ensure registration and profiles * Improve joined rooms manager and set up already joined rooms * Handle invites with service bots * Handle messages with service bots * Use service bots for connections * Use service bots in widget and provisioning APIs * Use service bots in setup connections * Use service bots for feed connections * Handle admin rooms for service bots * Fix confused event type and service type in provisioning and widget APIs * Fix generic webhooks service name * Fix enabled services config * Handle power level change * Create widgets with service scope * Use service bots for gitlab repo connections * Use service bots for gitlab issue connections * Use service bots for generic webhook connections * Use service bots for figma file connections * Use service bots when verifying state events * Use service bots for github repo connections * Use service bots for github discussion connections * Use service bots for github discussion space connections * Use service bots for github project connections * Use service bots for github issue connections * Use service bots for github user space connections * Use service bots for jira connections * Make sure ghost users are invited for gitlab issue comments * Configure one service per service bot * Add changelog * Update tests * Fix up following rebase * Fix comment * Use getter for enabled services * Ensure homeserver can be reached before registering bots * Add intent getter on bot user * Update config comment * Merge joined rooms manager with bot users manager * Remove unused localpart from bot user class * Refactor to pass in bot users manager * Improve priority sort function Co-authored-by: Christian Paul <christianp@matrix.org> * Fix priority sort Higher priority should come first * Add debug log when invites are rejected * Use different state key for scoped setup widgets * Use different subtitles to differentiate service bots setup widgets * Refactor bot user setup into bot users manager * Refactor to reduce duplication in widget API * Consistent room ID and intent args order * Add docs and update changelog * Add overrideUserId deprecation warning * Add service bots link Co-authored-by: Christian Paul <christianp@matrix.org> Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-13 10:32:09 -05:00
const { connection, intent } = createConnection({
includingLabels: ["include-me"]
});
await connection.onMergeRequestOpened({
...GITLAB_ISSUE_CREATED_PAYLOAD,
labels: [{
title: "include-me",
}],
} as never);
Implement separate bot users per service (#573) * Add service bots config * Add joined rooms manager and keep track of joined rooms * Add bot users manager and ensure registration and profiles * Improve joined rooms manager and set up already joined rooms * Handle invites with service bots * Handle messages with service bots * Use service bots for connections * Use service bots in widget and provisioning APIs * Use service bots in setup connections * Use service bots for feed connections * Handle admin rooms for service bots * Fix confused event type and service type in provisioning and widget APIs * Fix generic webhooks service name * Fix enabled services config * Handle power level change * Create widgets with service scope * Use service bots for gitlab repo connections * Use service bots for gitlab issue connections * Use service bots for generic webhook connections * Use service bots for figma file connections * Use service bots when verifying state events * Use service bots for github repo connections * Use service bots for github discussion connections * Use service bots for github discussion space connections * Use service bots for github project connections * Use service bots for github issue connections * Use service bots for github user space connections * Use service bots for jira connections * Make sure ghost users are invited for gitlab issue comments * Configure one service per service bot * Add changelog * Update tests * Fix up following rebase * Fix comment * Use getter for enabled services * Ensure homeserver can be reached before registering bots * Add intent getter on bot user * Update config comment * Merge joined rooms manager with bot users manager * Remove unused localpart from bot user class * Refactor to pass in bot users manager * Improve priority sort function Co-authored-by: Christian Paul <christianp@matrix.org> * Fix priority sort Higher priority should come first * Add debug log when invites are rejected * Use different state key for scoped setup widgets * Use different subtitles to differentiate service bots setup widgets * Refactor bot user setup into bot users manager * Refactor to reduce duplication in widget API * Consistent room ID and intent args order * Add docs and update changelog * Add overrideUserId deprecation warning * Add service bots link Co-authored-by: Christian Paul <christianp@matrix.org> Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-13 10:32:09 -05:00
intent.expectEventBodyContains('**alice** opened a new MR', 0);
});
});
Implement separate bot users per service (#573) * Add service bots config * Add joined rooms manager and keep track of joined rooms * Add bot users manager and ensure registration and profiles * Improve joined rooms manager and set up already joined rooms * Handle invites with service bots * Handle messages with service bots * Use service bots for connections * Use service bots in widget and provisioning APIs * Use service bots in setup connections * Use service bots for feed connections * Handle admin rooms for service bots * Fix confused event type and service type in provisioning and widget APIs * Fix generic webhooks service name * Fix enabled services config * Handle power level change * Create widgets with service scope * Use service bots for gitlab repo connections * Use service bots for gitlab issue connections * Use service bots for generic webhook connections * Use service bots for figma file connections * Use service bots when verifying state events * Use service bots for github repo connections * Use service bots for github discussion connections * Use service bots for github discussion space connections * Use service bots for github project connections * Use service bots for github issue connections * Use service bots for github user space connections * Use service bots for jira connections * Make sure ghost users are invited for gitlab issue comments * Configure one service per service bot * Add changelog * Update tests * Fix up following rebase * Fix comment * Use getter for enabled services * Ensure homeserver can be reached before registering bots * Add intent getter on bot user * Update config comment * Merge joined rooms manager with bot users manager * Remove unused localpart from bot user class * Refactor to pass in bot users manager * Improve priority sort function Co-authored-by: Christian Paul <christianp@matrix.org> * Fix priority sort Higher priority should come first * Add debug log when invites are rejected * Use different state key for scoped setup widgets * Use different subtitles to differentiate service bots setup widgets * Refactor bot user setup into bot users manager * Refactor to reduce duplication in widget API * Consistent room ID and intent args order * Add docs and update changelog * Add overrideUserId deprecation warning * Add service bots link Co-authored-by: Christian Paul <christianp@matrix.org> Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-13 10:32:09 -05:00
});