From 1260c8770c323e9608966924f1be6fde6fd99066 Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Wed, 26 Jul 2023 17:22:03 +0700 Subject: [PATCH] UBER-629 Fix Kick Employee action (#3523) Signed-off-by: Alexander Onnikov --- models/contact/src/index.ts | 3 +- models/contact/src/plugin.ts | 2 + plugins/contact-assets/lang/en.json | 7 +-- plugins/contact-assets/lang/ru.json | 1 + plugins/contact-resources/src/index.ts | 2 +- plugins/contact-resources/src/plugin.ts | 3 +- tests/prepare.sh | 4 +- tests/sanity/tests/contacts.spec.ts | 59 ++++++++++++++++++++++++- 8 files changed, 72 insertions(+), 9 deletions(-) diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index bee661a227..36d30c87c2 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -1,5 +1,6 @@ // // Copyright © 2020, 2021 Anticrm Platform Contributors. +// Copyright © 2023 Hardcore Engineering Inc. // // Licensed under the Eclipse Public License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. You may @@ -764,7 +765,7 @@ export function createModel (builder: Builder): void { }, secured: true }, - contact.action.KickEmployee + contact.action.DeleteEmployee ) createAction( diff --git a/models/contact/src/plugin.ts b/models/contact/src/plugin.ts index f5a435d1f3..79946f6c10 100644 --- a/models/contact/src/plugin.ts +++ b/models/contact/src/plugin.ts @@ -1,5 +1,6 @@ // // Copyright © 2020 Anticrm Platform Contributors. +// Copyright © 2023 Hardcore Engineering Inc. // // Licensed under the Eclipse Public License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. You may @@ -112,6 +113,7 @@ export default mergeIds(contactId, contact, { }, action: { KickEmployee: '' as Ref, + DeleteEmployee: '' as Ref, MergeEmployee: '' as Ref }, actionImpl: { diff --git a/plugins/contact-assets/lang/en.json b/plugins/contact-assets/lang/en.json index 8884091a20..d49d92c763 100644 --- a/plugins/contact-assets/lang/en.json +++ b/plugins/contact-assets/lang/en.json @@ -28,7 +28,8 @@ "Person": "Person", "Organization": "Company", "Employee": "Employee", - "DeleteEmployee": "Delete", + "DeleteEmployee": "Delete employee", + "DeleteEmployeeDescr": "Are you sure you want to delete the employee from the workspace?", "Value": "Value", "FullDescription": "Full description", "Phone": "Phone", @@ -61,7 +62,7 @@ "Members": "Members", "NoMembers": "No members added", "AddMember": "Add member", - "KickEmployee": "Kick an employee", + "KickEmployee": "Kick employee", "KickEmployeeDescr": "Are you sure you want to kick the employee out of the workspace? This action cannot be undone", "Email": "Email", "CreateEmployee": "Employee", @@ -70,7 +71,7 @@ "UseImage": "Attached photo", "UseGravatar": "Gravatar", "UseColor": "Color", - "NotSpecified": "Not specified", + "NotSpecified": "Not specified", "Whatsapp": "Whatsapp", "WhatsappPlaceholder": "Whatsapp", "Skype": "Skype", diff --git a/plugins/contact-assets/lang/ru.json b/plugins/contact-assets/lang/ru.json index 166b89209f..b53be2d044 100644 --- a/plugins/contact-assets/lang/ru.json +++ b/plugins/contact-assets/lang/ru.json @@ -29,6 +29,7 @@ "Organization": "Компания", "Employee": "Сотрудник", "DeleteEmployee": "Удалить", + "DeleteEmployeeDescr": "Вы действительно хотите удалить сотрудника из рабочего пространства?", "Value": "Значение", "FullDescription": "Полное описание", "Phone": "Телефон", diff --git a/plugins/contact-resources/src/index.ts b/plugins/contact-resources/src/index.ts index e5e4b42aab..ffc7ef12c0 100644 --- a/plugins/contact-resources/src/index.ts +++ b/plugins/contact-resources/src/index.ts @@ -218,7 +218,7 @@ async function kickEmployee (doc: Employee): Promise { MessageBox, { label: contact.string.DeleteEmployee, - message: contact.string.DeleteEmployee + message: contact.string.DeleteEmployeeDescr }, undefined, (res?: boolean) => { diff --git a/plugins/contact-resources/src/plugin.ts b/plugins/contact-resources/src/plugin.ts index 27b5d2ff53..ca50f82fe3 100644 --- a/plugins/contact-resources/src/plugin.ts +++ b/plugins/contact-resources/src/plugin.ts @@ -1,6 +1,6 @@ // // Copyright © 2020, 2021 Anticrm Platform Contributors. -// Copyright © 2021 Hardcore Engineering Inc. +// Copyright © 2021, 2023 Hardcore Engineering Inc. // // Licensed under the Eclipse Public License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. You may @@ -77,6 +77,7 @@ export default mergeIds(contactId, contact, { CategoryComponentLead: '' as IntlString, CategoryOther: '' as IntlString, DeleteEmployee: '' as IntlString, + DeleteEmployeeDescr: '' as IntlString, HasMessagesIn: '' as IntlString, HasNewMessagesIn: '' as IntlString }, diff --git a/tests/prepare.sh b/tests/prepare.sh index d6b521bbbe..3a45d3407e 100755 --- a/tests/prepare.sh +++ b/tests/prepare.sh @@ -6,10 +6,12 @@ docker-compose -p sanity up -d --force-recreate --renew-anon-volumes ./wait-elastic.sh 9201 -# Creae workspace record in accounts +# Create workspace record in accounts ./tool.sh create-workspace sanity-ws -o SanityTest # Create user record in accounts ./tool.sh create-account user1 -f John -l Appleseed -p 1234 +# Make user the workspace maintainer +./tool.sh set-user-role user1 sanity-ws 1 ./tool.sh confirm-email user1 ./restore-workspace.sh \ No newline at end of file diff --git a/tests/sanity/tests/contacts.spec.ts b/tests/sanity/tests/contacts.spec.ts index a859607fca..ec3c56a31a 100644 --- a/tests/sanity/tests/contacts.spec.ts +++ b/tests/sanity/tests/contacts.spec.ts @@ -88,15 +88,70 @@ test.describe('contact tests', () => { await page.locator('.antiCard button:has-text("Create")').click() await page.waitForSelector('form.antiCard', { state: 'detached' }) + await expect(page.locator(`td:has-text("${last} ${first}")`)).toHaveCount(1) + // Click #context-menu svg await page.hover(`td:has-text("${last} ${first}")`) await page.click(`td:has-text("${last} ${first}")`, { button: 'right' }) await page.click('text="Delete"') - // Click text=Ok + // Click text=Yes await page.click('text=Yes') - await expect(page.locator(`td:has-text("${first} ${last}")`)).toHaveCount(0) + await expect(page.locator(`td:has-text("${last} ${first}")`)).toHaveCount(0) + }) + + test('kick-and-delete-employee', async ({ page }) => { + // Create a new context with the saved storage state. + await page.locator('[id="app-contact\\:string\\:Contacts"]').click() + + // Create employee + await page.click('.antiNav-element:has-text("Employee")') + await page.click('button:has-text("Employee")') + + const first = 'Elton-' + generateId(5) + const last = 'John-' + generateId(5) + const mail = 'eltonjohn@' + generateId(5) + + const firstName = page.locator('[placeholder="First name"]') + await firstName.click() + await firstName.fill(first) + + const lastName = page.locator('[placeholder="Last name"]') + await lastName.click() + await lastName.fill(last) + + const email = page.locator('[placeholder="Email"]') + await email.click() + await email.fill(mail) + + await page.locator('.antiCard button:has-text("Create")').click() + await page.waitForSelector('form.antiCard', { state: 'detached' }) + + // Kick employee + + // Click #context-menu svg + await page.hover(`td:has-text("${last} ${first}")`) + await page.click(`td:has-text("${last} ${first}")`, { button: 'right' }) + await page.click('text="Kick employee"') + // Click text=Ok + await page.click('text=Ok') + + await expect(page.locator(`td:has-text("${last} ${first}")`)).toHaveCount(1) + + // We need some time to ensure that the status is proper one + await page.waitForTimeout(1000) + + // Delete employee + + // Click #context-menu svg + await page.hover(`td:has-text("${last} ${first}")`) + await page.click(`td:has-text("${last} ${first}")`, { button: 'right' }) + await page.click('text="Delete employee"') + // Click text=Ok + await page.click('text=Ok') + + await expect(page.locator(`td:has-text("${last} ${first}")`)).toHaveCount(0) }) })