Skip to content
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
41 changes: 8 additions & 33 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Code lint checker
run: pnpm checker

test-ee:
test:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.title, '[skip checker]') }}
strategy:
Expand All @@ -34,65 +34,41 @@ jobs:
- name: Install dependencies
uses: ./.github/actions/catch-install-pnpm

- name: Coverage test report ee
run: sh ./scripts/jest/run-ci-ee.sh ${{ matrix.shard }} ${{ strategy.job-total }}
- name: Coverage test report
run: sh ./scripts/jest/run-ci.sh ${{ matrix.shard }} ${{ strategy.job-total }}

- uses: actions/upload-artifact@v4
with:
name: coverage-artifacts-${{ matrix.shard }}
path: coverage/

test-ce:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.title, '[skip checker]') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/catch-install-pnpm

- name: Coverage test report ce
run: sh ./scripts/jest/run-ci-ce.sh

- uses: actions/upload-artifact@v4
with:
name: ce-coverage-artifacts
path: ce_coverage/

report:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.title, '[skip checker]') }}
needs: [test-ee, test-ce]
needs: [test]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get CE Coverage
uses: actions/download-artifact@v4
with:
name: ce-coverage-artifacts
path: ce_coverage

- name: Get EE Coverage 1
- name: Get Coverage 1
uses: actions/download-artifact@v4
with:
name: coverage-artifacts-1
path: coverage

- name: Get EE Coverage 2
- name: Get Coverage 2
uses: actions/download-artifact@v4
with:
name: coverage-artifacts-2
path: coverage

- name: Get EE Coverage 3
- name: Get Coverage 3
uses: actions/download-artifact@v4
with:
name: coverage-artifacts-3
path: coverage

- name: Get EE Coverage 4
- name: Get Coverage 4
uses: actions/download-artifact@v4
with:
name: coverage-artifacts-4
Expand All @@ -115,7 +91,6 @@ jobs:
uses: geekyeggo/delete-artifact@v5
with:
name: |
ce-coverage-artifacts
coverage-artifacts-1
coverage-artifacts-2
coverage-artifacts-3
Expand Down
125 changes: 104 additions & 21 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,37 @@ const { pathsToModuleNameMapper } = require('ts-jest');

compilerOptions.paths['~/*'][0] = path.resolve(compilerOptions.paths['~/*'][0]);

