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

chore: Upgrade tsconfigs #1419

Merged
merged 1 commit into from
Aug 8, 2023
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
3 changes: 1 addition & 2 deletions pages/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ function App() {
urlParams: { density, motionDisabled },
} = useContext(AppContext);

const isAppLayout =
pageId !== undefined && (pageId.indexOf('app-layout') > -1 || pageId.indexOf('content-layout') > -1);
const isAppLayout = pageId !== undefined && (pageId.includes('app-layout') || pageId.includes('content-layout'));
// AppLayout already contains <main>
// Also, AppLayout pages should resemble the ConsoleNav 2.0 styles
const ContentTag = isAppLayout ? 'div' : 'main';
Expand Down
2 changes: 1 addition & 1 deletion pages/cards/selection.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface Item {
const ariaLabels: CardsProps<Item>['ariaLabels'] = {
selectionGroupLabel: 'group label',
itemSelectionLabel: ({ selectedItems }, item) =>
`${item.text} is ${selectedItems.indexOf(item) < 0 ? 'not ' : ''}selected`,
`${item.text} is ${!selectedItems.includes(item) ? 'not ' : ''}selected`,
};

function createSimpleItems(count: number) {
Expand Down
2 changes: 1 addition & 1 deletion pages/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"lib": ["ES2015", "DOM"],
"lib": ["ES2020", "DOM"],
"target": "ES2015",
"declaration": false,
"declarationMap": false,
Expand Down
20 changes: 9 additions & 11 deletions src/__a11y__/run-a11y-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { findAllPages } from '../__integ__/utils';
import A11yPageObject from './a11y-page-object';

type Theme = string;
type Theme = 'default' | 'visual-refresh';
type Mode = 'light' | 'dark';

function setupTest(url: string, testFn: (page: A11yPageObject) => Promise<void>) {
Expand All @@ -19,23 +19,21 @@
}

function urlFormatter(inputUrl: string, theme: Theme, mode: Mode) {
return `#/${mode}/${inputUrl}?visualRefresh=${theme.indexOf('visual-refresh') !== -1 ? 'true' : 'false'}`;
return `#/${mode}/${inputUrl}?visualRefresh=${theme === 'visual-refresh' ? 'true' : 'false'}`;
}

export default function runA11yTests(theme: Theme, mode: Mode, skip: string[] = []) {
describe(`A11y checks for ${mode} ${theme}`, () => {
findAllPages().forEach(inputUrl => {
const testFunction =
[
...skip,
'theming/tokens',
// this page intentionally has issues to test the helper
'undefined-texts',
].indexOf(inputUrl) === -1
? test
: test.skip;
const skipPages = [
...skip,
'theming/tokens',
// this page intentionally has issues to test the helper
'undefined-texts',
];
const testFunction = skipPages.includes(inputUrl) ? test.skip : test;
const url = urlFormatter(inputUrl, theme, mode);
testFunction(

Check warning on line 36 in src/__a11y__/run-a11y-tests.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components accessibility tests

RETRY 1: A11y checks for dark default › #/dark/date-range-picker/calendar-permutations?visualRefresh=false

thrown: "Exceeded timeout of 60000 ms for a test. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test." at src/__a11y__/run-a11y-tests.ts:36:7 at Array.forEach (<anonymous>) at src/__a11y__/run-a11y-tests.ts:27:20 at runA11yTests (src/__a11y__/run-a11y-tests.ts:26:3) at Object.<anonymous> (src/__a11y__/a11y-dark.test.ts:5:13)

Check warning on line 36 in src/__a11y__/run-a11y-tests.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components accessibility tests

RETRY 1: A11y checks for light visual-refresh › #/light/date-range-picker/calendar-permutations?visualRefresh=true

thrown: "Exceeded timeout of 60000 ms for a test. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test." at src/__a11y__/run-a11y-tests.ts:36:7 at Array.forEach (<anonymous>) at src/__a11y__/run-a11y-tests.ts:27:20 at runA11yTests (src/__a11y__/run-a11y-tests.ts:26:3) at Object.<anonymous> (src/__a11y__/a11y-refresh-light.test.ts:5:13)

Check warning on line 36 in src/__a11y__/run-a11y-tests.ts

View workflow job for this annotation

GitHub Actions / dry-run / Components accessibility tests

RETRY 1: A11y checks for dark visual-refresh › #/dark/date-range-picker/calendar-permutations?visualRefresh=true

thrown: "Exceeded timeout of 60000 ms for a test. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test." at src/__a11y__/run-a11y-tests.ts:36:7 at Array.forEach (<anonymous>) at src/__a11y__/run-a11y-tests.ts:27:20 at runA11yTests (src/__a11y__/run-a11y-tests.ts:26:3) at Object.<anonymous> (src/__a11y__/a11y-refresh-dark.test.ts:5:13)
url,
setupTest(url, page => page.assertNoAxeViolations())
);
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/form-field-controls-integration.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ formFieldControlComponents.forEach(({ componentName, findNativeElement }) => {
}

describe(`${componentName}`, () => {
const isGroupComponent = ['radio-group', 'tiles'].indexOf(componentName) !== -1;
const isGroupComponent = ['radio-group', 'tiles'].includes(componentName);
if (!isGroupComponent) {
describe('controlId', () => {
test('applies controlId from FormField when controlId is not set on itself', () => {
Expand Down
11 changes: 0 additions & 11 deletions src/multiselect/__integ__/page-objects/multiselect-page.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { strict as assert } from 'assert';
import { MultiselectWrapper } from '../../../../lib/components/test-utils/selectors';
import SelectPageObject from '../../../select/__integ__/page-objects/select-page';
import optionStyles from '../../../../lib/components/internal/components/option/styles.selectors.js';
import selectableItemStyles from '../../../../lib/components/internal/components/selectable-item/styles.selectors.js';

export default class MultiselectPageObject extends SelectPageObject<MultiselectWrapper> {
getOptionInGroup(groupNumber: number, optionNumber: number) {
Expand All @@ -15,15 +13,6 @@ export default class MultiselectPageObject extends SelectPageObject<MultiselectW
await this.click(this.getOptionInGroup(groupNumber, optionNumber));
}

async assertOptionSelected(groupNumber: number, optionNumber: number, isSelected: boolean) {
const className = await this.getElementAttribute(this.getOptionInGroup(groupNumber, optionNumber), 'class');
assert.equal(
className.indexOf(selectableItemStyles.selected),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line contained a bug, used indexOf() instead of indexOf() > -1.

Because this code is not used in any tests, it is easier to remove than fixing

isSelected,
`Option should be ${isSelected ? '' : 'not '} selected`
);
}

clickTokenToggle() {
return this.click(this.wrapper.findTokenToggle().toSelector());
}
Expand Down
2 changes: 1 addition & 1 deletion src/test-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"incremental": true,
"module": "CommonJS",
"target": "ES2015",
"lib": ["ES2015", "DOM"],
"lib": ["ES2020", "DOM"],
"declaration": true,
"allowSyntheticDefaultImports": true,
"outDir": "../../lib/components/test-utils",
Expand Down
5 changes: 2 additions & 3 deletions tsconfig.integ.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "@tsconfig/node16/tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"lib": ["es2017", "dom"],
"lib": ["es2020", "dom"],
"types": ["jest"],
"noEmit": true,
"strict": true,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"lib": ["ES2015", "ES2017.Intl", "ES2018.Intl", "ES2020.Intl", "DOM"],
"lib": ["ES2020", "DOM"],
"target": "ES2015",
"types": [],
"module": "ES2015",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.unit.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es2018",
"lib": ["es2018", "dom"],
"lib": ["es2020", "dom"],
"types": ["node", "jest", "@testing-library/jest-dom"],
"moduleResolution": "node",
"downlevelIteration": true,
Expand Down
Loading