Skip to content

Commit

Permalink
test: improve selectors specificity (#32665)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliajforesti authored Jun 24, 2024
1 parent e07a515 commit 209a062
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions apps/meteor/client/components/FilterByText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const FilterByText = forwardRef<HTMLInputElement, FilterByTextProps>(function Fi
value={text}
flexGrow={2}
minWidth='x220'
aria-label={placeholder ?? t('Search')}
/>
</Box>
{isFilterByTextPropsWithButton(props) ? (
Expand Down
8 changes: 5 additions & 3 deletions apps/meteor/client/views/omnichannel/managers/AddManager.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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 type { ReactElement } from 'react';
import React, { useState } from 'react';
Expand All @@ -12,6 +12,8 @@ const AddManager = ({ reload }: { reload: () => void }): ReactElement => {
const [username, setUsername] = useState('');
const dispatchToastMessage = useToastMessageDispatch();

const usernameFieldId = useUniqueId();

const saveAction = useEndpointAction('POST', '/v1/livechat/users/manager');

const handleSave = useMutableCallback(async () => {
Expand All @@ -34,9 +36,9 @@ const AddManager = ({ reload }: { reload: () => void }): ReactElement => {
return (
<Box display='flex' alignItems='center'>
<Field>
<FieldLabel>{t('Username')}</FieldLabel>
<FieldLabel htmlFor={usernameFieldId}>{t('Username')}</FieldLabel>
<FieldRow>
<UserAutoComplete value={username} onChange={handleChange} />
<UserAutoComplete id={usernameFieldId} value={username} onChange={handleChange} />
<Button disabled={!username} onClick={handleSave} mis={8} primary>
{t('Add_manager')}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/page-objects/omnichannel-agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class OmnichannelAgents {
}

get inputSearch(): Locator {
return this.page.locator('[placeholder="Search"]');
return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
}

get btnAdd(): Locator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class OmnichannelBusinessHours extends OmnichannelAdministration {
}

get inputSearch(): Locator {
return this.page.locator('[placeholder="Search"]');
return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
}

get inputName(): Locator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class OmnichannelCustomFields {
}

get inputSearch(): Locator {
return this.page.locator('[placeholder="Search"]');
return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
}

firstRowInTable(filedName: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class OmnichannelDepartments {
}

get inputSearch() {
return this.page.locator('[placeholder="Search"]');
return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
}

async search(text: string) {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/tests/e2e/page-objects/omnichannel-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class OmnichannelManager {
}

private get inputSearch() {
return this.page.locator('[placeholder="Search"]');
return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
}

async search(text: string) {
Expand All @@ -27,7 +27,7 @@ export class OmnichannelManager {
}

get inputUsername(): Locator {
return this.page.locator('input').first();
return this.page.getByRole('main').getByLabel('Username');
}

async selectUsername(username: string) {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/page-objects/omnichannel-monitors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class OmnichannelMonitors extends OmnichannelAdministration {
}

get inputSearch(): Locator {
return this.page.locator('input[placeholder="Search"]');
return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
}

findRowByName(name: string): Locator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class OmnichannelSlaPolicies {
}

get inputSearch() {
return this.page.locator('[placeholder="Search"]');
return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
}

headingButtonNew(name: string) {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/page-objects/omnichannel-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class OmnichannelTags extends OmnichannelAdministration {
}

get inputSearch(): Locator {
return this.page.locator('[placeholder="Search"]');
return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
}

get confirmDeleteModal(): Locator {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/page-objects/omnichannel-units.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { OmnichannelAdministration } from './omnichannel-administration';

export class OmnichannelUnits extends OmnichannelAdministration {
get inputSearch() {
return this.page.locator('[placeholder="Search"]');
return this.page.getByRole('main').getByRole('textbox', { name: 'Search' });
}

async search(text: string) {
Expand Down

0 comments on commit 209a062

Please sign in to comment.