-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix: Remove act from selectors #64
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,25 +4,41 @@ | |
|
||
// This file converts example input into selector utils and checks that the result compiles by Typescript | ||
const fs = require('fs'); | ||
const glob = require('glob'); | ||
const path = require('path'); | ||
const { execSync } = require('child_process'); | ||
const convertToSelectorUtil = require(path.join(__dirname, '../lib/converter/dist')).default; | ||
|
||
// These test files include utils represented as external dependencies to properly test their conversion to selectors. | ||
// We need to skip them here because they are not expected to compile correctly. | ||
const skip = ['strip-external-imports.ts']; | ||
|
||
const inputDir = path.join(__dirname, '../src/converter/test/inputs/converter'); | ||
const outputDir = path.join(__dirname, '../src/converter/test/outputs/converter'); | ||
|
||
fs.rmSync(outputDir, { recursive: true, force: true }); | ||
fs.mkdirSync(outputDir, { recursive: true }); | ||
fs.readdirSync(inputDir).forEach(name => { | ||
if (skip.includes(name)) { | ||
return; | ||
} | ||
|
||
const source = fs.readFileSync(path.join(inputDir, name), 'utf-8').trim(); | ||
const result = convertToSelectorUtil(source); | ||
fs.writeFileSync(path.join(outputDir, name), result); | ||
}); | ||
|
||
const includedInputFiles = glob.sync('src/converter/test/inputs/converter/*.ts').filter(file => { | ||
const fileName = file.split('/').pop(); | ||
return !skip.includes(fileName); | ||
}); | ||
|
||
// Command-line API does not allow to use tsconfig when compiling only selected files | ||
// https://github.com/microsoft/TypeScript/issues/27379 | ||
execSync( | ||
`tsc --noEmit --strict --experimentalDecorators --target es5 src/converter/test/inputs/converter/*.ts src/converter/test/outputs/converter/*.ts`, | ||
`tsc --noEmit --strict --experimentalDecorators --target es5 ${includedInputFiles.join( | ||
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. There is no built-in flag provided by |
||
' ' | ||
)} src/converter/test/outputs/converter/*.ts`, | ||
|
||
{ | ||
stdio: 'inherit', | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/converter/test/inputs/converter/strip-external-imports.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
/* eslint-env browser */ | ||
import { ComponentWrapper, usesDom } from '@cloudscape-design/test-utils-core/dom'; | ||
import { KeyCode } from '@cloudscape-design/test-utils-core/utils'; | ||
import { act } from '@cloudscape-design/test-utils-core/utils-dom'; | ||
|
||
import ChildWrapper from './simple'; | ||
|
||
export default class DummyWrapper extends ComponentWrapper { | ||
findElement(): ChildWrapper { | ||
return new ChildWrapper(this.find('.awsui-child')!.getElement()); | ||
} | ||
|
||
@usesDom | ||
findDomElement(): ChildWrapper { | ||
return new ChildWrapper(this.find('.awsui-child')!.getElement()); | ||
} | ||
|
||
@usesDom | ||
openDropdown(): void { | ||
act(() => { | ||
this.findElement().click(); | ||
}); | ||
} | ||
|
||
findSomething(): number { | ||
return KeyCode.enter; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Use this file for any utilities specific to React/ReactDOM APIs or those that depend on them. | ||
|
||
import * as React from 'react'; | ||
import { act as reactDomAct } from 'react-dom/test-utils'; | ||
|
||
export const act = ('act' in React ? React.act : reactDomAct) as typeof reactDomAct; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 change and everything else in this file seems like too much work to work around this issue.
Alternative options
paths
ortypeRoots
options from tsconfig.converter-no-typecheck
folder (seems easier than writing that much code to skip, right?)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.
Option 2 looks like a way to go. Updated