Commit fee6ed03 authored by Yannis Barlas's avatar Yannis Barlas
Browse files

test(ui): fix ui tests failing

parent e442b3c2
Pipeline #17990 failed with stages
in 66 minutes and 10 seconds
import Enzyme from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import Adapter from '@wojtekmaj/enzyme-adapter-react-17'
import path from 'path'
Enzyme.configure({ adapter: new Adapter() })
......
module.exports = {
collectCoverageFrom: [
'**/*.{js,jsx}',
'!**/*test.{js,jsx}',
'!**/test/**',
'!**/node_modules/**',
'!**/config/**',
'!**/coverage/**',
'!**/dist/**',
],
coverageDirectory: '<rootDir>/coverage',
projects: [
{
rootDir: '<rootDir>/packages/server',
displayName: 'server',
testEnvironment: 'jest-environment-db',
testRegex: '/test/.*_test.js$',
setupFilesAfterEnv: ['<rootDir>/test/helpers/jest-setup.js'],
},
{
rootDir: '<rootDir>/packages/client',
displayName: 'client',
testRegex: '/test/.+test.jsx?$',
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.js'],
globals: {
window: {},
},
},
{
rootDir: '<rootDir>/packages/db-manager',
displayName: 'db-manager',
testMatch: ['**/test/**/*.test.js'],
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.js'],
testEnvironment: 'jest-environment-db',
},
{
rootDir: '<rootDir>/components/client',
displayName: 'components',
moduleNameMapper: {
'\\.s?css$': 'identity-obj-proxy',
},
transformIgnorePatterns: ['/node_modules/(?!@?pubsweet)'],
testPathIgnorePatterns: [
'/node_modules',
'config/test',
'model-*',
'-server',
],
globals: {
fetch: true,
},
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.js'],
},
{
rootDir: '<rootDir>/packages/cli',
displayName: 'cli',
testMatch: ['<rootDir>/test/*.test.js', '<rootDir>/test/cli/*.test.js'],
testPathIgnorePatterns: ['<rootDir>/build/'],
modulePaths: ['<rootDir>/node_modules'],
testEnvironment: 'jest-environment-db',
unmockedModulePathPatterns: ['/src/models'],
setupFilesAfterEnv: ['<rootDir>/test/helpers/jest-setup.js'],
verbose: true,
},
{
rootDir: '<rootDir>/packages/logger',
displayName: 'logger',
testMatch: ['**/test/**/*test.js'],
modulePaths: ['<rootDir>/node_modules'],
testEnvironment: 'node',
verbose: true,
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.js'],
},
{
rootDir: '<rootDir>/packages/ui',
testPathIgnorePatterns: ['/dist'],
displayName: 'ui',
moduleNameMapper: {
'\\.s?css$': 'identity-obj-proxy',
},
setupFilesAfterEnv: ['<rootDir>/test/setup/enzyme.js'],
snapshotSerializers: ['enzyme-to-json/serializer'],
},
{
rootDir: '<rootDir>/packages/base-model',
displayName: 'base-model',
testRegex: '/test/.*_test.js$',
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.js'],
testEnvironment: 'jest-environment-db',
},
{
rootDir: '<rootDir>/packages/sse',
displayName: 'sse',
testRegex: '/test/.*_test.js$',
testEnvironment: 'node',
},
{
rootDir: '<rootDir>/components/server/model-team',
displayName: 'model-team',
testRegex: '/test/.*_test.js$',
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.js'],
testEnvironment: 'jest-environment-db',
},
{
rootDir: '<rootDir>/components/server/model-user',
displayName: 'model-user',
testRegex: '/test/.*_test.js$',
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.js'],
testEnvironment: 'jest-environment-db',
},
{
rootDir: '<rootDir>/components/server/model-fragment',
displayName: 'model-fragment',
testRegex: '/test/.*_test.js$',
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.js'],
testEnvironment: 'jest-environment-db',
},
{
rootDir: '<rootDir>/components/server/component-password-reset-server',
displayName: 'component-password-reset-server',
testRegex: '/test/.*_test.js$',
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.js'],
testEnvironment: 'jest-environment-db',
},
{
rootDir: '<rootDir>/components/server/job-xsweet',
displayName: 'job-xsweet',
testRegex: '/test/.*_test.js$',
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.js'],
testEnvironment: 'node',
},
{
rootDir: '<rootDir>/components/server/component-email-templating',
displayName: 'component-email-templating',
testRegex: '/test/.*.test.js$',
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.js'],
testEnvironment: 'node',
},
{
rootDir: '<rootDir>/components/server/component-aws-s3',
displayName: 'component-aws-s3',
testRegex: '/test/.*.test.js$',
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.js'],
testEnvironment: 'node',
},
],
}
......@@ -2,7 +2,36 @@
"name": "pubsweet-monorepo",
"version": "0.0.0",
"private": true,
"repository": {
"type": "git",
"url": "https://gitlab.coko.foundation/pubsweet/pubsweet"
},
"license": "MIT",
"workspaces": [
"packages/*",
"components/server/*",
"components/client/*",
"docs"
],
"scripts": {
"clean": "lerna clean",
"styleguide": "yarn --cwd docs styleguide",
"styleguide:build": "yarn --cwd docs styleguide:build",
"test": "jest --no-cache --coverage --detectOpenHandles",
"lint": "yarn lint:js && yarn lint:style && yarn lint:json",
"lint:js": "eslint '**/*.{js,jsx}'",
"lint:style": "stylelint '**/*.{js,jsx}'",
"lint:json": "prettier --list-different '**/*.json'",
"precommit": "lint-staged",
"cz": "git-cz",
"commitmsg": "commitlint -e $GIT_PARAMS",
"build": "lerna run build"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
......@@ -12,15 +41,15 @@
"@babel/preset-react": "^7.0.0",
"@commitlint/cli": "^6.0.5",
"@commitlint/config-conventional": "^6.0.4",
"@testing-library/jest-dom": "^4.0.0",
"@testing-library/react": "^9.0.0",
"@testing-library/jest-dom": "^5.11.10",
"@testing-library/react": "^11.2.6",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.0",
"apollo-link-http": "^1.5.16",
"babel-eslint": "^10.0.1",
"commitizen": "^2.9.6",
"cz-conventional-changelog": "^2.1.0",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.12.1",
"enzyme-to-json": "^3.4.3",
"enzyme": "^3.11.0",
"enzyme-to-json": "^3.6.1",
"eslint": "^4.13.1",
"eslint-config-pubsweet": "^0.0.6",
"eslint-plugin-import": "^2.8.0",
......@@ -39,7 +68,7 @@
"isomorphic-form-data": "^1.0.0",
"jest": "^24.7.1",
"jest-cli": "^24.7.1",
"jest-styled-components": "^6.3.1",
"jest-styled-components": "^7.0.3",
"lerna": "^3.13.2",
"lint-staged": "^8.1.5",
"nock": "^9.0.14",
......@@ -52,232 +81,5 @@
"stylelint-processor-styled-components": "^1.8.0",
"supertest": "^3.1.0",
"waait": "^1.0.2"
},
"scripts": {
"clean": "lerna clean",
"styleguide": "yarn --cwd docs styleguide",
"styleguide:build": "yarn --cwd docs styleguide:build",
"test": "jest --no-cache --coverage --detectOpenHandles",
"lint": "yarn lint:js && yarn lint:style && yarn lint:json",
"lint:js": "eslint '**/*.{js,jsx}'",
"lint:style": "stylelint '**/*.{js,jsx}'",
"lint:json": "prettier --list-different '**/*.json'",
"precommit": "lint-staged",
"cz": "git-cz",
"commitmsg": "commitlint -e $GIT_PARAMS",
"build": "lerna run build"
},
"jest": {
"collectCoverageFrom": [
"**/*.{js,jsx}",
"!**/*test.{js,jsx}",
"!**/test/**",
"!**/node_modules/**",
"!**/config/**",
"!**/coverage/**",
"!**/dist/**"
],
"coverageDirectory": "<rootDir>/coverage",
"projects": [
{
"rootDir": "<rootDir>/packages/server",
"displayName": "server",
"testEnvironment": "jest-environment-db",
"testRegex": "/test/.*_test.js$",
"setupFilesAfterEnv": [
"<rootDir>/test/helpers/jest-setup.js"
]
},
{
"rootDir": "<rootDir>/packages/client",
"displayName": "client",
"testRegex": "/test/.+test.jsx?$",
"setupFilesAfterEnv": [
"<rootDir>/test/jest-setup.js"
],
"globals": {
"window": {}
}
},
{
"rootDir": "<rootDir>/packages/db-manager",
"displayName": "db-manager",
"testMatch": [
"**/test/**/*.test.js"
],
"setupFilesAfterEnv": [
"<rootDir>/test/jest-setup.js"
],
"testEnvironment": "jest-environment-db"
},
{
"rootDir": "<rootDir>/components/client",
"displayName": "components",
"moduleNameMapper": {
"\\.s?css$": "identity-obj-proxy"
},
"transformIgnorePatterns": [
"/node_modules/(?!@?pubsweet)"
],
"testPathIgnorePatterns": [
"/node_modules",
"config/test",
"model-*",
"-server"
],
"globals": {
"fetch": true
},
"setupFilesAfterEnv": [
"<rootDir>/test/jest-setup.js"
]
},
{
"rootDir": "<rootDir>/packages/cli",
"displayName": "cli",
"testMatch": [
"<rootDir>/test/*.test.js",
"<rootDir>/test/cli/*.test.js"
],
"testPathIgnorePatterns": [
"<rootDir>/build/"
],
"modulePaths": [
"<rootDir>/node_modules"
],
"testEnvironment": "jest-environment-db",
"unmockedModulePathPatterns": [
"/src/models"
],
"setupFilesAfterEnv": [
"<rootDir>/test/helpers/jest-setup.js"
],
"verbose": true
},
{
"rootDir": "<rootDir>/packages/logger",
"displayName": "logger",
"testMatch": [
"**/test/**/*test.js"
],
"modulePaths": [
"<rootDir>/node_modules"
],
"testEnvironment": "node",
"verbose": true,
"setupFilesAfterEnv": [
"<rootDir>/test/jest-setup.js"
]
},
{
"rootDir": "<rootDir>/packages/ui",
"testPathIgnorePatterns": [
"/dist"
],
"displayName": "ui",
"moduleNameMapper": {
"\\.s?css$": "identity-obj-proxy"
},
"setupFilesAfterEnv": [
"<rootDir>/test/setup/enzyme.js"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
},
{
"rootDir": "<rootDir>/packages/base-model",
"displayName": "base-model",
"testRegex": "/test/.*_test.js$",
"setupFilesAfterEnv": [
"<rootDir>/test/jest-setup.js"
],
"testEnvironment": "jest-environment-db"
},
{
"rootDir": "<rootDir>/packages/sse",
"displayName": "sse",
"testRegex": "/test/.*_test.js$",
"testEnvironment": "node"
},
{
"rootDir": "<rootDir>/components/server/model-team",
"displayName": "model-team",
"testRegex": "/test/.*_test.js$",
"setupFilesAfterEnv": [
"<rootDir>/test/jest-setup.js"
],
"testEnvironment": "jest-environment-db"
},
{
"rootDir": "<rootDir>/components/server/model-user",
"displayName": "model-user",
"testRegex": "/test/.*_test.js$",
"setupFilesAfterEnv": [
"<rootDir>/test/jest-setup.js"
],
"testEnvironment": "jest-environment-db"
},
{
"rootDir": "<rootDir>/components/server/model-fragment",
"displayName": "model-fragment",
"testRegex": "/test/.*_test.js$",
"setupFilesAfterEnv": [
"<rootDir>/test/jest-setup.js"
],
"testEnvironment": "jest-environment-db"
},
{
"rootDir": "<rootDir>/components/server/component-password-reset-server",
"displayName": "component-password-reset-server",
"testRegex": "/test/.*_test.js$",
"setupFilesAfterEnv": [
"<rootDir>/test/jest-setup.js"
],
"testEnvironment": "jest-environment-db"
},
{
"rootDir": "<rootDir>/components/server/job-xsweet",
"displayName": "job-xsweet",
"testRegex": "/test/.*_test.js$",
"setupFilesAfterEnv": [
"<rootDir>/test/jest-setup.js"
],
"testEnvironment": "node"
},
{
"rootDir": "<rootDir>/components/server/component-email-templating",
"displayName": "component-email-templating",
"testRegex": "/test/.*.test.js$",
"setupFilesAfterEnv": [
"<rootDir>/test/jest-setup.js"
],
"testEnvironment": "node"
},
{
"rootDir": "<rootDir>/components/server/component-aws-s3",
"displayName": "component-aws-s3",
"testRegex": "/test/.*.test.js$",
"setupFilesAfterEnv": [
"<rootDir>/test/jest-setup.js"
],
"testEnvironment": "node"
}
]
},
"workspaces": [
"packages/*",
"components/server/*",
"components/client/*",
"docs"
],
"repository": {
"type": "git",
"url": "https://gitlab.coko.foundation/pubsweet/pubsweet"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
......@@ -29,8 +29,8 @@
"styled-normalize": "^8.0.6"
},
"devDependencies": {
"@wojtekmaj/enzyme-adapter-react-17": "0.6.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"history": "^5.0.0",
"html-webpack-plugin": "^4.5.0",
"react-dom": "^17.0.2",
......
import Enzyme from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import Adapter from '@wojtekmaj/enzyme-adapter-react-17'
import path from 'path'
Enzyme.configure({ adapter: new Adapter() })
......
......@@ -8,9 +8,9 @@
"url": "https://gitlab.coko.foundation/pubsweet/pubsweet"
},
"dependencies": {
"@wojtekmaj/enzyme-adapter-react-17": "0.6.0",
"@pubsweet/ui-toolkit": "^2.3.12",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.12.1",
"formik": "^1.4.2",
"invariant": "^2.2.3",
"lodash": "^4.17.4",
......
......@@ -172,7 +172,7 @@ Dropdown.propTypes = {
itemsList: PropTypes.arrayOf(
PropTypes.shape({
/** The key for the item */
id: PropTypes.number.isRequired,
id: PropTypes.string.isRequired,
/** The click function for the item */
onClick: PropTypes.func,
......
......@@ -43,7 +43,8 @@ describe('AlignmentBoxWithLabel', () => {
})
test(`with default props the label is rendered on the left`, () => {
const label = wrapperMounted.find('span')
const newWrapper = mount(<AlignmentBoxWithLabel {...requiredProps} />)
const label = newWrapper.find('span')
expect(label.text()).toEqual(requiredProps.labelText)
expect(label).toHaveStyleRule('order', '0')
})
......
......@@ -173,5 +173,6 @@ function setup(props = {}) {
<Pagination {...props}>{childrenSpy}</Pagination>
</ThemeProvider>,
)
return { ...utils, ...renderArgs, childrenSpy }
}
......@@ -4,6 +4,9 @@ exports[`AppBar Basic display 1`] = `
.c3 {
color: black;
cursor: pointer;
}
.c4 {
color: black;
font: sans-serif;
font-size: 18px;
......@@ -15,9 +18,9 @@ exports[`AppBar Basic display 1`] = `
transition: 1s ease;
}
.c3:hover,
.c3:focus,
.c3:active {
.c4:hover,
.c4:focus,
.c4:active {
background: none;
color: black;
-webkit-text-decoration: underline;
......@@ -55,11 +58,11 @@ exports[`AppBar Basic display 1`] = `
margin: calc(8px * 2) 1rem calc(8px * 2) 1rem;
}
.c4 > * {
.c5 > * {
height: calc(8px * 6);
}
.c5 {
.c6 {
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
......@@ -81,7 +84,7 @@ exports[`AppBar Basic display 1`] = `
className="c2"
>
<a
className="c3 c4"
className="c3 c4 c5"
href="/"
onClick={[Function]}
>
......@@ -93,10 +96,10 @@ exports[`AppBar Basic display 1`] = `
className="c1"
>
<span
className="c5"
className="c6"
>
<a
className="c3"
className="c3 c4"
href="/login"
onClick={[Function]}
>
......@@ -108,7 +111,7 @@ exports[`AppBar Basic display 1`] = `
`;
exports[`AppBar With admin user 1`] = `
.c6 {
.c7 {
display: -webkit-inline-box;
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
......@@ -116,13 +119,13 @@ exports[`AppBar With admin user 1`] = `
padding: calc(8px / 2);
}
.c6 svg {
.c7 svg {
stroke: black;
width: calc(2 * 8px);
height: calc(2 * 8px);
}
.c7 {
.c8 {
background: grey;
border: 1px solid grey;
border-radius: 8px;
......@@ -132,55 +135,61 @@ exports[`AppBar With admin user 1`] = `
line-height: calc(8px * 3);
min-width: calc(8px * 12);
padding: 8px;
background: none;
border: none;
min-width: 0;
padding: 0;
color: black;
font: sans-serif;
font-size: 18px;
font-weight: normal;
-webkit-text-decoration: none;
text-decoration: none;
text-transform: none;
-webkit-transition: 1s ease;
transition: 1s ease;
}
.c7:focus,
.c7:hover {
.c8:focus,
.c8:hover {
background-color: hsl(0,0%,35.1%);