From d5adc6ee4bf60eab8f219873cf7debddc2a03fdb Mon Sep 17 00:00:00 2001
From: ilkin-overleaf <100852799+ilkin-overleaf@users.noreply.github.com>
Date: Thu, 27 Feb 2025 11:12:45 +0200
Subject: [PATCH] Merge pull request #23806 from
overleaf/ii-bs5-manage-group-managers
[web] BS5 Group managers management
GitOrigin-RevId: 912fd29c3d5cf07eab0cd67e2771e60b1ba25fb3
---
.../UserMembershipController.mjs | 2 +
.../user_membership/group-managers-react.pug | 4 +
.../institution-managers-react.pug | 4 +
.../publisher-managers-react.pug | 4 +
.../components/managers-table.tsx | 217 ++++++++++--------
.../group-management/components/user-row.tsx | 116 ++++++----
.../bootstrap-5/components/group-members.scss | 8 +
.../stylesheets/components/group-members.less | 8 +
.../components/group-managers.spec.tsx | 140 ++++++-----
.../components/institution-managers.spec.tsx | 140 ++++++-----
.../components/publisher-managers.spec.tsx | 134 ++++++-----
11 files changed, 461 insertions(+), 316 deletions(-)
diff --git a/services/web/app/src/Features/UserMembership/UserMembershipController.mjs b/services/web/app/src/Features/UserMembership/UserMembershipController.mjs
index 3fa0f57a74..547b3ba854 100644
--- a/services/web/app/src/Features/UserMembership/UserMembershipController.mjs
+++ b/services/web/app/src/Features/UserMembership/UserMembershipController.mjs
@@ -120,6 +120,8 @@ async function _renderManagersPage(req, res, next, template) {
entityConfig
)
+ await SplitTestHandler.promises.getAssignment(req, res, 'bootstrap-5-groups')
+
res.render(template, {
name: entityName,
users,
diff --git a/services/web/app/views/user_membership/group-managers-react.pug b/services/web/app/views/user_membership/group-managers-react.pug
index f4d8c0e973..143e2218d8 100644
--- a/services/web/app/views/user_membership/group-managers-react.pug
+++ b/services/web/app/views/user_membership/group-managers-react.pug
@@ -3,6 +3,10 @@ extends ../layout-marketing
block entrypointVar
- entrypoint = 'pages/user/subscription/group-management/group-managers'
+block vars
+ - bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
+ - bootstrap5PageSplitTest = 'bootstrap-5-groups'
+
block append meta
meta(name="ol-users", data-type="json", content=users)
meta(name="ol-groupId", data-type="string", content=groupId)
diff --git a/services/web/app/views/user_membership/institution-managers-react.pug b/services/web/app/views/user_membership/institution-managers-react.pug
index 690e8409f2..99307f69a9 100644
--- a/services/web/app/views/user_membership/institution-managers-react.pug
+++ b/services/web/app/views/user_membership/institution-managers-react.pug
@@ -3,6 +3,10 @@ extends ../layout-marketing
block entrypointVar
- entrypoint = 'pages/user/subscription/group-management/institution-managers'
+block vars
+ - bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
+ - bootstrap5PageSplitTest = 'bootstrap-5-groups'
+
block append meta
meta(name="ol-users", data-type="json", content=users)
meta(name="ol-groupId", data-type="string", content=groupId)
diff --git a/services/web/app/views/user_membership/publisher-managers-react.pug b/services/web/app/views/user_membership/publisher-managers-react.pug
index 793bdf9602..7f965add73 100644
--- a/services/web/app/views/user_membership/publisher-managers-react.pug
+++ b/services/web/app/views/user_membership/publisher-managers-react.pug
@@ -3,6 +3,10 @@ extends ../layout-marketing
block entrypointVar
- entrypoint = 'pages/user/subscription/group-management/publisher-managers'
+block vars
+ - bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
+ - bootstrap5PageSplitTest = 'bootstrap-5-groups'
+
block append meta
meta(name="ol-users", data-type="json", content=users)
meta(name="ol-groupId", data-type="string", content=groupId)
diff --git a/services/web/frontend/js/features/group-management/components/managers-table.tsx b/services/web/frontend/js/features/group-management/components/managers-table.tsx
index 6eff6c522c..d5950f6578 100644
--- a/services/web/frontend/js/features/group-management/components/managers-table.tsx
+++ b/services/web/frontend/js/features/group-management/components/managers-table.tsx
@@ -1,9 +1,6 @@
import { useCallback, useState } from 'react'
-import { Button, Col, Form, FormControl, Row } from 'react-bootstrap'
import { useTranslation } from 'react-i18next'
import { deleteJSON, FetchError, postJSON } from '@/infrastructure/fetch-json'
-import MaterialIcon from '../../../shared/components/material-icon'
-import Tooltip from '../../../shared/components/tooltip'
import getMeta from '../../../utils/meta'
import { parseEmails } from '../utils/emails'
import ErrorAlert, { APIError } from './error-alert'
@@ -11,6 +8,17 @@ import UserRow from './user-row'
import useUserSelection from '../hooks/use-user-selection'
import { User } from '../../../../../types/group-management/user'
import { debugConsole } from '@/utils/debugging'
+import OLRow from '@/features/ui/components/ol/ol-row'
+import OLCol from '@/features/ui/components/ol/ol-col'
+import BackButton from '@/features/group-management/components/back-button'
+import OLCard from '@/features/ui/components/ol/ol-card'
+import OLButton from '@/features/ui/components/ol/ol-button'
+import OLFormControl from '@/features/ui/components/ol/ol-form-control'
+import OLFormText from '@/features/ui/components/ol/ol-form-text'
+import OLTable from '@/features/ui/components/ol/ol-table'
+import OLTooltip from '@/features/ui/components/ol/ol-tooltip'
+import OLFormCheckbox from '@/features/ui/components/ol/ol-form-checkbox'
+import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
type ManagersPaths = {
addMember: string
@@ -132,136 +140,155 @@ export function ManagersTable({
return (
-
-
-
-
-
- {' '}
- {groupName || translations.title}
-
-
-
+
+
+
+
+
{groupName || translations.title}
+
+
+
{removeMemberInflightCount > 0 ? (
-
+
) : (
<>
{selectedUsers.length > 0 && (
-
+
)}
>
)}
-
{translations.subtitle}
+
{translations.subtitle}
{t('add_more_managers')}
-
+
+
+
+
-
-
-
+
+
+
)
}
diff --git a/services/web/frontend/js/features/group-management/components/user-row.tsx b/services/web/frontend/js/features/group-management/components/user-row.tsx
index 99d93e93b6..fd7fea4b53 100644
--- a/services/web/frontend/js/features/group-management/components/user-row.tsx
+++ b/services/web/frontend/js/features/group-management/components/user-row.tsx
@@ -1,8 +1,11 @@
import moment from 'moment'
import { useCallback } from 'react'
-import { Col, Row } from 'react-bootstrap'
import { useTranslation } from 'react-i18next'
import { User } from '../../../../../types/group-management/user'
+import OLFormCheckbox from '@/features/ui/components/ol/ol-form-checkbox'
+import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
+import Icon from '@/shared/components/icon'
+import MaterialIcon from '@/shared/components/material-icon'
type GroupMemberRowProps = {
user: User
@@ -31,52 +34,75 @@ export default function UserRow({
)
return (
-
-
-
-
- handleSelectUser(e, user)}
+
+ |
+ handleSelectUser(e, user)}
+ aria-label={t('select_user')}
+ data-testid="select-single-checkbox"
+ />
+ }
+ bs5={
+ handleSelectUser(e, user)}
+ aria-label={t('select_user')}
+ data-testid="select-single-checkbox"
+ />
+ }
+ />
+ |
+ {user.email} |
+
+ {user.first_name} {user.last_name}
+ |
+
+ {user.last_active_at
+ ? moment(user.last_active_at).format('Do MMM YYYY')
+ : 'N/A'}
+ |
+
+ {user.invite ? (
+
+ }
+ bs5={
+
+ }
/>
- {user.email}
-
-
- {user.first_name} {user.last_name}
-
-
- {user.last_active_at
- ? moment(user.last_active_at).format('Do MMM YYYY')
- : 'N/A'}
-
-
- {user.invite ? (
- <>
-
- {t('invite_not_accepted')}
- >
- ) : (
- <>
-
- {t('accepted_invite')}
- >
- )}
-
-
-
+ }
+ />
+ )}
+ |
+
)
}
diff --git a/services/web/frontend/stylesheets/bootstrap-5/components/group-members.scss b/services/web/frontend/stylesheets/bootstrap-5/components/group-members.scss
index b6971b2e1d..1c7ba2bde5 100644
--- a/services/web/frontend/stylesheets/bootstrap-5/components/group-members.scss
+++ b/services/web/frontend/stylesheets/bootstrap-5/components/group-members.scss
@@ -71,6 +71,10 @@
text-align: right;
}
+ .cell-accepted-invite {
+ width: 17%;
+ }
+
&.managed-users-active {
.cell-email {
width: 30%;
@@ -131,6 +135,10 @@
text-align: right;
}
+ .cell-accepted-invite {
+ width: 17%;
+ }
+
&.managed-users-active {
.cell-email {
width: 41%;
diff --git a/services/web/frontend/stylesheets/components/group-members.less b/services/web/frontend/stylesheets/components/group-members.less
index 5047034a3d..88c6d9d0f9 100644
--- a/services/web/frontend/stylesheets/components/group-members.less
+++ b/services/web/frontend/stylesheets/components/group-members.less
@@ -126,6 +126,10 @@
min-width: 25px;
}
+ .cell-accepted-invite {
+ width: 17%;
+ }
+
&.managed-users-active {
.cell-email {
width: 35%;
@@ -185,6 +189,10 @@
min-width: 25px;
}
+ .cell-accepted-invite {
+ width: 17%;
+ }
+
&.managed-users-active {
.cell-email {
width: 42%;
diff --git a/services/web/test/frontend/features/group-management/components/group-managers.spec.tsx b/services/web/test/frontend/features/group-management/components/group-managers.spec.tsx
index 464e6878c7..d91660f437 100644
--- a/services/web/test/frontend/features/group-management/components/group-managers.spec.tsx
+++ b/services/web/test/frontend/features/group-management/components/group-managers.spec.tsx
@@ -35,23 +35,25 @@ describe('group managers', function () {
})
it('renders the group management page', function () {
- cy.get('h1').contains('My Awesome Team')
+ cy.findByRole('heading', { name: /my awesome team/i, level: 1 })
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.contains('john.doe@test.com')
- cy.contains('John Doe')
- cy.contains('15th Jan 2023')
- cy.get(`[aria-label="Invite not yet accepted"]`)
- })
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByText('john.doe@test.com')
+ cy.findByText('John Doe')
+ cy.findByText('15th Jan 2023')
+ cy.findByText('Invite not yet accepted')
+ })
- cy.get('li:nth-child(3)').within(() => {
- cy.contains('bobby.lapointe@test.com')
- cy.contains('Bobby Lapointe')
- cy.contains('2nd Jan 2023')
- cy.get(`[aria-label="Accepted invite"]`)
+ cy.get('tr:nth-child(2)').within(() => {
+ cy.findByText('bobby.lapointe@test.com')
+ cy.findByText('Bobby Lapointe')
+ cy.findByText('2nd Jan 2023')
+ cy.findByText('Accepted invite')
+ })
})
- })
})
it('sends an invite', function () {
@@ -65,16 +67,20 @@ describe('group managers', function () {
},
})
- cy.get('.form-control').type('someone.else@test.com')
- cy.get('button').click()
-
- cy.get('ul').within(() => {
- cy.get('li:nth-child(4)').within(() => {
- cy.contains('someone.else@test.com')
- cy.contains('N/A')
- cy.get(`[aria-label="Invite not yet accepted"]`)
- })
+ cy.findByTestId('add-members-form').within(() => {
+ cy.findByRole('textbox').type('someone.else@test.com')
+ cy.findByRole('button').click()
})
+
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(3)').within(() => {
+ cy.findByText('someone.else@test.com')
+ cy.findByText('N/A')
+ cy.findByText('Invite not yet accepted')
+ })
+ })
})
it('tries to send an invite and displays the error', function () {
@@ -87,31 +93,41 @@ describe('group managers', function () {
},
})
- cy.get('.form-control').type('someone.else@test.com')
- cy.get('button').click()
- cy.get('.alert').contains('Error: User already added')
+ cy.findByTestId('add-members-form').within(() => {
+ cy.findByRole('textbox').type('someone.else@test.com')
+ cy.findByRole('button').click()
+ })
+ cy.findByRole('alert').should('contain.text', 'Error: User already added')
})
it('checks the select all checkbox', function () {
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.get('.select-item').should('not.be.checked')
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByLabelText(/select user/i).should('not.be.checked')
+ })
+ cy.get('tr:nth-child(2)').within(() => {
+ cy.findByLabelText(/select user/i).should('not.be.checked')
+ })
})
- cy.get('li:nth-child(3)').within(() => {
- cy.get('.select-item').should('not.be.checked')
- })
- })
- cy.get('.select-all').click()
+ cy.findByTestId('managed-users-table')
+ .find('thead')
+ .within(() => {
+ cy.findByLabelText(/select all/i).check()
+ })
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.get('.select-item').should('be.checked')
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByLabelText(/select user/i).should('be.checked')
+ })
+ cy.get('tr:nth-child(2)').within(() => {
+ cy.findByLabelText(/select user/i).should('be.checked')
+ })
})
- cy.get('li:nth-child(3)').within(() => {
- cy.get('.select-item').should('be.checked')
- })
- })
})
it('remove a member', function () {
@@ -119,22 +135,26 @@ describe('group managers', function () {
statusCode: 200,
})
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.get('.select-item').check()
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByLabelText(/select user/i).check()
+ })
})
- })
- cy.get('button').contains('Remove manager').click()
+ cy.findByRole('button', { name: /remove manager/i }).click()
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.contains('bobby.lapointe@test.com')
- cy.contains('Bobby Lapointe')
- cy.contains('2nd Jan 2023')
- cy.get(`[aria-label="Accepted invite"]`)
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByText('bobby.lapointe@test.com')
+ cy.findByText('Bobby Lapointe')
+ cy.findByText('2nd Jan 2023')
+ cy.findByText('Accepted invite')
+ })
})
- })
})
it('tries to remove a manager and displays the error', function () {
@@ -142,13 +162,15 @@ describe('group managers', function () {
statusCode: 500,
})
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.get('.select-item').check()
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByLabelText(/select user/i).check()
+ })
})
- })
- cy.get('button').contains('Remove manager').click()
+ cy.findByRole('button', { name: /remove manager/i }).click()
- cy.get('.alert').contains('Sorry, something went wrong')
+ cy.findByRole('alert').should('contain.text', 'Sorry, something went wrong')
})
})
diff --git a/services/web/test/frontend/features/group-management/components/institution-managers.spec.tsx b/services/web/test/frontend/features/group-management/components/institution-managers.spec.tsx
index 56eeb85e07..8acbb5d0f6 100644
--- a/services/web/test/frontend/features/group-management/components/institution-managers.spec.tsx
+++ b/services/web/test/frontend/features/group-management/components/institution-managers.spec.tsx
@@ -35,23 +35,25 @@ describe('institution managers', function () {
})
it('renders the institution management page', function () {
- cy.get('h1').contains('My Awesome Institution')
+ cy.findByRole('heading', { name: /my awesome institution/i, level: 1 })
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.contains('john.doe@test.com')
- cy.contains('John Doe')
- cy.contains('15th Jan 2023')
- cy.get(`[aria-label="Invite not yet accepted"]`)
- })
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByText('john.doe@test.com')
+ cy.findByText('John Doe')
+ cy.findByText('15th Jan 2023')
+ cy.findByText('Invite not yet accepted')
+ })
- cy.get('li:nth-child(3)').within(() => {
- cy.contains('bobby.lapointe@test.com')
- cy.contains('Bobby Lapointe')
- cy.contains('2nd Jan 2023')
- cy.get(`[aria-label="Accepted invite"]`)
+ cy.get('tr:nth-child(2)').within(() => {
+ cy.findByText('bobby.lapointe@test.com')
+ cy.findByText('Bobby Lapointe')
+ cy.findByText('2nd Jan 2023')
+ cy.findByText('Accepted invite')
+ })
})
- })
})
it('sends an invite', function () {
@@ -65,16 +67,20 @@ describe('institution managers', function () {
},
})
- cy.get('.form-control').type('someone.else@test.com')
- cy.get('button').click()
-
- cy.get('ul').within(() => {
- cy.get('li:nth-child(4)').within(() => {
- cy.contains('someone.else@test.com')
- cy.contains('N/A')
- cy.get(`[aria-label="Invite not yet accepted"]`)
- })
+ cy.findByTestId('add-members-form').within(() => {
+ cy.findByRole('textbox').type('someone.else@test.com')
+ cy.findByRole('button').click()
})
+
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(3)').within(() => {
+ cy.findByText('someone.else@test.com')
+ cy.findByText('N/A')
+ cy.findByText('Invite not yet accepted')
+ })
+ })
})
it('tries to send an invite and displays the error', function () {
@@ -87,31 +93,41 @@ describe('institution managers', function () {
},
})
- cy.get('.form-control').type('someone.else@test.com')
- cy.get('button').click()
- cy.get('.alert').contains('Error: User already added')
+ cy.findByTestId('add-members-form').within(() => {
+ cy.findByRole('textbox').type('someone.else@test.com')
+ cy.findByRole('button').click()
+ })
+ cy.findByRole('alert').should('contain.text', 'Error: User already added')
})
it('checks the select all checkbox', function () {
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.get('.select-item').should('not.be.checked')
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByLabelText(/select user/i).should('not.be.checked')
+ })
+ cy.get('tr:nth-child(2)').within(() => {
+ cy.findByLabelText(/select user/i).should('not.be.checked')
+ })
})
- cy.get('li:nth-child(3)').within(() => {
- cy.get('.select-item').should('not.be.checked')
- })
- })
- cy.get('.select-all').click()
+ cy.findByTestId('managed-users-table')
+ .find('thead')
+ .within(() => {
+ cy.findByLabelText(/select all/i).check()
+ })
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.get('.select-item').should('be.checked')
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByLabelText(/select user/i).should('be.checked')
+ })
+ cy.get('tr:nth-child(2)').within(() => {
+ cy.findByLabelText(/select user/i).should('be.checked')
+ })
})
- cy.get('li:nth-child(3)').within(() => {
- cy.get('.select-item').should('be.checked')
- })
- })
})
it('remove a member', function () {
@@ -119,22 +135,26 @@ describe('institution managers', function () {
statusCode: 200,
})
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.get('.select-item').check()
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByLabelText(/select user/i).check()
+ })
})
- })
- cy.get('button').contains('Remove manager').click()
+ cy.findByRole('button', { name: /remove manager/i }).click()
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.contains('bobby.lapointe@test.com')
- cy.contains('Bobby Lapointe')
- cy.contains('2nd Jan 2023')
- cy.get(`[aria-label="Accepted invite"]`)
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByText('bobby.lapointe@test.com')
+ cy.findByText('Bobby Lapointe')
+ cy.findByText('2nd Jan 2023')
+ cy.findByText('Accepted invite')
+ })
})
- })
})
it('tries to remove a manager and displays the error', function () {
@@ -142,13 +162,15 @@ describe('institution managers', function () {
statusCode: 500,
})
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.get('.select-item').check()
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByLabelText(/select user/i).check()
+ })
})
- })
- cy.get('button').contains('Remove manager').click()
+ cy.findByRole('button', { name: /remove manager/i }).click()
- cy.get('.alert').contains('Sorry, something went wrong')
+ cy.findByRole('alert').should('contain.text', 'Sorry, something went wrong')
})
})
diff --git a/services/web/test/frontend/features/group-management/components/publisher-managers.spec.tsx b/services/web/test/frontend/features/group-management/components/publisher-managers.spec.tsx
index deb23b0bef..b39fe9e2d2 100644
--- a/services/web/test/frontend/features/group-management/components/publisher-managers.spec.tsx
+++ b/services/web/test/frontend/features/group-management/components/publisher-managers.spec.tsx
@@ -35,23 +35,25 @@ describe('publisher managers', function () {
})
it('renders the publisher management page', function () {
- cy.get('h1').contains('My Awesome Publisher')
+ cy.findByRole('heading', { name: /my awesome publisher/i, level: 1 })
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.contains('john.doe@test.com')
- cy.contains('John Doe')
- cy.contains('15th Jan 2023')
- cy.get(`[aria-label="Invite not yet accepted"]`)
- })
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByText('john.doe@test.com')
+ cy.findByText('John Doe')
+ cy.findByText('15th Jan 2023')
+ cy.findByText('Invite not yet accepted')
+ })
- cy.get('li:nth-child(3)').within(() => {
- cy.contains('bobby.lapointe@test.com')
- cy.contains('Bobby Lapointe')
- cy.contains('2nd Jan 2023')
- cy.get(`[aria-label="Accepted invite"]`)
+ cy.get('tr:nth-child(2)').within(() => {
+ cy.findByText('bobby.lapointe@test.com')
+ cy.findByText('Bobby Lapointe')
+ cy.findByText('2nd Jan 2023')
+ cy.findByText('Accepted invite')
+ })
})
- })
})
it('sends an invite', function () {
@@ -65,16 +67,20 @@ describe('publisher managers', function () {
},
})
- cy.get('.form-control').type('someone.else@test.com')
- cy.get('button').click()
-
- cy.get('ul').within(() => {
- cy.get('li:nth-child(4)').within(() => {
- cy.contains('someone.else@test.com')
- cy.contains('N/A')
- cy.get(`[aria-label="Invite not yet accepted"]`)
- })
+ cy.findByTestId('add-members-form').within(() => {
+ cy.findByRole('textbox').type('someone.else@test.com')
+ cy.findByRole('button').click()
})
+
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(3)').within(() => {
+ cy.findByText('someone.else@test.com')
+ cy.findByText('N/A')
+ cy.findByText('Invite not yet accepted')
+ })
+ })
})
it('tries to send an invite and displays the error', function () {
@@ -87,31 +93,37 @@ describe('publisher managers', function () {
},
})
- cy.get('.form-control').type('someone.else@test.com')
- cy.get('button').click()
- cy.get('.alert').contains('Error: User already added')
+ cy.findByTestId('add-members-form').within(() => {
+ cy.findByRole('textbox').type('someone.else@test.com')
+ cy.findByRole('button').click()
+ })
+ cy.findByRole('alert').should('contain.text', 'Error: User already added')
})
it('checks the select all checkbox', function () {
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.get('.select-item').should('not.be.checked')
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByLabelText(/select user/i).should('not.be.checked')
+ })
+ cy.get('tr:nth-child(2)').within(() => {
+ cy.findByLabelText(/select user/i).should('not.be.checked')
+ })
})
- cy.get('li:nth-child(3)').within(() => {
- cy.get('.select-item').should('not.be.checked')
- })
- })
cy.get('.select-all').click()
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.get('.select-item').should('be.checked')
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByLabelText(/select user/i).should('be.checked')
+ })
+ cy.get('tr:nth-child(2)').within(() => {
+ cy.findByLabelText(/select user/i).should('be.checked')
+ })
})
- cy.get('li:nth-child(3)').within(() => {
- cy.get('.select-item').should('be.checked')
- })
- })
})
it('remove a member', function () {
@@ -119,22 +131,26 @@ describe('publisher managers', function () {
statusCode: 200,
})
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.get('.select-item').check()
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByLabelText(/select user/i).check()
+ })
})
- })
- cy.get('button').contains('Remove manager').click()
+ cy.findByRole('button', { name: 'Remove manager' }).click()
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.contains('bobby.lapointe@test.com')
- cy.contains('Bobby Lapointe')
- cy.contains('2nd Jan 2023')
- cy.get(`[aria-label="Accepted invite"]`)
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByText('bobby.lapointe@test.com')
+ cy.findByText('Bobby Lapointe')
+ cy.findByText('2nd Jan 2023')
+ cy.findByText('Accepted invite')
+ })
})
- })
})
it('tries to remove a manager and displays the error', function () {
@@ -142,13 +158,15 @@ describe('publisher managers', function () {
statusCode: 500,
})
- cy.get('ul').within(() => {
- cy.get('li:nth-child(2)').within(() => {
- cy.get('.select-item').check()
+ cy.findByTestId('managed-users-table')
+ .find('tbody')
+ .within(() => {
+ cy.get('tr:nth-child(1)').within(() => {
+ cy.findByLabelText(/select user/i).check()
+ })
})
- })
- cy.get('button').contains('Remove manager').click()
+ cy.findByRole('button', { name: /remove manager/i }).click()
- cy.get('.alert').contains('Sorry, something went wrong')
+ cy.findByRole('alert').should('contain.text', 'Sorry, something went wrong')
})
})