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

1500 move datafetcher to lib react4xp #1535

Merged
merged 24 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7a98fea
wip #1500 DataFetcher test
ComLock Nov 12, 2024
e69d7f9
wip #1500 RenderableComponent should not have config
ComLock Nov 12, 2024
5c7db64
Handle page templates
ComLock Nov 21, 2024
d349757
Pass along
ComLock Nov 22, 2024
33ac3b1
wip #1500 Handle page templates with caching
ComLock Nov 25, 2024
ffbc5c8
wip #1500 Get image content for Richtext processing
ComLock Nov 25, 2024
de556b7
wip #1500 Build nashorn files using tsup
ComLock Dec 3, 2024
0cc06cf
wip #1500 Forgot to pass content to all toProps
ComLock Dec 3, 2024
0e8d916
Fix #1500 Move DataFetcher to lib-react4xp
ComLock Dec 4, 2024
8f470c1
Fix #1500 mode is an extra property on text component, not a prop
ComLock Dec 5, 2024
b87eaec
Fix #1523 DataFetcher should be able to handle contentTypes
ComLock Dec 5, 2024
bd2e96c
Able to return response
ComLock Dec 10, 2024
cf0faf3
Update build.gradle
rymsha Dec 11, 2024
8c12aeb
Update build.gradle
rymsha Dec 11, 2024
5b038f9
@enonic/react-components 6.0.0-B1
ComLock Dec 11, 2024
4af387a
Fix deno tests
ComLock Dec 11, 2024
5284d9d
Dep update
alansemenov Dec 11, 2024
998e95e
fix windows build
rymsha Dec 11, 2024
3b7b8e5
@enonic/react-components 6.0.0-B2
ComLock Dec 12, 2024
39debbb
Some type fixes
ComLock Dec 12, 2024
85f9f39
Update deno.lock to match package.json
ComLock Dec 12, 2024
418f417
More type fixes
ComLock Dec 12, 2024
594703f
client and executor has to be in @enonic/react4xp because of app name
ComLock Dec 12, 2024
1439526
@enonic/react4xp 6.0.0-B1
ComLock Dec 12, 2024
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
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.13.1
22.11.0
32 changes: 26 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {

implementation "com.enonic.xp:lib-io:${xpVersion}"
implementation "com.enonic.xp:lib-portal:${xpVersion}"
implementation "com.enonic.xp:lib-schema:${xpVersion}"
implementation "com.enonic.xp:lib-task:${xpVersion}"

implementation 'com.enonic.lib:lib-cache:2.2.1'
Expand All @@ -33,7 +34,7 @@ dependencies {

node {
download = true
version = '20.13.1'
version = '22.11.0'
}

processResources {
Expand Down Expand Up @@ -64,11 +65,29 @@ if ( project.hasProperty( "dev" ) || project.hasProperty( "development" ) )
BUILD_ENV = "development"
}

task rollup( type: NpmTask ) {
mustRunAfter( processResources )
args = ['run', 'rollup']
tasks.register('npmBuild', NpmTask) {
args = [
'run',
'build',
]
environment = [
'FORCE_COLOR': 'true',
'LOG_LEVEL_FROM_GRADLE': gradle.startParameter.logLevel.toString(),
'NODE_ENV': project.hasProperty('dev') || project.hasProperty('development') ? 'development' : 'production'
]
inputs.dir 'src/main/resources'
outputs.dir 'build/resources/main'
outputs.upToDateWhen { false }
}
jar.dependsOn( rollup )
compileTestJava.dependsOn npmBuild
jar.dependsOn npmBuild
javadoc.dependsOn npmBuild

// task rollup( type: NpmTask ) {
// mustRunAfter( processResources )
// args = ['run', 'rollup']
// }
// jar.dependsOn( rollup )
rymsha marked this conversation as resolved.
Show resolved Hide resolved

if ( BUILD_ENV == 'development' )
{
Expand All @@ -88,7 +107,8 @@ else
npmInstall.inputs.files( "package.json", "package-lock.json" )
// npmInstall.outputs.dir("node_modules")
npmInstall.outputs.file file( "package-lock.json" )
rollup.dependsOn( npmInstall )
// rollup.dependsOn( npmInstall )
rymsha marked this conversation as resolved.
Show resolved Hide resolved
npmBuild.dependsOn( npmInstall )
}

test {
Expand Down
141 changes: 141 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import type { Config } from '@jest/types';


const DIR_SRC = 'src/main/resources';
const DIR_SRC_JEST = 'src/jest';
const DIR_SRC_JEST_CLIENT = `${DIR_SRC_JEST}/client`;
const DIR_SRC_JEST_SERVER = `${DIR_SRC_JEST}/server`;
const AND_BELOW = '**';
const SOURCE_FILES = `*.{ts,tsx}`;
const TEST_EXT = `{spec,test}.{ts,tsx}`;
const TEST_FILES = `*.${TEST_EXT}`;


const commonConfig: Config.InitialProjectOptions = {
collectCoverageFrom: [
`${DIR_SRC}/${AND_BELOW}/${SOURCE_FILES}`,
],

// Insert Jest's globals (expect, test, describe, beforeEach etc.) into the
// global environment. If you set this to false, you should import from @jest/globals, e.g.
// injectGlobals: true, // Doesn't seem to work?
};

const clientSideConfig: Config.InitialProjectOptions = {
...commonConfig,
displayName: {
color: 'white',
name: 'CLIENT',
},

// A map from regular expressions to module names or to arrays of module
// names that allow to stub out resources, like images or styles with a
// single module.
// Use <rootDir> string token to refer to rootDir value if you want to use
// file paths.
// Additionally, you can substitute captured regex groups using numbered
// backreferences.
moduleNameMapper: {
'/assets/(.*)': `<rootDir>/${DIR_SRC}/assets/$1`,
},

// Run clientside tests with DOM globals such as document and window
testEnvironment: 'jsdom',

// The glob patterns Jest uses to detect test files. By default it looks for
// .js, .jsx, .ts and .tsx files inside of __tests__ folders, as well as any
// files with a suffix of .test or .spec (e.g. Component.test.js or
// Component.spec.js). It will also find files called test.js or spec.js.
// (default: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[jt]s?(x)"
// ])
testMatch: [
`<rootDir>/${DIR_SRC_JEST_CLIENT}/${AND_BELOW}/${TEST_FILES}`,
],
transform: {
"^.+\\.(ts|js)x?$": [
'ts-jest',
{
tsconfig: `${DIR_SRC_JEST_CLIENT}/tsconfig.json`
}
]
}
};

const serverSideConfig: Config.InitialProjectOptions = {
...commonConfig,
displayName: {
color: 'blue',
name: 'SERVER',
},

// A set of global variables that need to be available in all test
// environments.
// If you specify a global reference value (like an object or array) here,
// and some code mutates that value in the midst of running a test, that
// mutation will not be persisted across test runs for other test files.
// In addition, the globals object must be json-serializable, so it can't be
// used to specify global functions. For that, you should use setupFiles.
globals: {
app: {
name: 'com.example.myproject',
config: {},
version: '1.0.0'
},
},

// A map from regular expressions to module names or to arrays of module
// names that allow to stub out resources, like images or styles with a
// single module.
// Use <rootDir> string token to refer to rootDir value if you want to use
// file paths.
// Additionally, you can substitute captured regex groups using numbered
// backreferences.
moduleNameMapper: {
'/lib/enonic/react4xp/(.*)': `<rootDir>/${DIR_SRC}/lib/enonic/react4xp/$1`,
},

// A list of paths to modules that run some code to configure or set up the
// testing environment. Each setupFile will be run once per test file. Since
// every test runs in its own environment, these scripts will be executed in
// the testing environment before executing setupFilesAfterEnv and before
// the test code itself.
setupFiles: [
`<rootDir>/${DIR_SRC_JEST_SERVER}/setupFile.ts`,
`<rootDir>/${DIR_SRC_JEST_SERVER}/mockXP.ts`
],

// Run serverside tests without DOM globals such as document and window
testEnvironment: 'node',
// testEnvironment: 'jsdom', // "Graal"

// The glob patterns Jest uses to detect test files. By default it looks for
// .js, .jsx, .ts and .tsx files inside of __tests__ folders, as well as any
// files with a suffix of .test or .spec (e.g. Component.test.js or
// Component.spec.js). It will also find files called test.js or spec.js.
// (default: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[jt]s?(x)"
// ])
testMatch: [
`<rootDir>/${DIR_SRC_JEST_SERVER}/${AND_BELOW}/${TEST_FILES}`,
],

transform: {
"^.+\\.(ts|js)x?$": [
'ts-jest',
{
tsconfig: `${DIR_SRC_JEST_SERVER}/tsconfig.json`
}
]
},
};

const customJestConfig: Config.InitialOptions = {
coverageProvider: 'v8', // To get correct line numbers under jsdom
passWithNoTests: true,
projects: [clientSideConfig, serverSideConfig],
};

export default customJestConfig;
Loading
Loading