module.exports = {
const sharedModuleNameMapper = {
'.+\\.(css|style|less|sass|scss|ttf|woff|woff2)$': 'identity-obj-proxy',
'@ant-design/plots':
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockAntDesignPlots.jsx',
'monaco-editor':
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockEditor.jsx',
'@monaco-editor/react':
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockEditor.jsx',
'@uiw/react-md-editor':
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockEditor.jsx',
'@actiontech/(.*)': '<rootDir>/packages/$1',
'@react-sigma/core(.*)$':
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockSigmaCore.tsx',
'@react-sigma/graph-search$':
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockSigmaGraphSearch.tsx',
...pathsToModuleNameMapper(compilerOptions.paths)
};

const sharedIgnorePatterns = ['/node_modules/', '/demo/', '/demos/'];

// Naming conventions for condition-specific test files:
// *.ce.test.{ts,tsx} → CE project (ee=false, ce=true, sqle=true, dms=false) 不要强制匹配 ce.test, ce.[可选项].test.{ts,tsx}
// *.sqle.test.{ts,tsx} → EE project (ee=true, ce=false, sqle=true, dms=false) 同上
// *.provision.test.{ts,tsx} → PROVISION project (ee=true, ce=false, sqle=false, provision=true, dms=false) 同上
// *.test.{ts,tsx} → DMS project (ee=true, ce=false, sqle=true, provision=true, dms=true) [default] 同上
// 实现:`.ce.` / `.sqle.` / `.provision.` 与 `.test.` 之间可有零段或多段 `.xxx.`(正则见下方 *_TEST_FILE_RE)。
const CE_TEST_FILE_RE = '\\.ce(\\.[^./]+)*\\.test\\.[jt]sx?$';
const SQLE_TEST_FILE_RE = '\\.sqle(\\.[^./]+)*\\.test\\.[jt]sx?$';
const PROVISION_TEST_FILE_RE = '\\.provision(\\.[^./]+)*\\.test\\.[jt]sx?$';

const sharedProjectConfig = {
transform: {
'^.+\\.(ts|tsx|js|jsx)$': '<rootDir>/scripts/jest/custom-transform.js',
'^.+\\.(png|jpg|jpeg|css|json)$': '<rootDir>/scripts/jest/file-transform.js'
Expand All @@ -19,24 +49,7 @@ module.exports = {
moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'jsx', 'node'],
testEnvironment: 'jest-environment-jsdom',
resetMocks: true,
moduleNameMapper: {
'.+\\.(css|style|less|sass|scss|ttf|woff|woff2)$': 'identity-obj-proxy',
'@ant-design/plots':
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockAntDesignPlots.jsx',
'monaco-editor':
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockEditor.jsx',
'@monaco-editor/react':
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockEditor.jsx',
'@uiw/react-md-editor':
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockEditor.jsx',
'@actiontech/(.*)': '<rootDir>/packages/$1',
'@react-sigma/core(.*)$':
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockSigmaCore.tsx',
'@react-sigma/graph-search$':
'<rootDir>/packages/shared/lib/testUtil/mockModule/mockSigmaGraphSearch.tsx',
...pathsToModuleNameMapper(compilerOptions.paths)
},

moduleNameMapper: sharedModuleNameMapper,
collectCoverageFrom: [
'packages/**/{src,lib}/{page,components,hooks,global,store,utils}/**/*.{ts,tsx}',
'packages/**/src/App.tsx',
Expand All @@ -49,8 +62,78 @@ module.exports = {
'!packages/**/demo/**',
'!packages/**/demos/**'
],
setupFilesAfterEnv: ['<rootDir>/jest-setup.ts'],
testPathIgnorePatterns: ['/node_modules/', '/demo/', '/demos/'],
setupFilesAfterEnv: ['<rootDir>/jest-setup.ts']
};

module.exports = {
projects: [
{
...sharedProjectConfig,
displayName: 'dms',
globals: {
TEST_CONDITIONS: {
ee: true,
ce: false,
sqle: true,
provision: true,
dms: true
}
},
// Default tests only: exclude CE / sqle / provision condition tests (dedicated projects)
testPathIgnorePatterns: [
...sharedIgnorePatterns,
CE_TEST_FILE_RE,
SQLE_TEST_FILE_RE,
PROVISION_TEST_FILE_RE
]
},
{
...sharedProjectConfig,
displayName: 'sqle-ce',
globals: {
TEST_CONDITIONS: {
ee: false,
ce: true,
sqle: true,
provision: false,
dms: false
}
},
testRegex: CE_TEST_FILE_RE,
testPathIgnorePatterns: sharedIgnorePatterns
},
{
...sharedProjectConfig,
displayName: 'sqle-ee',
globals: {
TEST_CONDITIONS: {
ee: true,
ce: false,
sqle: true,
provision: false,
dms: false
}
},
testRegex: SQLE_TEST_FILE_RE,
// e.g. *.ce.sqle.test.* belongs to CE, not EE
testPathIgnorePatterns: [...sharedIgnorePatterns, CE_TEST_FILE_RE]
},
{
...sharedProjectConfig,
displayName: 'provision',
globals: {
TEST_CONDITIONS: {
ee: true,
ce: false,
sqle: false,
provision: true,
dms: false
}
},
testRegex: PROVISION_TEST_FILE_RE,
testPathIgnorePatterns: [...sharedIgnorePatterns, CE_TEST_FILE_RE]
}
],
reporters: [
'default',
[
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"checker": "concurrently \"pnpm ts-check\" \"pnpm eslint\" \"pnpm stylelint\" \"pnpm prettier:c\"",
"test": "sh ./scripts/jest/run.sh",
"test:c": "sh ./scripts/jest/run-coverage.sh",
"test:ci": "sh ./scripts/jest/run-ci-ee.sh && sh ./scripts/jest/run-ci-ce.sh && node ./scripts/jest/merge-report-json.js",
"test:ci": "sh ./scripts/jest/run-ci.sh 1 1 && node ./scripts/jest/merge-report-json.js",
"test:clean": "jest --clearCache",
"icon:g": "pnpm --filter @actiontech/icons icon:g",
"icon:docs:g": "pnpm --filter @actiontech/icons docs:g",
Expand Down Expand Up @@ -149,4 +149,4 @@
"@babel/core": "^7.22.0",
"@ant-design/cssinjs": "1.17.0"
}
}
}
55 changes: 55 additions & 0 deletions packages/base/src/hooks/useOpPermission/index.sqle.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { cleanup, act, renderHook } from '@testing-library/react';
import useOpPermission from '.';
import userCenter from '@actiontech/shared/lib/testUtil/mockApi/base/userCenter';
import { ListOpPermissionsServiceEnum } from '@actiontech/shared/lib/api/base/service/OpPermission/index.enum';

// Verifies the [sqle && !dms] branch: service is set to sqle when calling ListOpPermissions

describe('test useOpPermission - sqle mode', () => {
let listOpPermissionSpy: jest.SpyInstance;

beforeEach(() => {
listOpPermissionSpy = userCenter.getOpPermissionsList();
jest.useFakeTimers();
});

afterEach(() => {
jest.useRealTimers();
cleanup();
});

it('should call ListOpPermissions with service=sqle', async () => {
const { result } = renderHook(() => useOpPermission());

act(() => {
result.current.updateOpPermissionList();
});

await act(async () => jest.advanceTimersByTime(3000));

expect(listOpPermissionSpy).toHaveBeenCalledTimes(1);
expect(listOpPermissionSpy).toHaveBeenCalledWith(
expect.objectContaining({
service: ListOpPermissionsServiceEnum.sqle
})
);
});

it('should call ListOpPermissions with service=sqle when filterBy is provided', async () => {
const { result } = renderHook(() => useOpPermission());

act(() => {
result.current.updateOpPermissionList();
});

await act(async () => jest.advanceTimersByTime(3000));

expect(listOpPermissionSpy).toHaveBeenCalledWith(
expect.objectContaining({
service: ListOpPermissionsServiceEnum.sqle
})
);
expect(result.current.loading).toBeFalsy();
expect(result.current.opPermissionList.length).toBeGreaterThan(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ exports[`page/DataSource/DataSourceForm CE render business field when getProject
</section>
</section>
<section
class="has-border css-1114g56"
class="css-1114g56"
>
<section
class="css-bspaai"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ exports[`page/DataSource/DataSourceList render list snap 1`] = `
<col />
<col />
<col />
<col />
<col
style="width: 286px;"
/>
Expand Down Expand Up @@ -315,12 +314,6 @@ exports[`page/DataSource/DataSourceList render list snap 1`] = `
>
环境属性
</th>
<th
class="ant-table-cell"
scope="col"
>
数据查询脱敏
</th>
<th
class="ant-table-cell"
scope="col"
Expand Down Expand Up @@ -434,22 +427,13 @@ exports[`page/DataSource/DataSourceList render list snap 1`] = `

</div>
</td>
<td
style="padding: 0px; border: 0px; height: 0px;"
>
<div
style="height: 0px; overflow: hidden;"
>

</div>
</td>
</tr>
<tr
class="ant-table-placeholder"
>
<td
class="ant-table-cell"
colspan="11"
colspan="10"
>
<div
class="ant-table-expanded-row-fixed"
Expand Down
Loading
Loading