mirror of https://github.com/rancher/dashboard.git
Correct issue with TS after tsconfig split with unit tests (#9686)
* Correct file test naming * Correct test files import and names * Restructure TS configuration with shared path * Copied TS configuration for shell due current architecture state
This commit is contained in:
parent
8eb172cdbe
commit
cb6f806274
|
|
@ -1 +1,2 @@
|
|||
// NOTE: We import the babel config from the shell folder due to "Validate Plugin build system" setup set in this way
|
||||
module.exports = require('./shell/babel.config.js');
|
||||
|
|
|
|||
|
|
@ -19,63 +19,65 @@ export type CreateUserParams = {
|
|||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
declare namespace Cypress {
|
||||
interface Chainable {
|
||||
declare global {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
namespace Cypress {
|
||||
interface Chainable {
|
||||
|
||||
state(state: any): any;
|
||||
state(state: any): any;
|
||||
|
||||
login(username?: string, password?: string, cacheSession?: boolean): Chainable<Element>;
|
||||
logout(): Chainable;
|
||||
byLabel(label: string): Chainable<Element>;
|
||||
login(username?: string, password?: string, cacheSession?: boolean): Chainable<Element>;
|
||||
logout(): Chainable;
|
||||
byLabel(label: string): Chainable<Element>;
|
||||
|
||||
createUser(params: CreateUserParams): Chainable;
|
||||
setGlobalRoleBinding(userId: string, role: string): Chainable;
|
||||
setClusterRoleBinding(clusterId: string, userPrincipalId: string, role: string): Chainable;
|
||||
setProjectRoleBinding(clusterId: string, userPrincipalId: string, projectName: string, role: string): Chainable;
|
||||
getProjectByName(clusterId: string, projectName: string): Chainable;
|
||||
createProject(projName: string, clusterId: string, userId: string): Chainable;
|
||||
createNamespace(nsName: string, projId: string): Chainable;
|
||||
createUser(params: CreateUserParams): Chainable;
|
||||
setGlobalRoleBinding(userId: string, role: string): Chainable;
|
||||
setClusterRoleBinding(clusterId: string, userPrincipalId: string, role: string): Chainable;
|
||||
setProjectRoleBinding(clusterId: string, userPrincipalId: string, projectName: string, role: string): Chainable;
|
||||
getProjectByName(clusterId: string, projectName: string): Chainable;
|
||||
createProject(projName: string, clusterId: string, userId: string): Chainable;
|
||||
createNamespace(nsName: string, projId: string): Chainable;
|
||||
|
||||
getRancherResource(prefix: 'v3' | 'v1', resourceType: string, resourceId?: string, expectedStatusCode: string): Chainable;
|
||||
setRancherResource(prefix: 'v3' | 'v1', resourceType: string, resourceId: string, body: string): Chainable;
|
||||
deleteRancherResource(prefix: 'v3' | 'v1', resourceType: string, resourceId: string): Chainable;
|
||||
getRancherResource(prefix: 'v3' | 'v1', resourceType: string, resourceId?: string, expectedStatusCode: string): Chainable;
|
||||
setRancherResource(prefix: 'v3' | 'v1', resourceType: string, resourceId: string, body: string): Chainable;
|
||||
deleteRancherResource(prefix: 'v3' | 'v1', resourceType: string, resourceId: string): Chainable;
|
||||
|
||||
/**
|
||||
* Wrapper for cy.get() to simply define the data-testid value that allows you to pass a matcher to find the element.
|
||||
* @param id Value used for the data-testid attribute of the element.
|
||||
* @param matcher Matching character used for attribute value:
|
||||
* - `$`: Suffixed with this value
|
||||
* - `^`: Prefixed with this value
|
||||
* - `~`: Contains this value as whitespace separated words
|
||||
* - `*`: Contains this value
|
||||
*/
|
||||
getId(id: string, matcher?: Matcher): Chainable<Element>;
|
||||
/**
|
||||
* Wrapper for cy.get() to simply define the data-testid value that allows you to pass a matcher to find the element.
|
||||
* @param id Value used for the data-testid attribute of the element.
|
||||
* @param matcher Matching character used for attribute value:
|
||||
* - `$`: Suffixed with this value
|
||||
* - `^`: Prefixed with this value
|
||||
* - `~`: Contains this value as whitespace separated words
|
||||
* - `*`: Contains this value
|
||||
*/
|
||||
getId(id: string, matcher?: Matcher): Chainable<Element>;
|
||||
|
||||
/**
|
||||
* Wrapper for cy.find() to simply define the data-testid value that allows you to pass a matcher to find the element.
|
||||
* @param id Value used for the data-testid attribute of the element.
|
||||
* @param matcher Matching character used for attribute value:
|
||||
* - `$`: Suffixed with this value
|
||||
* - `^`: Prefixed with this value
|
||||
* - `~`: Contains this value as whitespace separated words
|
||||
* - `*`: Contains this value
|
||||
*/
|
||||
findId(id: string, matcher?: Matcher): Chainable<Element>;
|
||||
/**
|
||||
* Wrapper for cy.find() to simply define the data-testid value that allows you to pass a matcher to find the element.
|
||||
* @param id Value used for the data-testid attribute of the element.
|
||||
* @param matcher Matching character used for attribute value:
|
||||
* - `$`: Suffixed with this value
|
||||
* - `^`: Prefixed with this value
|
||||
* - `~`: Contains this value as whitespace separated words
|
||||
* - `*`: Contains this value
|
||||
*/
|
||||
findId(id: string, matcher?: Matcher): Chainable<Element>;
|
||||
|
||||
/**
|
||||
* Override user preferences to default values, allowing to pass custom preferences for a deterministic scenario
|
||||
* Leave empty for reset to default values
|
||||
*/
|
||||
// eslint-disable-next-line no-undef
|
||||
userPreferences(preferences?: Partial<UserPreferences>): Chainable<null>;
|
||||
/**
|
||||
* Override user preferences to default values, allowing to pass custom preferences for a deterministic scenario
|
||||
* Leave empty for reset to default values
|
||||
*/
|
||||
// eslint-disable-next-line no-undef
|
||||
userPreferences(preferences?: Partial<UserPreferences>): Chainable<null>;
|
||||
|
||||
requestBase64Image(url: string): Chainable;
|
||||
requestBase64Image(url: string): Chainable;
|
||||
|
||||
keyboardControls(triggerKeys: Partial<any>, count: number): Chainable<Element>;
|
||||
keyboardControls(triggerKeys: Partial<any>, count: number): Chainable<Element>;
|
||||
|
||||
interceptAllRequests(verbs: Verbs, urls: string[], timeout: number): Chainable<string>;
|
||||
interceptAllRequests(verbs: Verbs, urls: string[], timeout: number): Chainable<string>;
|
||||
|
||||
iFrame(): Chainable<Element>;
|
||||
iFrame(): Chainable<Element>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,20 @@
|
|||
{
|
||||
"extends": "../shell/tsconfig.default.json",
|
||||
"extends": "../tsconfig.paths.json",
|
||||
"target": "ES2018",
|
||||
"module": "ES2020",
|
||||
"moduleResolution": "Node",
|
||||
"lib": [
|
||||
"ES2020",
|
||||
"ES2020.AsyncIterable",
|
||||
"DOM"
|
||||
],
|
||||
"allowJs": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"noEmit": false,
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"baseUrl": "..",
|
||||
"noEmit": true,
|
||||
"types": [
|
||||
"cypress",
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'jsdom',
|
||||
setupFilesAfterEnv: ['./jest.setup.js'],
|
||||
modulePaths: [
|
||||
'<rootDir>'
|
||||
],
|
||||
watchman: false,
|
||||
|
||||
// tell Jest to handle `*.vue` files
|
||||
moduleFileExtensions: ['js', 'json', 'vue', 'ts'],
|
||||
watchman: false,
|
||||
moduleNameMapper: {
|
||||
|
||||
// Paths
|
||||
// NOTE: Docs configuration does not work for our environment
|
||||
// https://kulshekhar.github.io/ts-jest/docs/27.1/getting-started/paths-mapping#jest-config-with-helper
|
||||
modulePaths: ['<rootDir>'],
|
||||
moduleNameMapper: {
|
||||
'^~/(.*)$': '<rootDir>/$1',
|
||||
'^~~/(.*)$': '<rootDir>/$1',
|
||||
'^@/(.*)$': '<rootDir>/$1',
|
||||
|
|
@ -15,21 +19,6 @@ module.exports = {
|
|||
'@pkg/(.*)': '<rootDir>/pkg/$1',
|
||||
'@components/(.*)': '<rootDir>/pkg/rancher-components/src/components/$1',
|
||||
},
|
||||
transform: {
|
||||
'^.+\\.js$': '<rootDir>/node_modules/babel-jest', // process js with `babel-jest`
|
||||
'.*\\.(vue)$': '<rootDir>/node_modules/@vue/vue2-jest', // process `*.vue` files with `vue-jest`
|
||||
'^.+\\.tsx?$': 'ts-jest', // process `*.ts` files with `ts-jest`
|
||||
'^.+\\.svg$': '<rootDir>/svgTransform.js' // to mock `*.svg` files
|
||||
},
|
||||
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
|
||||
collectCoverage: false,
|
||||
collectCoverageFrom: [
|
||||
'<rootDir>/shell/**/*.{vue,ts,js}',
|
||||
'<rootDir>/pkg/rancher-components/src/components/**/*.{vue,ts,js}',
|
||||
'!<rootDir>/shell/scripts/',
|
||||
'!<rootDir>/.nuxt',
|
||||
'!<rootDir>/.nuxt-prod',
|
||||
],
|
||||
modulePathIgnorePatterns: [
|
||||
'<rootDir>/cypress/',
|
||||
'<rootDir>/scripts/',
|
||||
|
|
@ -44,13 +33,26 @@ module.exports = {
|
|||
'<rootDir>/node_modules/',
|
||||
'<rootDir>(/.*)*/__tests__/utils/',
|
||||
],
|
||||
coverageDirectory: '<rootDir>/coverage/unit',
|
||||
coverageReporters: ['json', 'text-summary'],
|
||||
globals: {
|
||||
'ts-jest': {
|
||||
isolatedModules: true,
|
||||
tsconfig: 'tsconfig.test.json'
|
||||
}
|
||||
|
||||
// Babel
|
||||
transform: {
|
||||
'^.+\\.js$': '<rootDir>/node_modules/babel-jest', // process js with `babel-jest`
|
||||
'.*\\.(vue)$': '<rootDir>/node_modules/@vue/vue2-jest', // process `*.vue` files with `vue-jest`
|
||||
'^.+\\.tsx?$': 'ts-jest', // process `*.ts` files with `ts-jest`
|
||||
'^.+\\.svg$': '<rootDir>/svgTransform.js' // to mock `*.svg` files
|
||||
},
|
||||
preset: 'ts-jest'
|
||||
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
|
||||
|
||||
// Coverage
|
||||
coverageDirectory: '<rootDir>/coverage/unit',
|
||||
coverageReporters: ['json', 'text-summary'],
|
||||
collectCoverage: false,
|
||||
collectCoverageFrom: [
|
||||
'<rootDir>/shell/**/*.{vue,ts,js}',
|
||||
'<rootDir>/pkg/rancher-components/src/components/**/*.{vue,ts,js}',
|
||||
'!<rootDir>/shell/scripts/',
|
||||
],
|
||||
|
||||
// Globals
|
||||
globals: { 'ts-jest': { isolatedModules: true } },
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,13 @@ module.exports = function(api) {
|
|||
{ targets: { node: 'current' } }
|
||||
]
|
||||
];
|
||||
const env = { test: { presets: [['@babel/env', { targets: { node: 'current' } }]] } };
|
||||
const env = {
|
||||
test: {
|
||||
presets: [[
|
||||
'@babel/env', { targets: { node: 'current' } }
|
||||
]]
|
||||
}
|
||||
};
|
||||
|
||||
const plugins = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils';
|
|||
import PolicyRuleTarget from '@shell/edit/networking.k8s.io.networkpolicy/PolicyRuleTarget';
|
||||
import { cleanHtmlDirective } from '@shell/plugins/clean-html-directive';
|
||||
import mock from '@shell/edit/networking.k8s.io.networkpolicy/__tests__/utils/mock.json';
|
||||
import { PolicyRuleTargetSelectors } from '@shell/edit/networking.k8s.io.networkpolicy/__tests__/utils/selectors';
|
||||
import { PolicyRuleTargetSelectors } from '@shell/edit/networking.k8s.io.networkpolicy/__tests__/utils/selectors.test.ts';
|
||||
|
||||
describe.each([
|
||||
'view',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { batchChanges } from '@shell/plugins/dashboard-store/mutations';
|
||||
import { batchChanges } from '@shell/plugins/dashboard-store/mutations.js';
|
||||
import { POD, WORKLOAD_TYPES } from '@shell/config/types';
|
||||
import Resource from '@shell/plugins/dashboard-store/resource-class';
|
||||
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2018",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"ESNext.AsyncIterable",
|
||||
"DOM"
|
||||
],
|
||||
"esModuleInterop": true,
|
||||
"allowJs": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"noEmit": false,
|
||||
"baseUrl": ".",
|
||||
"rootDir": ".",
|
||||
"paths": {
|
||||
"~/*": [
|
||||
"../*"
|
||||
],
|
||||
"@/*": [
|
||||
"../*"
|
||||
],
|
||||
"@shell/*": [
|
||||
"../shell/*"
|
||||
],
|
||||
"@pkg/*": [
|
||||
"../shell/pkg/*"
|
||||
]
|
||||
},
|
||||
"typeRoots": [
|
||||
"./node_modules/@types"
|
||||
],
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".nuxt",
|
||||
"dist",
|
||||
"dist-pkg",
|
||||
"shell/creators",
|
||||
"shell/scripts",
|
||||
"script/standalone",
|
||||
"docusaurus"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,16 +1,42 @@
|
|||
{
|
||||
"extends": "./tsconfig.default.json",
|
||||
"extends": "./tsconfig.paths.json",
|
||||
"compilerOptions": {
|
||||
"target": "ES2018",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"ESNext.AsyncIterable",
|
||||
"DOM"
|
||||
],
|
||||
"allowJs": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"noEmit": false,
|
||||
"esModuleInterop": true,
|
||||
"baseUrl": ".",
|
||||
"rootDir": ".",
|
||||
"types": [
|
||||
"@types/node",
|
||||
"@types/jest",
|
||||
"@nuxt/types",
|
||||
]
|
||||
"node",
|
||||
"jest",
|
||||
],
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"../node_modules/@types"
|
||||
],
|
||||
},
|
||||
"exclude": [
|
||||
"cypress",
|
||||
"./cypress.config.ts",
|
||||
"**/*.test.ts",
|
||||
"**/*.spec.ts"
|
||||
"node_modules",
|
||||
".nuxt",
|
||||
"dist",
|
||||
"dist-pkg",
|
||||
"../dist",
|
||||
"../dist-pkg",
|
||||
"../creators",
|
||||
"../scripts",
|
||||
"../cypress",
|
||||
"../cypress.config.ts",
|
||||
"../docusaurus",
|
||||
"../**/*.spec.ts"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"~/*": [
|
||||
"../*"
|
||||
],
|
||||
"@/*": [
|
||||
"../*"
|
||||
],
|
||||
"@shell/*": [
|
||||
"../shell/*"
|
||||
],
|
||||
"@pkg/*": [
|
||||
"../shell/pkg/*"
|
||||
]
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,19 +1,3 @@
|
|||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"types": ["@types/node", "@types/jest"]
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".nuxt",
|
||||
"dist",
|
||||
"dist-pkg",
|
||||
"cypress",
|
||||
"shell/creators",
|
||||
"shell/scripts",
|
||||
"cypress",
|
||||
"./cypress.config.ts",
|
||||
"docusaurus",
|
||||
"script/standalone"
|
||||
]
|
||||
"extends": "../tsconfig.json"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,41 @@
|
|||
{
|
||||
"extends": "./shell/tsconfig.default.json",
|
||||
"extends": "./tsconfig.paths.json",
|
||||
"compilerOptions": {
|
||||
"target": "ES2018",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"ESNext.AsyncIterable",
|
||||
"DOM"
|
||||
],
|
||||
"allowJs": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"noEmit": false,
|
||||
"esModuleInterop": true,
|
||||
"baseUrl": ".",
|
||||
"rootDir": ".",
|
||||
"types": [
|
||||
"node",
|
||||
"jest",
|
||||
],
|
||||
"typeRoots": [
|
||||
"./node_modules/@types"
|
||||
],
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".nuxt",
|
||||
"dist",
|
||||
"dist-pkg",
|
||||
"cypress",
|
||||
"shell/creators",
|
||||
"shell/scripts",
|
||||
"cypress",
|
||||
"./cypress.config.ts",
|
||||
"docusaurus",
|
||||
"scripts/standalone",
|
||||
"**/*.spec.ts"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"~/*": [
|
||||
"*"
|
||||
],
|
||||
"@/*": [
|
||||
"*"
|
||||
],
|
||||
"@shell/*": [
|
||||
"shell/*"
|
||||
],
|
||||
"@pkg/*": [
|
||||
"shell/pkg/*"
|
||||
],
|
||||
"@components/*": [
|
||||
"pkg/rancher-components/src/components/*"
|
||||
]
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"extends": "./shell/tsconfig.default.json",
|
||||
"compilerOptions": {
|
||||
"types": [
|
||||
"jest"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"./**/*.test.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"cypress",
|
||||
"./cypress.config.ts",
|
||||
"**/*.spec.ts"
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue