-
Notifications
You must be signed in to change notification settings - Fork 108
INSTUI-4672 Add the (almost complete) regression test suite, fix small a11y issues, SSR errors #2105
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
INSTUI-4672 Add the (almost complete) regression test suite, fix small a11y issues, SSR errors #2105
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,7 @@ | |
| "@types/react-dom": "^18.3.0", | ||
| "@vitejs/plugin-react": "^4.5.1", | ||
| "@vitest/eslint-plugin": "^1.2.1", | ||
| "@types/node": "^22", | ||
| "chai": "^4.4.1", | ||
| "chalk": "^4.1.2", | ||
| "commitizen": "^4.3.1", | ||
|
|
@@ -101,7 +102,7 @@ | |
| "@types/jest": "needed because https://github.com/testing-library/jest-dom/issues/544 recheck if fixed" | ||
| }, | ||
| "engines": { | ||
| "node": ">=18", | ||
| "node": ">=22", | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated this to be in sync with what we use in Github actions |
||
| "yarn": "YARN NO LONGER USED - use npm instead." | ||
| }, | ||
| "config": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,11 +28,11 @@ import { View } from '@instructure/ui-view' | |
| import { | ||
| safeCloneElement, | ||
| callRenderProp, | ||
| omitProps | ||
| omitProps, | ||
| withDeterministicId | ||
| } from '@instructure/ui-react-utils' | ||
| import { createChainedFunction } from '@instructure/ui-utils' | ||
| import { logError as error } from '@instructure/console' | ||
| import { uid } from '@instructure/uid' | ||
| import { AccessibleContent } from '@instructure/ui-a11y-content' | ||
|
|
||
| import { testable } from '@instructure/ui-testable' | ||
|
|
@@ -64,6 +64,7 @@ import { SimpleSelect } from '@instructure/ui-simple-select' | |
| category: components | ||
| --- | ||
| **/ | ||
| @withDeterministicId() | ||
| @withStyle(generateStyle, generateComponentTheme) | ||
| @testable() | ||
| class Calendar extends Component<CalendarProps, CalendarState> { | ||
|
|
@@ -82,14 +83,15 @@ class Calendar extends Component<CalendarProps, CalendarState> { | |
| } | ||
|
|
||
| ref: Element | null = null | ||
| private _weekdayHeaderIds = ( | ||
| this.props.renderWeekdayLabels || this.defaultWeekdays | ||
| ).reduce((ids: Record<number, string>, _label, i) => { | ||
| return { ...ids, [i]: uid(`weekday-header-${i}`) } | ||
| }, {}) | ||
| private _weekdayHeaderIds | ||
|
|
||
| constructor(props: CalendarProps) { | ||
| super(props) | ||
|
|
||
| this._weekdayHeaderIds = ( | ||
| this.props.renderWeekdayLabels || this.defaultWeekdays | ||
| ).reduce((ids: Record<number, string>, _label, i) => { | ||
| return { ...ids, [i]: this.props.deterministicId!('weekday-header') } | ||
| }, {}) | ||
|
Comment on lines
+90
to
+94
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SSR bugfix due to ID not being deterministic |
||
| this.state = this.calculateState( | ||
| this.locale(), | ||
| this.timezone(), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,10 +45,10 @@ export function runTest(codemod: Transform) { | |
| entries.forEach((entry) => { | ||
| if (entry.isFile() && entry.name.includes('input')) { | ||
| const isWarningTest = entry.name.includes('.warning.input') | ||
| const inputPath = path.join(entry.path, entry.name) | ||
| const inputPath = path.join(entry.parentPath, entry.name) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| const input = fs.readFileSync(inputPath, 'utf8') | ||
| const expectedName = entry.name.replace('input', 'output') | ||
| const expectedPath = path.join(entry.path, expectedName) | ||
| const expectedPath = path.join(entry.parentPath, expectedName) | ||
| const expected = fs.readFileSync(expectedPath, 'utf8') | ||
|
|
||
| // eslint-disable-next-line no-console | ||
|
|
@@ -61,12 +61,17 @@ export function runTest(codemod: Transform) { | |
| ) | ||
|
|
||
| if (isWarningTest) { | ||
| const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => { }) | ||
| const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}) | ||
|
|
||
| try { | ||
| const j = jscodeshift.withParser('tsx') | ||
| const fileInfo = { path: inputPath, source: input } | ||
| const api = { jscodeshift: j, j: j, stats: () => { }, report: () => { } } | ||
| const api = { | ||
| jscodeshift: j, | ||
| j: j, | ||
| stats: () => {}, | ||
| report: () => {} | ||
| } | ||
| const options = {} | ||
|
|
||
| // Run codemod withouth comparison | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1126,7 +1126,7 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> { | |
| if (subPageId) { | ||
| optionProps.renderAfterLabel = <IconArrowOpenEndSolid /> | ||
| optionProps['aria-haspopup'] = true | ||
| optionProps.role = customRole || 'button' | ||
| optionProps.role = customRole || 'menuitem' | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drilldown has |
||
| warn( | ||
| !renderAfterLabel, | ||
| `The prop "renderAfterLabel" is reserved on item with id: "${id}". When it has "subPageId" provided, a navigation arrow will render after the label.` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,9 +49,9 @@ Pre-configured and with unique styles, the `ai-headings` are used for standardiz | |
| type: example | ||
| --- | ||
| <div style={{display: 'flex', flexDirection: 'column', gap: '24px'}}> | ||
| <Heading aiVariant="stacked">Nutrition Facts</Heading> | ||
| <Heading aiVariant="horizontal">Nutrition Facts</Heading> | ||
| <Heading aiVariant="iconOnly">Nutrition Facts</Heading> | ||
| <Heading aiVariant="stacked" level="h2">Nutrition Facts</Heading> | ||
| <Heading aiVariant="horizontal" level="h3">Nutrition Facts</Heading> | ||
| <Heading aiVariant="iconOnly" level="h4">Nutrition Facts</Heading> | ||
|
Comment on lines
+52
to
+54
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean |
||
| </div> | ||
| ``` | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,12 +63,11 @@ const generateStyle = ( | |
| background: componentTheme.selectedBackground, | ||
| color: componentTheme.highlightedLabelColor | ||
| }, | ||
| disabled: { cursor: 'not-allowed', opacity: 0.5 }, | ||
| disabled: { cursor: 'not-allowed', opacity: 0.68 }, | ||
| 'highlighted-disabled': { | ||
| background: componentTheme.highlightedBackground, | ||
| color: componentTheme.highlightedLabelColor, | ||
| cursor: 'not-allowed', | ||
| opacity: 0.5 | ||
| cursor: 'not-allowed' | ||
|
Comment on lines
+66
to
+70
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These needed the opacity to be increased, otherwise they would fail color contract a11y tests. AFAIK we are not using this directly anywhere, so it should be OK |
||
| }, | ||
| 'selected-highlighted': { | ||
| background: componentTheme.selectedHighlightedBackground, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must be added otherwise it will just pick up a
@types/nodeversion from a dependency