Skip to content

Commit

Permalink
chore: Upgrade tsconfigs
Browse files Browse the repository at this point in the history
  • Loading branch information
just-boris committed Aug 7, 2023
1 parent d87a49a commit c4093fc
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 33 deletions.
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
21 changes: 10 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 useBrowser from '@cloudscape-design/browser-test-tools/use-browser';
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,21 +19,20 @@ function setupTest(url: string, testFn: (page: A11yPageObject) => Promise<void>)
}

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 testFunction = [
...skip,
'theming/tokens',
// this page intentionally has issues to test the helper
'undefined-texts',
].includes(inputUrl)
? test
: test.skip;
const url = urlFormatter(inputUrl, theme, mode);
testFunction(
url,
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),
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
4 changes: 1 addition & 3 deletions tsconfig.integ.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"extends": "@tsconfig/node16/tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"lib": ["es2017", "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

0 comments on commit c4093fc

Please sign in to comment.