From 938161d339b11050402093360c6abcfbb3174842 Mon Sep 17 00:00:00 2001 From: Alex Jin <57976479+Silver-IT@users.noreply.github.com> Date: Wed, 24 Jul 2024 19:37:19 -0700 Subject: [PATCH 1/2] Fix error that invite link doesn't work inside chat (#2246) * chore: added a small update and Cypress try * chore: added comment and Cypress retry * chore: check if group-chat passes three times in a row * chore: group-chat passes 4 times in a row * chore: 5 times pass in a row means it fixes the heisenbug? maybe it's because assert inside then clause? * fix: error in invitelink * feat: update Cypress according to the updated invitelink format * fix: cypress errors according to the changes of inviteLink format * chore: added comment and Cypress retry * chore: updated comment and Cypress retry * fix: added cy.wait and Cypress try * chore: added comment and Cypress retry * fix: removing cy.wait * chore: updated comment and check Cypress passed 2 times in a row * chore: really passes 3 times in a row? * chore: updated comment and Cypress retry * chore: cypress retry * chore: Cypress retry * chore: Cypress retry * chore: Cypress retry * chore: Cypress retry * fix: heisenbug in group-proposal * feat: changed query to hash for security problem * fix: reverted the format of hash param * fix: eslint error --- frontend/controller/router.js | 2 +- .../chatroom/chat-mentions/RenderMessageWithMarkdown.js | 2 +- frontend/views/pages/Join.vue | 4 ++-- test/cypress/integration/group-proposals.spec.js | 5 +++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/controller/router.js b/frontend/controller/router.js index f16ce7644..0f2c1ca89 100644 --- a/frontend/controller/router.js +++ b/frontend/controller/router.js @@ -42,7 +42,7 @@ const loginGuard = { const inviteGuard = { guard: (to, from) => { - // ex: http://localhost:8000/app/join#groupId=21XWnNRE7vggw4ngGqmQz5D4vAwPYqcREhEkGop2mYZTKVkx8H&secret=5157 + // ex: http://localhost:8000/app/join#?groupId=21XWnNRE7vggw4ngGqmQz5D4vAwPYqcREhEkGop2mYZTKVkx8H&secret=5157 return !(to.hash.includes('groupId=') && to.hash.includes('secret=')) }, redirect: (to, from) => ({ path: '/' }) diff --git a/frontend/views/containers/chatroom/chat-mentions/RenderMessageWithMarkdown.js b/frontend/views/containers/chatroom/chat-mentions/RenderMessageWithMarkdown.js index 44441685c..09b927e3d 100644 --- a/frontend/views/containers/chatroom/chat-mentions/RenderMessageWithMarkdown.js +++ b/frontend/views/containers/chatroom/chat-mentions/RenderMessageWithMarkdown.js @@ -38,7 +38,7 @@ const RenderMessageWithMarkdown: any = { for (const [key, value] of url.searchParams) { query[key] = value } - routerOptions.route = { path, query } + routerOptions.route = { path, query, hash: url.hash } routerOptions.href = this.$router.resolve(routerOptions.route).href routerOptions.isInAppRouter = true } diff --git a/frontend/views/pages/Join.vue b/frontend/views/pages/Join.vue index ace156c61..d41359fa8 100644 --- a/frontend/views/pages/Join.vue +++ b/frontend/views/pages/Join.vue @@ -83,7 +83,7 @@ export default ({ pageStatus: 'LOADING', invitation: {}, groupInfo: {}, - query: null + hash: null } } }, @@ -102,7 +102,7 @@ export default ({ } }, mounted () { - // For some reason in some Cypress tests it loses the route query when initialized is called + // For some reason in some Cypress tests it loses the route hash when initialized is called this.ephemeral.hash = new URLSearchParams(this.$route.hash.slice(1)) if (syncFinished || !this.ourIdentityContractId) { this.initialize() diff --git a/test/cypress/integration/group-proposals.spec.js b/test/cypress/integration/group-proposals.spec.js index f34e75c15..c4099575d 100644 --- a/test/cypress/integration/group-proposals.spec.js +++ b/test/cypress/integration/group-proposals.spec.js @@ -252,6 +252,8 @@ describe('Proposals - Add members', () => { cy.getByDT('openAllProposals').click() cy.get('[data-test="modal"] > .c-container .c-title').should('contain', 'Archived proposals') cy.getByDT('modal').within(() => { + // NOTE: this is to wait until all of the 4 proposals are loaded inside the modal + cy.get('.c-container > .c-header-info .has-text-1').should('contain', '4 proposals') assertInvitationLinkFor(2, 'user4') assertInvitationLinkFor(1, 'user6') }) @@ -408,6 +410,9 @@ describe('Proposals - Add members', () => { cy.getByDT('openAllProposals').click() cy.get('[data-test="modal"] > .c-container .c-title').should('contain', 'Archived proposals') cy.getByDT('modal').within(() => { + // NOTE: this is to wait until all of the 5 proposals are loaded inside the modal + cy.get('.c-container > .c-header-info .has-text-1').should('contain', '5 proposals') + getProposalItems().eq(2).within(() => { cy.getByDT('title', 'p').should('contain', 'You proposed') cy.getByDT('statusDescription') From cb73265fd9712e1f89da5cab68e0234d65412427 Mon Sep 17 00:00:00 2001 From: Alex Jin <57976479+Silver-IT@users.noreply.github.com> Date: Wed, 24 Jul 2024 20:21:31 -0700 Subject: [PATCH 2/2] Fix some UI issues (#2251) * fix: error in redirecting chatroom * fix: error in opening an wrong URL with query * fix: to revoke invite link which are already revoked * fix: styling issue inside pinned messages * fix: reverted useless change --- frontend/views/containers/chatroom/ChatMixin.js | 14 ++++++++++---- .../views/containers/chatroom/PinnedMessages.vue | 6 +++++- .../containers/group-settings/InvitationsTable.vue | 12 ++++++++---- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/frontend/views/containers/chatroom/ChatMixin.js b/frontend/views/containers/chatroom/ChatMixin.js index 9aa4f6aea..7ce89663a 100644 --- a/frontend/views/containers/chatroom/ChatMixin.js +++ b/frontend/views/containers/chatroom/ChatMixin.js @@ -80,15 +80,21 @@ const ChatMixin: Object = { }, methods: { redirectChat (chatRoomID: string) { - const name = 'GroupChatConversation' // Temporarily blocked the chatrooms which the user is not part of // Need to open it later and display messages just like Slack - chatRoomID = chatRoomID || (this.isJoinedChatRoom(this.currentChatRoomId) ? this.currentChatRoomId : this.groupGeneralChatRoomId) + + // NOTE: for better understanding created a variable `shouldUseAlternative` instead of using !chatRoomID. + // to skip passing `chatRoomID` parameter means an intention to redirect to another chatroom + // this happens when the wrong (or cannot accessable) chatRoomID is used while opening group-chat URL + const shouldUseAlternative = !chatRoomID + if (shouldUseAlternative) { + chatRoomID = this.isJoinedChatRoom(this.currentChatRoomId) ? this.currentChatRoomId : this.groupGeneralChatRoomId + } this.$router.push({ - name, + name: 'GroupChatConversation', params: { chatRoomID }, - query: { ...this.$route.query } + query: !shouldUseAlternative ? { ...this.$route.query } : {} }).catch(logExceptNavigationDuplicated) }, refreshTitle (title?: string): void { diff --git a/frontend/views/containers/chatroom/PinnedMessages.vue b/frontend/views/containers/chatroom/PinnedMessages.vue index 86992c156..00a391089 100644 --- a/frontend/views/containers/chatroom/PinnedMessages.vue +++ b/frontend/views/containers/chatroom/PinnedMessages.vue @@ -306,7 +306,11 @@ export default { .c-pinned-message-content { margin: 0.5rem 0; - word-break: break-word; + + .c-text { + white-space: pre-line; + word-break: break-word; + } .c-poll-inner { position: relative; diff --git a/frontend/views/containers/group-settings/InvitationsTable.vue b/frontend/views/containers/group-settings/InvitationsTable.vue index 549a94c84..c0bbb83b5 100644 --- a/frontend/views/containers/group-settings/InvitationsTable.vue +++ b/frontend/views/containers/group-settings/InvitationsTable.vue @@ -288,10 +288,14 @@ export default ({ } }, showRevokeLinkMenu (inviteItem) { - return inviteItem.isAnyoneLink - ? this.isUserGroupCreator && - this.groupShouldPropose // 'Anyone' link must only be revokable when the group size is >= 3 (context: https://github.com/okTurtles/group-income/issues/1670) - : inviteItem.status.isActive + if (inviteItem.status.isActive) { + if (inviteItem.isAnyoneLink) { + // 'Anyone' link must only be revokable when the group size is >= 3 (context: https://github.com/okTurtles/group-income/issues/1670) + return this.isUserGroupCreator && this.groupShouldPropose + } + return true + } + return false }, handleInviteClick (e) { if (e.target.classList.contains('js-btnInvite')) {