diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml index 9ca3023cc..c1aee47cf 100644 --- a/.github/workflows/test-webapp.yml +++ b/.github/workflows/test-webapp.yml @@ -23,7 +23,7 @@ jobs: prepare: name: Prepare - if: needs.files-changed.outputs.webapp + if: needs.files-changed.outputs.webapp == 'true' needs: files-changed runs-on: ubuntu-latest steps: @@ -37,7 +37,7 @@ jobs: build_test_webapp: name: Docker Build Test - Webapp - if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp + if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' needs: [files-changed, prepare] runs-on: ubuntu-latest steps: @@ -57,7 +57,7 @@ jobs: lint_webapp: name: Lint Webapp - if: needs.files-changed.outputs.webapp + if: needs.files-changed.outputs.webapp == 'true' needs: files-changed runs-on: ubuntu-latest steps: @@ -69,7 +69,7 @@ jobs: unit_test_webapp: name: Unit Tests - Webapp - if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp + if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true' needs: [files-changed, build_test_webapp] runs-on: ubuntu-latest permissions: diff --git a/backend/src/schema/resolvers/rooms.spec.ts b/backend/src/schema/resolvers/rooms.spec.ts index d27c64e57..03c3d4456 100644 --- a/backend/src/schema/resolvers/rooms.spec.ts +++ b/backend/src/schema/resolvers/rooms.spec.ts @@ -92,6 +92,21 @@ describe('Room', () => { }) }) + describe('user id is self', () => { + it('throws error', async () => { + await expect( + mutate({ + mutation: createRoomMutation(), + variables: { + userId: 'chatting-user', + }, + }), + ).resolves.toMatchObject({ + errors: [{ message: 'Cannot create a room with self' }], + }) + }) + }) + describe('user id exists', () => { it('returns the id of the room', async () => { const result = await mutate({ diff --git a/backend/src/schema/resolvers/rooms.ts b/backend/src/schema/resolvers/rooms.ts index 2fe621d23..d5015a03b 100644 --- a/backend/src/schema/resolvers/rooms.ts +++ b/backend/src/schema/resolvers/rooms.ts @@ -12,7 +12,11 @@ export default { if (resolved) { resolved.forEach((room) => { if (room.users) { + // buggy, you must query the username for this to function correctly room.roomName = room.users.filter((user) => user.id !== context.user.id)[0].name + room.avatar = + room.users.filter((user) => user.id !== context.user.id)[0].avatar?.url || + 'default-avatar' room.users.forEach((user) => { user._id = user.id }) @@ -28,6 +32,9 @@ export default { const { user: { id: currentUserId }, } = context + if (userId === currentUserId) { + throw new Error('Cannot create a room with self') + } const session = context.driver.session() const writeTxResultPromise = session.writeTransaction(async (transaction) => { const createRoomCypher = ` diff --git a/backend/src/schema/types/type/Room.gql b/backend/src/schema/types/type/Room.gql index c90ebda3a..2ce6556f6 100644 --- a/backend/src/schema/types/type/Room.gql +++ b/backend/src/schema/types/type/Room.gql @@ -14,6 +14,7 @@ type Room { roomId: String! @cypher(statement: "RETURN this.id") roomName: String! ## @cypher(statement: "MATCH (this)<-[:CHATS_IN]-(user:User) WHERE NOT user.id = $cypherParams.currentUserId RETURN user[0].name") + avatar: String! ## @cypher match not own user in users array } type Mutation { diff --git a/deployment/TODO-next-update.md b/deployment/TODO-next-update.md index 8630275b7..8e30d1f47 100644 --- a/deployment/TODO-next-update.md +++ b/deployment/TODO-next-update.md @@ -2,6 +2,10 @@ When you overtake this deploy and rebrand repo to your network you have to recognize the following changes and doings: +## Version >= 2.7.0 with 'ocelotDockerVersionTag' 2.7.0-470 + +- You have to rename all `.js` files to `.ts` in `branding/constants` + ## Version >= 2.4.0 with 'ocelotDockerVersionTag' 2.4.0-298 - You have to set `SHOW_CONTENT_FILTER_HEADER_MENU` and `SHOW_CONTENT_FILTER_MASONRY_GRID` in `branding/constants/filter.js` originally in main code file `webapp/constants/filter.js` to your preferred value. diff --git a/package.json b/package.json index 5a116bd13..9f8399db7 100644 --- a/package.json +++ b/package.json @@ -27,12 +27,12 @@ "@babel/register": "^7.12.10", "@badeball/cypress-cucumber-preprocessor": "^15.1.4", "@cypress/browserify-preprocessor": "^3.0.2", - "@faker-js/faker": "7.6.0", + "@faker-js/faker": "8.0.2", "auto-changelog": "^2.3.0", "bcryptjs": "^2.4.3", "cross-env": "^7.0.3", "cucumber": "^6.0.5", - "cypress": "^12.14.0", + "cypress": "^12.17.0", "cypress-file-upload": "^3.5.3", "cypress-network-idle": "^1.14.2", "date-fns": "^2.25.0", diff --git a/webapp/components/Chat/Chat.vue b/webapp/components/Chat/Chat.vue index c2b02c0af..2b9514bf3 100644 --- a/webapp/components/Chat/Chat.vue +++ b/webapp/components/Chat/Chat.vue @@ -3,7 +3,7 @@