Skip to content
Snippets Groups Projects
Unverified Commit 209a0628 authored by Júlia Jaeger Foresti's avatar Júlia Jaeger Foresti Committed by GitHub
Browse files

test: improve selectors specificity (#32665)

parent e07a5158
No related branches found
No related tags found
No related merge requests found
Showing
with 16 additions and 13 deletions
...@@ -54,6 +54,7 @@ const FilterByText = forwardRef<HTMLInputElement, FilterByTextProps>(function Fi ...@@ -54,6 +54,7 @@ const FilterByText = forwardRef<HTMLInputElement, FilterByTextProps>(function Fi
value={text} value={text}
flexGrow={2} flexGrow={2}
minWidth='x220' minWidth='x220'
aria-label={placeholder ?? t('Search')}
/> />
</Box> </Box>
{isFilterByTextPropsWithButton(props) ? ( {isFilterByTextPropsWithButton(props) ? (
......
import { Button, Box, Field, FieldLabel, FieldRow } from '@rocket.chat/fuselage'; import { Button, Box, Field, FieldLabel, FieldRow } from '@rocket.chat/fuselage';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; import { useMutableCallback, useUniqueId } from '@rocket.chat/fuselage-hooks';
import { useToastMessageDispatch, useTranslation } from '@rocket.chat/ui-contexts'; import { useToastMessageDispatch, useTranslation } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react'; import type { ReactElement } from 'react';
import React, { useState } from 'react'; import React, { useState } from 'react';
...@@ -12,6 +12,8 @@ const AddManager = ({ reload }: { reload: () => void }): ReactElement => { ...@@ -12,6 +12,8 @@ const AddManager = ({ reload }: { reload: () => void }): ReactElement => {
const [username, setUsername] = useState(''); const [username, setUsername] = useState('');
const dispatchToastMessage = useToastMessageDispatch(); const dispatchToastMessage = useToastMessageDispatch();
const usernameFieldId = useUniqueId();
const saveAction = useEndpointAction('POST', '/v1/livechat/users/manager'); const saveAction = useEndpointAction('POST', '/v1/livechat/users/manager');
const handleSave = useMutableCallback(async () => { const handleSave = useMutableCallback(async () => {
...@@ -34,9 +36,9 @@ const AddManager = ({ reload }: { reload: () => void }): ReactElement => { ...@@ -34,9 +36,9 @@ const AddManager = ({ reload }: { reload: () => void }): ReactElement => {
return ( return (
<Box display='flex' alignItems='center'> <Box display='flex' alignItems='center'>
<Field> <Field>
<FieldLabel>{t('Username')}</FieldLabel> <FieldLabel htmlFor={usernameFieldId}>{t('Username')}</FieldLabel>
<FieldRow> <FieldRow>
<UserAutoComplete value={username} onChange={handleChange} /> <UserAutoComplete id={usernameFieldId} value={username} onChange={handleChange} />
<Button disabled={!username} onClick={handleSave} mis={8} primary> <Button disabled={!username} onClick={handleSave} mis={8} primary>
{t('Add_manager')} {t('Add_manager')}
</Button> </Button>
......
...@@ -23,7 +23,7 @@ export class OmnichannelAgents { ...@@ -23,7 +23,7 @@ export class OmnichannelAgents {
} }
get inputSearch(): Locator { get inputSearch(): Locator {
return this.page.locator('[placeholder="Search"]'); return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
} }
get btnAdd(): Locator { get btnAdd(): Locator {
......
...@@ -20,7 +20,7 @@ export class OmnichannelBusinessHours extends OmnichannelAdministration { ...@@ -20,7 +20,7 @@ export class OmnichannelBusinessHours extends OmnichannelAdministration {
} }
get inputSearch(): Locator { get inputSearch(): Locator {
return this.page.locator('[placeholder="Search"]'); return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
} }
get inputName(): Locator { get inputName(): Locator {
......
...@@ -33,7 +33,7 @@ export class OmnichannelCustomFields { ...@@ -33,7 +33,7 @@ export class OmnichannelCustomFields {
} }
get inputSearch(): Locator { get inputSearch(): Locator {
return this.page.locator('[placeholder="Search"]'); return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
} }
firstRowInTable(filedName: string) { firstRowInTable(filedName: string) {
......
...@@ -13,7 +13,7 @@ export class OmnichannelDepartments { ...@@ -13,7 +13,7 @@ export class OmnichannelDepartments {
} }
get inputSearch() { get inputSearch() {
return this.page.locator('[placeholder="Search"]'); return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
} }
async search(text: string) { async search(text: string) {
......
...@@ -13,7 +13,7 @@ export class OmnichannelManager { ...@@ -13,7 +13,7 @@ export class OmnichannelManager {
} }
private get inputSearch() { private get inputSearch() {
return this.page.locator('[placeholder="Search"]'); return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
} }
async search(text: string) { async search(text: string) {
...@@ -27,7 +27,7 @@ export class OmnichannelManager { ...@@ -27,7 +27,7 @@ export class OmnichannelManager {
} }
get inputUsername(): Locator { get inputUsername(): Locator {
return this.page.locator('input').first(); return this.page.getByRole('main').getByLabel('Username');
} }
async selectUsername(username: string) { async selectUsername(username: string) {
......
...@@ -20,7 +20,7 @@ export class OmnichannelMonitors extends OmnichannelAdministration { ...@@ -20,7 +20,7 @@ export class OmnichannelMonitors extends OmnichannelAdministration {
} }
get inputSearch(): Locator { get inputSearch(): Locator {
return this.page.locator('input[placeholder="Search"]'); return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
} }
findRowByName(name: string): Locator { findRowByName(name: string): Locator {
......
...@@ -60,7 +60,7 @@ export class OmnichannelSlaPolicies { ...@@ -60,7 +60,7 @@ export class OmnichannelSlaPolicies {
} }
get inputSearch() { get inputSearch() {
return this.page.locator('[placeholder="Search"]'); return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
} }
headingButtonNew(name: string) { headingButtonNew(name: string) {
......
...@@ -24,7 +24,7 @@ export class OmnichannelTags extends OmnichannelAdministration { ...@@ -24,7 +24,7 @@ export class OmnichannelTags extends OmnichannelAdministration {
} }
get inputSearch(): Locator { get inputSearch(): Locator {
return this.page.locator('[placeholder="Search"]'); return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
} }
get confirmDeleteModal(): Locator { get confirmDeleteModal(): Locator {
......
...@@ -4,7 +4,7 @@ import { OmnichannelAdministration } from './omnichannel-administration'; ...@@ -4,7 +4,7 @@ import { OmnichannelAdministration } from './omnichannel-administration';
export class OmnichannelUnits extends OmnichannelAdministration { export class OmnichannelUnits extends OmnichannelAdministration {
get inputSearch() { get inputSearch() {
return this.page.locator('[placeholder="Search"]'); return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
} }
async search(text: string) { async search(text: string) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment