Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NoQA] Add eslint-plugin-testing-library #41203

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const restrictedImportPatterns = [

module.exports = {
extends: ['expensify', 'plugin:storybook/recommended', 'plugin:react-native-a11y/basic', 'plugin:@dword-design/import-alias/recommended', 'prettier'],
plugins: ['react-native-a11y'],
plugins: ['react-native-a11y', 'testing-library'],
parser: 'babel-eslint',
ignorePatterns: ['!.*', 'src/vendor', '.github/actions/**/index.js', 'desktop/dist/*.js', 'dist/*.js', 'node_modules/.bin/**', 'node_modules/.cache/**', '.git/**'],
env: {
Expand Down Expand Up @@ -129,6 +129,20 @@ module.exports = {
files: ['tests/**/*.js', 'tests/**/*.ts', 'tests/**/*.jsx', 'assets/**/*.js', '.storybook/**/*.js'],
rules: {'@dword-design/import-alias/prefer-alias': ['off']},
},
{
files: ['tests/**/*.js', 'tests/**/*.ts', 'tests/**/*.jsx', 'tests/**/*.tsx'],
extends: ['plugin:testing-library/react'],
rules: {
'testing-library/await-async-queries': 'error',
'testing-library/await-async-utils': 'error',
'testing-library/no-debugging-utils': 'error',
'testing-library/no-manual-cleanup': 'error',
'testing-library/no-unnecessary-act': 'error',
'testing-library/prefer-find-by': 'error',
'testing-library/prefer-presence-queries': 'error',
'testing-library/prefer-screen-queries': 'error',
},
},
{
files: ['*.js', '*.jsx'],
settings: {
Expand Down
34 changes: 26 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react-native-a11y": "^3.3.0",
"eslint-plugin-storybook": "^0.8.0",
"eslint-plugin-testing-library": "^6.2.2",
"eslint-plugin-you-dont-need-lodash-underscore": "^6.12.0",
"html-webpack-plugin": "^5.5.0",
"jest": "29.4.1",
Expand Down
16 changes: 8 additions & 8 deletions tests/ui/UnreadIndicatorsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,11 @@ describe('Unread Indicators', () => {
expect(displayNameTexts).toHaveLength(2);
const firstReportOption = displayNameTexts[0];
expect(firstReportOption?.props?.style?.fontWeight).toBe(FontUtils.fontWeight.bold);
expect(firstReportOption?.props?.children?.[0]).toBe('C User');
expect(screen.getByText('C User')).toBeOnTheScreen();

const secondReportOption = displayNameTexts[1];
expect(secondReportOption?.props?.style?.fontWeight).toBe(FontUtils.fontWeight.bold);
expect(secondReportOption?.props?.children?.[0]).toBe('B User');
expect(screen.getByText('B User')).toBeOnTheScreen();

// Tap the new report option and navigate back to the sidebar again via the back button
return navigateToSidebarOption(0);
Expand All @@ -456,9 +456,9 @@ describe('Unread Indicators', () => {
const displayNameTexts = screen.queryAllByLabelText(hintText);
expect(displayNameTexts).toHaveLength(2);
expect(displayNameTexts[0]?.props?.style?.fontWeight).toBe(undefined);
expect(displayNameTexts[0]?.props?.children?.[0]).toBe('C User');
expect(screen.getAllByText('C User')[0]).toBeOnTheScreen();
expect(displayNameTexts[1]?.props?.style?.fontWeight).toBe(FontUtils.fontWeight.bold);
expect(displayNameTexts[1]?.props?.children?.[0]).toBe('B User');
expect(screen.getByText('B User')).toBeOnTheScreen();
}));

xit('Manually marking a chat message as unread shows the new line indicator and updates the LHN', () =>
Expand Down Expand Up @@ -490,7 +490,7 @@ describe('Unread Indicators', () => {
const displayNameTexts = screen.queryAllByLabelText(hintText);
expect(displayNameTexts).toHaveLength(1);
expect(displayNameTexts[0]?.props?.style?.fontWeight).toBe(FontUtils.fontWeight.bold);
expect(displayNameTexts[0]?.props?.children?.[0]).toBe('B User');
expect(screen.getByText('B User')).toBeOnTheScreen();

// Navigate to the report again and back to the sidebar
return navigateToSidebarOption(0);
Expand All @@ -502,7 +502,7 @@ describe('Unread Indicators', () => {
const displayNameTexts = screen.queryAllByLabelText(hintText);
expect(displayNameTexts).toHaveLength(1);
expect(displayNameTexts[0]?.props?.style?.fontWeight).toBe(undefined);
expect(displayNameTexts[0]?.props?.children?.[0]).toBe('B User');
expect(screen.getByText('B User')).toBeOnTheScreen();

// Navigate to the report again and verify the new line indicator is missing
return navigateToSidebarOption(0);
Expand Down Expand Up @@ -615,7 +615,7 @@ describe('Unread Indicators', () => {
const hintText = Localize.translateLocal('accessibilityHints.lastChatMessagePreview');
const alternateText = screen.queryAllByLabelText(hintText);
expect(alternateText).toHaveLength(1);
expect(alternateText[0].props.children).toBe('Current User Comment 1');
expect(screen.getByText('Current User Comment 1')).toBeOnTheScreen();

if (lastReportAction) {
Report.deleteReportComment(REPORT_ID, lastReportAction);
Expand All @@ -626,7 +626,7 @@ describe('Unread Indicators', () => {
const hintText = Localize.translateLocal('accessibilityHints.lastChatMessagePreview');
const alternateText = screen.queryAllByLabelText(hintText);
expect(alternateText).toHaveLength(1);
expect(alternateText[0].props.children).toBe('Comment 9');
expect(screen.getAllByText('Comment 9')[0]).toBeOnTheScreen();
})
);
});
Expand Down
Loading
Loading