Merge pull request #22629 from mattermost/fix-boards-webapp-unit-tests

Этот коммит содержится в:
Caleb Roseland
2023-03-31 10:16:00 -05:00
коммит произвёл GitHub
родитель 99467c6b68 f35b829e47
Коммит fa7057bfbf
160 изменённых файлов: 6533 добавлений и 9753 удалений

2
.github/workflows/channels-ci.yml поставляемый
Просмотреть файл

@@ -150,7 +150,7 @@ jobs:
env:
NODE_OPTIONS: --max_old_space_size=5120
run: |
# npm run test-ci --workspace=boards
npm run test-ci --workspace=boards
npm run test-ci --workspace=channels
npm run test-ci --workspace=platform/client
npm run test-ci --workspace=playbooks

1
.gitignore поставляемый
Просмотреть файл

@@ -134,6 +134,7 @@ cprofile.out
*.test
webapp/coverage
/report.xml
junit.xml
.agignore
.ctags

Просмотреть файл

@@ -1,2 +1,3 @@
save-exact=true
legacy-peer-deps=true
global-style=true

Просмотреть файл

@@ -89,7 +89,7 @@
"unused-imports/no-unused-imports": 2,
"no-relative-import-paths/no-relative-import-paths": [
"error",
{ "allowSameFolder": true, "rootDir": "webapp/src"}
{ "allowSameFolder": true, "rootDir": "webapp/boards"}
],
/* "no-restricted-imports": ["error", {
"patterns": ["..*"]

68
webapp/boards/jest.config.js Обычный файл
Просмотреть файл

@@ -0,0 +1,68 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
/** @type {import('jest').Config} */
const config = {
transform: {
"^.+\\.(t|j)sx?$": ["@swc/jest"]
},
moduleFileExtensions: [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
extensionsToTreatAsEsm: ['.ts', '.tsx'],
transformIgnorePatterns: [
"/nanoevents/",
"node_modules/(?!react-native|react-router|react-day-picker)"
],
maxWorkers: "80%",
testEnvironment: "jsdom",
collectCoverage: true,
collectCoverageFrom: [
"src/**/*.{ts,tsx,js,jsx}",
"!src/test/**"
],
testPathIgnorePatterns: [
"/node_modules/",
],
clearMocks: true,
coverageReporters: [
"lcov",
"text-summary"
],
moduleNameMapper: {
"^.+\\.(scss|css)$": "<rootDir>/src/test/style_mock.json",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(scss|css)$": "<rootDir>/__mocks__/styleMock.js",
"^bundle-loader\\?lazy\\!(.*)$": "$1",
"^src(.*)$": "<rootDir>/src$1",
"^i18n(.*)$": "<rootDir>/i18n$1",
"^static(.*)$": "<rootDir>/static$1",
"^moment(.*)$": "<rootDir>/../node_modules/moment$1",
},
moduleDirectories: [
"src",
"node_modules",
],
reporters: [
"default",
"jest-junit"
],
setupFiles: [
"jest-canvas-mock"
],
setupFilesAfterEnv: [
"<rootDir>/src/test/setup.tsx"
],
testTimeout: 60000,
testEnvironmentOptions: {
url: "http://localhost:8065"
}
};
module.exports = config;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@@ -19,10 +19,11 @@
"check-types:fix": "npm run check-types -- --noEmit --fix",
"check": "npm run check-lint && npm run check-style",
"fix": "npm run check-lint:fix && npm run check-style:fix",
"test": "jest --forceExit --detectOpenHandles --verbose",
"test:watch": "jest --watch",
"test:updatesnapshot": "jest --updateSnapshot",
"test-ci": "jest --ci --forceExit --detectOpenHandles --maxWorkers=100%",
"test": "cross-env TZ=Etc/UTC jest",
"test:watch": "cross-env TZ=Etc/UTC jest --watch",
"test:updatesnapshot": "cross-env TZ=Etc/UTC jest --updateSnapshot",
"test:debug": "cross-env TZ=Etc/UTC jest --forceExit --detectOpenHandles --verbose ",
"test-ci": "cross-env TZ=Etc/UTC jest --ci --maxWorkers=100%",
"clean": "rm -rf node_modules .eslintcache"
},
"dependencies": {
@@ -44,77 +45,26 @@
"fullcalendar": "^5.10.2",
"glob-parent": "6.0.2",
"lodash": "^4.17.21",
"marked": "^4.0.12",
"marked": "4.0.17",
"mini-create-react-context": "^0.4.1",
"moment": "^2.29.1",
"nanoevents": "^5.1.13",
"react": "^16.13.0",
"react": "17.0.2",
"react-beautiful-dnd": "^13.1.1",
"react-day-picker": "^7.4.10",
"react-day-picker": "7.4.10",
"react-dnd": "^14.0.2",
"react-dnd-html5-backend": "^14.0.0",
"react-dnd-scrolling": "^1.2.1",
"react-dnd-touch-backend": "^14.0.0",
"react-dom": "^16.13.0",
"react-dom": "17.0.2",
"react-hot-keys": "^2.7.1",
"react-hotkeys-hook": "^3.4.4",
"react-intl": "^5.20.0",
"react-redux": "^7.2.1",
"react-router-dom": "^5.2.0",
"react-select": "5.7.0",
"react-select": "5.5.9",
"trim-newlines": "^4.0.2"
},
"jest": {
"transform": {
"^.+\\.(js|tsx|ts|tsx)$": "@swc/jest"
},
"transformIgnorePatterns": [
"/nanoevents/",
"node_modules/(?!react-native|react-router|mattermost-webapp|react-day-picker)"
],
"maxWorkers": "50%",
"testEnvironment": "jsdom",
"collectCoverage": true,
"collectCoverageFrom": [
"src/**/*.{ts,tsx,js,jsx}",
"!src/test/**"
],
"moduleFileExtensions": ["js", "jsx", "ts", "tsx"],
"testPathIgnorePatterns": [
"/node_modules/",
"/non_npm_dependencies/"
],
"clearMocks": true,
"coverageReporters": [
"lcov",
"text-summary"
],
"moduleNameMapper": {
"^.+\\.(scss|css)$": "<rootDir>/src/test/style_mock.json",
"^.*i18n.*\\.(json)$": "<rootDir>/src/test/i18n_mock.json",
"^bundle-loader\\?lazy\\!(.*)$": "$1",
"^react$": "<rootDir>/node_modules/react",
"^react-redux$": "<rootDir>/node_modules/react-redux",
"^react-intl$": "<rootDir>/node_modules/react-intl",
"^src(.*)$": "<rootDir>/src$1"
},
"moduleDirectories": [
"src",
"node_modules",
"non_npm_dependencies"
],
"reporters": [
"default",
"jest-junit"
],
"setupFiles": [
"jest-canvas-mock"
],
"setupFilesAfterEnv": [
"<rootDir>/src/test/setup.tsx"
],
"testURL": "http://localhost:8065"
},
"devDependencies": {
"@babel/cli": "7.17.6",
"@babel/core": "7.17.8",
@@ -129,30 +79,32 @@
"@babel/runtime": "7.17.8",
"@formatjs/cli": "^4.8.2",
"@formatjs/ts-transformer": "^3.9.2",
"@swc/jest": "^0.2.24",
"@testing-library/dom": "^8.11.4",
"@testing-library/jest-dom": "^5.16.3",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^13.5.0",
"@swc/core": "1.3.40",
"@swc/jest": "0.2.24",
"@testing-library/dom": "8.20.0",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "12.1.5",
"@testing-library/user-event": "14.4.3",
"@types/color": "^3.0.3",
"@types/draft-js": "^0.11.9",
"@types/emoji-mart": "^3.0.9",
"@types/enzyme": "3.10.11",
"@types/jest": "27.4.1",
"@types/jest": "29.4.2",
"@types/lodash": "4.14.182",
"@types/marked": "^4.0.3",
"@types/nanoevents": "^1.0.0",
"@types/node": "17.0.23",
"@types/react": "^17.0.43",
"@types/node": "16.11.7",
"@types/react": "17.0.53",
"@types/react-beautiful-dnd": "^13.1.2",
"@types/react-dom": "^17.0.14",
"@types/react-day-picker": "5.3.0",
"@types/react-dom": "17.0.19",
"@types/react-redux": "^7.1.23",
"@types/react-router-dom": "^5.3.3",
"@types/react-transition-group": "4.4.4",
"@types/redux-mock-store": "1.0.3",
"@typescript-eslint/eslint-plugin": "5.16.0",
"@typescript-eslint/parser": "5.16.0",
"babel-eslint": "10.1.0",
"babel-eslint": "10.1.0",
"cross-env": "^7.0.3",
"css-loader": "6.7.1",
"eslint": "^8.11.0",
@@ -167,7 +119,7 @@
"eslint-plugin-react": "7.29.4",
"eslint-plugin-react-hooks": "4.3.0",
"eslint-plugin-unused-imports": "2.0.0",
"fetch-mock-jest": "^1.5.1",
"fetch-mock-jest": "1.5.1",
"identity-obj-proxy": "3.0.0",
"image-webpack-loader": "8.1.0",
"imagemin-gifsicle": "^7.0.0",
@@ -177,10 +129,12 @@
"imagemin-svgo": "^10.0.1",
"imagemin-webp": "7.0.0",
"isomorphic-fetch": "3.0.0",
"jest": "27.5.1",
"jest-canvas-mock": "2.3.1",
"jest-junit": "13.0.0",
"jest-mock": "27.5.1",
"jest": "29.5.0",
"jest-canvas-mock": "2.4.0",
"jest-environment-jsdom": "29.5.0",
"jest-fail-on-console": "3.0.2",
"jest-junit": "15.0.0",
"jest-mock": "29.4.3",
"prettier": "^2.6.1",
"redux-mock-store": "^1.5.4",
"sass": "1.49.9",

Просмотреть файл

@@ -1,46 +1,46 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`block tests correctly generate patches from two blocks should add fields on the new fields added and remove it in the undo 1`] = `
Array [
Object {
"deletedFields": Array [],
"updatedFields": Object {
[
{
"deletedFields": [],
"updatedFields": {
"newField": "new field",
},
},
Object {
"deletedFields": Array [
{
"deletedFields": [
"newField",
],
"updatedFields": Object {},
"updatedFields": {},
},
]
`;
exports[`block tests correctly generate patches from two blocks should generate two empty patches for the same block 1`] = `
Array [
Object {
"deletedFields": Array [],
"updatedFields": Object {},
[
{
"deletedFields": [],
"updatedFields": {},
},
Object {
"deletedFields": Array [],
"updatedFields": Object {},
{
"deletedFields": [],
"updatedFields": {},
},
]
`;
exports[`block tests correctly generate patches from two blocks should remove field on the new block added and add it again in the undo 1`] = `
Array [
Object {
"deletedFields": Array [
[
{
"deletedFields": [
"test",
],
"updatedFields": Object {},
"updatedFields": {},
},
Object {
"deletedFields": Array [],
"updatedFields": Object {
{
"deletedFields": [],
"updatedFields": {
"test": "test",
},
},
@@ -48,16 +48,16 @@ Array [
`;
exports[`block tests correctly generate patches from two blocks should update propertie on the main object and revert it back on the undo 1`] = `
Array [
Object {
"deletedFields": Array [],
[
{
"deletedFields": [],
"parentId": "new-parent-id",
"updatedFields": Object {},
"updatedFields": {},
},
Object {
"deletedFields": Array [],
{
"deletedFields": [],
"parentId": "old-parent-id",
"updatedFields": Object {},
"updatedFields": {},
},
]
`;

Просмотреть файл

@@ -1,52 +1,52 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`board tests correctly generate patches for boards and blocks should add fields on update and remove it in the undo 1`] = `
Array [
Object {
"blockIDs": Array [
[
{
"blockIDs": [
"test-old-block-id",
],
"blockPatches": Array [
Object {
"deletedFields": Array [],
"updatedFields": Object {
"blockPatches": [
{
"deletedFields": [],
"updatedFields": {
"newField": "new field",
},
},
],
"boardIDs": Array [
"boardIDs": [
"test-board-id",
],
"boardPatches": Array [
Object {
"deletedCardProperties": Array [],
"deletedProperties": Array [],
"updatedCardProperties": Array [],
"updatedProperties": Object {},
"boardPatches": [
{
"deletedCardProperties": [],
"deletedProperties": [],
"updatedCardProperties": [],
"updatedProperties": {},
},
],
},
Object {
"blockIDs": Array [
{
"blockIDs": [
"test-old-block-id",
],
"blockPatches": Array [
Object {
"deletedFields": Array [
"blockPatches": [
{
"deletedFields": [
"newField",
],
"updatedFields": Object {},
"updatedFields": {},
},
],
"boardIDs": Array [
"boardIDs": [
"test-board-id",
],
"boardPatches": Array [
Object {
"deletedCardProperties": Array [],
"deletedProperties": Array [],
"updatedCardProperties": Array [],
"updatedProperties": Object {},
"boardPatches": [
{
"deletedCardProperties": [],
"deletedProperties": [],
"updatedCardProperties": [],
"updatedProperties": {},
},
],
},
@@ -54,48 +54,48 @@ Array [
`;
exports[`board tests correctly generate patches for boards and blocks should generate two empty patches for the same board and block 1`] = `
Array [
Object {
"blockIDs": Array [
[
{
"blockIDs": [
"test-card-id",
],
"blockPatches": Array [
Object {
"deletedFields": Array [],
"updatedFields": Object {},
"blockPatches": [
{
"deletedFields": [],
"updatedFields": {},
},
],
"boardIDs": Array [
"boardIDs": [
"test-board-id",
],
"boardPatches": Array [
Object {
"deletedCardProperties": Array [],
"deletedProperties": Array [],
"updatedCardProperties": Array [],
"updatedProperties": Object {},
"boardPatches": [
{
"deletedCardProperties": [],
"deletedProperties": [],
"updatedCardProperties": [],
"updatedProperties": {},
},
],
},
Object {
"blockIDs": Array [
{
"blockIDs": [
"test-card-id",
],
"blockPatches": Array [
Object {
"deletedFields": Array [],
"updatedFields": Object {},
"blockPatches": [
{
"deletedFields": [],
"updatedFields": {},
},
],
"boardIDs": Array [
"boardIDs": [
"test-board-id",
],
"boardPatches": Array [
Object {
"deletedCardProperties": Array [],
"deletedProperties": Array [],
"updatedCardProperties": Array [],
"updatedProperties": Object {},
"boardPatches": [
{
"deletedCardProperties": [],
"deletedProperties": [],
"updatedCardProperties": [],
"updatedProperties": {},
},
],
},
@@ -103,16 +103,16 @@ Array [
`;
exports[`board tests correctly generate patches from two boards should add card properties on the redo and remove them on the undo 1`] = `
Array [
Object {
"deletedCardProperties": Array [],
"deletedProperties": Array [],
"updatedCardProperties": Array [
Object {
[
{
"deletedCardProperties": [],
"deletedProperties": [],
"updatedCardProperties": [
{
"id": "new-property-id",
"name": "property-name",
"options": Array [
Object {
"options": [
{
"color": "propColorYellow",
"id": "opt",
"value": "val",
@@ -121,30 +121,30 @@ Array [
"type": "select",
},
],
"updatedProperties": Object {},
"updatedProperties": {},
},
Object {
"deletedCardProperties": Array [
{
"deletedCardProperties": [
"new-property-id",
],
"deletedProperties": Array [],
"updatedCardProperties": Array [],
"updatedProperties": Object {},
"deletedProperties": [],
"updatedCardProperties": [],
"updatedProperties": {},
},
]
`;
exports[`board tests correctly generate patches from two boards should add card properties on the redo and undo if they exists in both, but differ 1`] = `
Array [
Object {
"deletedCardProperties": Array [],
"deletedProperties": Array [],
"updatedCardProperties": Array [
Object {
[
{
"deletedCardProperties": [],
"deletedProperties": [],
"updatedCardProperties": [
{
"id": "new-property-id",
"name": "property-name",
"options": Array [
Object {
"options": [
{
"color": "propColorYellow",
"id": "opt",
"value": "val",
@@ -153,17 +153,17 @@ Array [
"type": "select",
},
],
"updatedProperties": Object {},
"updatedProperties": {},
},
Object {
"deletedCardProperties": Array [],
"deletedProperties": Array [],
"updatedCardProperties": Array [
Object {
{
"deletedCardProperties": [],
"deletedProperties": [],
"updatedCardProperties": [
{
"id": "new-property-id",
"name": "a-different-name",
"options": Array [
Object {
"options": [
{
"color": "propColorYellow",
"id": "opt",
"value": "val",
@@ -172,22 +172,22 @@ Array [
"type": "select",
},
],
"updatedProperties": Object {},
"updatedProperties": {},
},
]
`;
exports[`board tests correctly generate patches from two boards should add card properties on the redo and undo if they exists in both, but their options are different 1`] = `
Array [
Object {
"deletedCardProperties": Array [],
"deletedProperties": Array [],
"updatedCardProperties": Array [
Object {
[
{
"deletedCardProperties": [],
"deletedProperties": [],
"updatedCardProperties": [
{
"id": "new-property-id",
"name": "property-name",
"options": Array [
Object {
"options": [
{
"color": "propColorYellow",
"id": "opt",
"value": "val",
@@ -196,17 +196,17 @@ Array [
"type": "select",
},
],
"updatedProperties": Object {},
"updatedProperties": {},
},
Object {
"deletedCardProperties": Array [],
"deletedProperties": Array [],
"updatedCardProperties": Array [
Object {
{
"deletedCardProperties": [],
"deletedProperties": [],
"updatedCardProperties": [
{
"id": "new-property-id",
"name": "property-name",
"options": Array [
Object {
"options": [
{
"color": "propColorBrown",
"id": "another-opt",
"value": "val",
@@ -215,45 +215,45 @@ Array [
"type": "select",
},
],
"updatedProperties": Object {},
"updatedProperties": {},
},
]
`;
exports[`board tests correctly generate patches from two boards should add properties on the update patch and remove them on the undo 1`] = `
Array [
Object {
"deletedCardProperties": Array [],
"deletedProperties": Array [],
"updatedCardProperties": Array [],
"updatedProperties": Object {
[
{
"deletedCardProperties": [],
"deletedProperties": [],
"updatedCardProperties": [],
"updatedProperties": {
"prop1": "val1",
},
},
Object {
"deletedCardProperties": Array [],
"deletedProperties": Array [
{
"deletedCardProperties": [],
"deletedProperties": [
"prop1",
],
"updatedCardProperties": Array [],
"updatedProperties": Object {},
"updatedCardProperties": [],
"updatedProperties": {},
},
]
`;
exports[`board tests correctly generate patches from two boards should generate two empty patches for the same board 1`] = `
Array [
Object {
"deletedCardProperties": Array [],
"deletedProperties": Array [],
"updatedCardProperties": Array [],
"updatedProperties": Object {},
[
{
"deletedCardProperties": [],
"deletedProperties": [],
"updatedCardProperties": [],
"updatedProperties": {},
},
Object {
"deletedCardProperties": Array [],
"deletedProperties": Array [],
"updatedCardProperties": Array [],
"updatedProperties": Object {},
{
"deletedCardProperties": [],
"deletedProperties": [],
"updatedCardProperties": [],
"updatedProperties": {},
},
]
`;

Просмотреть файл

@@ -12,7 +12,7 @@ import {Utils} from './utils'
import {IPropertyTemplate} from './blocks/board'
jest.mock('./utils')
const mockedUtils = mocked(Utils, true)
const mockedUtils = mocked(Utils)
const dayMillis = 24 * 60 * 60 * 1000

Просмотреть файл

@@ -434,7 +434,7 @@ exports[`components/cardDialog limited card shows hidden view (no toolbar) 1`] =
<p
class="CardDetail__limited-body"
>
Upgrade to our Professional or Enterprise plan to view archived cards, have unlimited views per boards, unlimited cards and more.
Upgrade to our Professional or Enterprise plan.
<br />
<a
class="CardDetail__limited-link"

Просмотреть файл

@@ -317,7 +317,7 @@ exports[`components/centerPanel Clicking on the Hidden card count should open a
</button>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -982,7 +982,7 @@ exports[`components/centerPanel return centerPanel and click on card to show car
>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -1580,7 +1580,7 @@ exports[`components/centerPanel return centerPanel and click on new card to edit
</button>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -2102,7 +2102,7 @@ exports[`components/centerPanel return centerPanel and press touch 1 with readon
</button>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -2639,7 +2639,7 @@ exports[`components/centerPanel return centerPanel and press touch ctrl+d for on
</button>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -3298,7 +3298,7 @@ exports[`components/centerPanel return centerPanel and press touch del for one c
</button>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -3957,7 +3957,7 @@ exports[`components/centerPanel return centerPanel and press touch esc for one c
</button>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -4616,7 +4616,7 @@ exports[`components/centerPanel return centerPanel and press touch esc for one c
</button>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -5275,7 +5275,7 @@ exports[`components/centerPanel return centerPanel and press touch esc for two c
</button>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -5934,7 +5934,7 @@ exports[`components/centerPanel return centerPanel and press touch esc for two c
</button>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -6593,7 +6593,7 @@ exports[`components/centerPanel return centerPanel and press touch esc for two c
</button>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -7252,7 +7252,7 @@ exports[`components/centerPanel return centerPanel and select one card and click
</button>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -7911,7 +7911,7 @@ exports[`components/centerPanel return centerPanel and select one card and click
</button>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -8802,7 +8802,7 @@ exports[`components/centerPanel should match snapshot for Kanban 1`] = `
>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -9322,7 +9322,7 @@ exports[`components/centerPanel should match snapshot for Kanban, not shared 1`]
>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>
@@ -9886,7 +9886,7 @@ exports[`components/centerPanel should match snapshot for Table 1`] = `
</button>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>

Просмотреть файл

@@ -54,7 +54,7 @@ exports[`/components/confirmAddUserForNotifications should match snapshot 1`] =
class="ConfirmAddUserForNotifications"
>
<p>
fake-username is not a member of the board, and will not receive any notifications about it.
fake-username isn't a member of the board, and won't receive any notifications about it.
</p>
<p>
Do you want to add fake-username to the board?

Просмотреть файл

@@ -1041,7 +1041,7 @@ exports[`properties/person show multiple, display modal 2`] = `
<span
id="aria-context"
>
option username-3 focused, 3 of 3. 1 result available. Use Up and Down to choose options, press Enter to select the currently focused option, press Escape to exit the menu, press Tab to select the option and exit the menu.
option username-3 focused, 1 of 1. 1 result available. Use Up and Down to choose options, press Enter to select the currently focused option, press Escape to exit the menu, press Tab to select the option and exit the menu.
</span>
</span>
<div

Просмотреть файл

@@ -16,36 +16,15 @@ exports[`components/propertyValueElement Generic fields should allow cancel 1`]
exports[`components/propertyValueElement URL fields should allow cancel 1`] = `
<div>
<div
class="URLProperty octo-propertyvalue"
class="URLProperty"
>
<a
class="link"
href="http://localhost"
rel="noreferrer"
target="_blank"
>
http://localhost
</a>
<button
aria-label="Edit"
class="IconButton Button_Edit"
title="Edit"
type="button"
>
<i
class="CompassIcon icon-pencil-outline EditIcon"
/>
</button>
<button
aria-label="Copy"
class="IconButton Button_Copy"
title="Copy"
type="button"
>
<i
class="CompassIcon icon-content-copy content-copy"
/>
</button>
<input
class="Editable octo-propertyvalue"
placeholder="Empty"
style="width: 100%;"
title=""
value=""
/>
</div>
</div>
`;

Просмотреть файл

@@ -110,7 +110,7 @@ exports[`components/rhsChannelBoardItem render board with menu open 1`] = `
<div
class="menu-subtext text-75 mt-1"
>
You are not an admin of the board
You're not an admin of the board
</div>
</div>
<div

Просмотреть файл

@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`/components/viewMenu should match snapshot 1`] = `
Object {
{
"asFragment": [Function],
"baseElement": <body>
<div>
@@ -530,7 +530,7 @@ Object {
`;
exports[`/components/viewMenu should match snapshot, read only 1`] = `
Object {
{
"asFragment": [Function],
"baseElement": <body>
<div>

Просмотреть файл

@@ -46,7 +46,7 @@ exports[`src/components/workspace return workspace and showcard 1`] = `
/>
<div>
<span>
Find Boards
Find boards
</span>
</div>
</div>
@@ -73,6 +73,7 @@ exports[`src/components/workspace return workspace and showcard 1`] = `
>
<div
data-rbd-draggable-context-id="1"
data-rbd-draggable-id="categoryAttributeId1"
>
<div
class="SidebarCategory"
@@ -80,14 +81,16 @@ exports[`src/components/workspace return workspace and showcard 1`] = `
<div
class="categoryBoardsDroppableArea"
data-rbd-droppable-context-id="1"
data-rbd-droppable-id="categoryAttributeId1"
>
<div
class="octo-sidebar-item category expanded active"
class="octo-sidebar-item category expanded "
>
<div
aria-describedby="rbd-hidden-text-1-hidden-text-5"
class="octo-sidebar-title category-title"
data-rbd-drag-handle-context-id="1"
data-rbd-drag-handle-draggable-id="categoryAttributeId1"
draggable="false"
role="button"
tabindex="0"
@@ -463,7 +466,7 @@ exports[`src/components/workspace return workspace and showcard 1`] = `
>
<span
class="Label empty "
title="Items with an empty Property 2 property will go here. This column cannot be removed."
title="Items with an empty Property 2 property will go here. This column can't be removed."
>
No Property 2
</span>
@@ -875,7 +878,7 @@ exports[`src/components/workspace return workspace readonly and showcard 1`] = `
>
<span
class="Label empty "
title="Items with an empty Property 2 property will go here. This column cannot be removed."
title="Items with an empty Property 2 property will go here. This column can't be removed."
>
No Property 2
</span>
@@ -1097,7 +1100,7 @@ exports[`src/components/workspace should match snapshot 1`] = `
/>
<div>
<span>
Find Boards
Find boards
</span>
</div>
</div>
@@ -1124,6 +1127,7 @@ exports[`src/components/workspace should match snapshot 1`] = `
>
<div
data-rbd-draggable-context-id="0"
data-rbd-draggable-id="categoryAttributeId1"
>
<div
class="SidebarCategory"
@@ -1131,14 +1135,16 @@ exports[`src/components/workspace should match snapshot 1`] = `
<div
class="categoryBoardsDroppableArea"
data-rbd-droppable-context-id="0"
data-rbd-droppable-id="categoryAttributeId1"
>
<div
class="octo-sidebar-item category expanded active"
class="octo-sidebar-item category expanded "
>
<div
aria-describedby="rbd-hidden-text-0-hidden-text-0"
class="octo-sidebar-title category-title"
data-rbd-drag-handle-context-id="0"
data-rbd-drag-handle-draggable-id="categoryAttributeId1"
draggable="false"
role="button"
tabindex="0"
@@ -1514,7 +1520,7 @@ exports[`src/components/workspace should match snapshot 1`] = `
>
<span
class="Label empty "
title="Items with an empty Property 2 property will go here. This column cannot be removed."
title="Items with an empty Property 2 property will go here. This column can't be removed."
>
No Property 2
</span>
@@ -1926,7 +1932,7 @@ exports[`src/components/workspace should match snapshot with readonly 1`] = `
>
<span
class="Label empty "
title="Items with an empty Property 2 property will go here. This column cannot be removed."
title="Items with an empty Property 2 property will go here. This column can't be removed."
>
No Property 2
</span>

Просмотреть файл

@@ -4,7 +4,6 @@
import React, {ReactElement, ReactNode} from 'react'
import {render, screen, waitFor} from '@testing-library/react'
import '@testing-library/jest-dom'
import {mocked} from 'jest-mock'
@@ -35,7 +34,7 @@ const wrap = (child: ReactNode): ReactElement => (
)
jest.mock('src/mutator')
const mockedMutator = mocked(mutator, true)
const mockedMutator = mocked(mutator)
describe('components/addContentMenuItem', () => {
beforeEach(() => {
@@ -66,7 +65,7 @@ describe('components/addContentMenuItem', () => {
)
expect(container).toMatchSnapshot()
const buttonElement = screen.getByRole('button', {name: 'text'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
await waitFor(() => expect(mockedMutator.insertBlock).toBeCalled())
})
@@ -82,7 +81,7 @@ describe('components/addContentMenuItem', () => {
)
expect(container).toMatchSnapshot()
const buttonElement = screen.getByRole('button', {name: 'checkbox'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
await waitFor(() => expect(mockedMutator.insertBlock).toBeCalled())
})
@@ -98,11 +97,12 @@ describe('components/addContentMenuItem', () => {
)
expect(container).toMatchSnapshot()
const buttonElement = screen.getByRole('button', {name: 'divider'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
await waitFor(() => expect(mockedMutator.insertBlock).toBeCalled())
})
test('return an error and empty element from unknown type', () => {
jest.spyOn(console, 'error').mockImplementation()
const {container} = render(
wrap(
<AddContentMenuItem
@@ -112,6 +112,8 @@ describe('components/addContentMenuItem', () => {
/>,
),
)
expect(console.error).toBeCalledWith(expect.stringContaining('addContentMenu, unknown content type: unknown'))
expect(container).toMatchSnapshot()
})
})

Просмотреть файл

@@ -2,16 +2,10 @@
// See LICENSE.txt for license information.
import React from 'react'
import {
fireEvent,
render,
screen,
act
} from '@testing-library/react'
import {fireEvent, render, screen} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import '@testing-library/jest-dom'
import {mocked} from 'jest-mock'
@@ -27,7 +21,7 @@ const card = TestBlockFactory.createCard()
const icon = '👍'
jest.mock('src/mutator')
const mockedMutator = mocked(mutator, true)
const mockedMutator = mocked(mutator)
describe('components/blockIconSelector', () => {
beforeEach(() => {
@@ -53,14 +47,14 @@ describe('components/blockIconSelector', () => {
))
expect(container).toMatchSnapshot()
})
test('return menu on click', () => {
test('return menu on click', async () => {
const {container} = render(wrapIntl(
<BlockIconSelector
block={card}
size='l'
/>,
))
userEvent.click(screen.getByRole('button', {name: 'menuwrapper'}))
await userEvent.click(screen.getByRole('button', {name: 'menuwrapper'}))
expect(container).toMatchSnapshot()
})
test('return no menu in readonly', () => {
@@ -73,54 +67,50 @@ describe('components/blockIconSelector', () => {
expect(container).toMatchSnapshot()
})
test('return a new icon after click on random menu', () => {
test('return a new icon after click on random menu', async () => {
render(wrapIntl(
<BlockIconSelector
block={card}
size='l'
/>,
))
userEvent.click(screen.getByRole('button', {name: 'menuwrapper'}))
await userEvent.click(screen.getByRole('button', {name: 'menuwrapper'}))
const buttonRandom = screen.queryByRole('button', {name: 'Random'})
expect(buttonRandom).not.toBeNull()
userEvent.click(buttonRandom!)
await userEvent.click(buttonRandom!)
expect(mockedMutator.changeBlockIcon).toBeCalledTimes(1)
})
test('return a new icon after click on EmojiPicker', () => {
test('return a new icon after click on EmojiPicker', async () => {
const {container, getByRole, getAllByRole} = render(wrapIntl(
<BlockIconSelector
block={card}
size='l'
/>,
))
act(() => {
userEvent.click(getByRole('button', {name: 'menuwrapper'}))
})
await userEvent.click(getByRole('button', {name: 'menuwrapper'}))
const menuPicker = container.querySelector('div#pick')
expect(menuPicker).not.toBeNull()
act(() => {
fireEvent.mouseEnter(menuPicker!)
})
fireEvent.mouseEnter(menuPicker!)
const allButtonThumbUp = getAllByRole('button', {name: /thumbsup/i})
userEvent.click(allButtonThumbUp[0])
await userEvent.click(allButtonThumbUp[0])
expect(mockedMutator.changeBlockIcon).toBeCalledTimes(1)
expect(mockedMutator.changeBlockIcon).toBeCalledWith(card.boardId, card.id, card.fields.icon, '👍')
})
test('return no icon after click on remove menu', () => {
test('return no icon after click on remove menu', async () => {
const {container, rerender} = render(wrapIntl(
<BlockIconSelector
block={card}
size='l'
/>,
))
userEvent.click(screen.getByRole('button', {name: 'menuwrapper'}))
await userEvent.click(screen.getByRole('button', {name: 'menuwrapper'}))
const buttonRemove = screen.queryByRole('button', {name: 'Remove icon'})
expect(buttonRemove).not.toBeNull()
userEvent.click(buttonRemove!)
await userEvent.click(buttonRemove!)
expect(mockedMutator.changeBlockIcon).toBeCalledTimes(1)
expect(mockedMutator.changeBlockIcon).toBeCalledWith(card.boardId, card.id, card.fields.icon, '', 'remove icon')

Просмотреть файл

@@ -14,7 +14,18 @@ exports[`components/blocksEditor/blocksEditor should match snapshot on empty 1`]
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-2-live-region"
/>
>
<span
id="aria-selection"
>
option , selected.
</span>
<span
id="aria-context"
>
Select is focused ,type to refine list, press Down to open the menu,
</span>
</span>
<span
aria-atomic="false"
aria-live="polite"
@@ -22,7 +33,7 @@ exports[`components/blocksEditor/blocksEditor should match snapshot on empty 1`]
class="css-1f43avz-a11yText-A11yText"
/>
<div
class=" css-4bb158-control"
class=" css-1x912dq-control"
>
<div
class=" css-30zlo3-ValueContainer"
@@ -394,7 +405,18 @@ exports[`components/blocksEditor/blocksEditor should match snapshot with blocks
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-3-live-region"
/>
>
<span
id="aria-selection"
>
option , selected.
</span>
<span
id="aria-context"
>
Select is focused ,type to refine list, press Down to open the menu,
</span>
</span>
<span
aria-atomic="false"
aria-live="polite"
@@ -402,7 +424,7 @@ exports[`components/blocksEditor/blocksEditor should match snapshot with blocks
class="css-1f43avz-a11yText-A11yText"
/>
<div
class=" css-4bb158-control"
class=" css-1x912dq-control"
>
<div
class=" css-30zlo3-ValueContainer"

Просмотреть файл

@@ -76,7 +76,18 @@ exports[`components/blocksEditor/editor should match snapshot on empty 1`] = `
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-2-live-region"
/>
>
<span
id="aria-selection"
>
option , selected.
</span>
<span
id="aria-context"
>
Select is focused ,type to refine list, press Down to open the menu,
</span>
</span>
<span
aria-atomic="false"
aria-live="polite"
@@ -84,7 +95,7 @@ exports[`components/blocksEditor/editor should match snapshot on empty 1`] = `
class="css-1f43avz-a11yText-A11yText"
/>
<div
class=" css-4bb158-control"
class=" css-1x912dq-control"
>
<div
class=" css-30zlo3-ValueContainer"

Просмотреть файл

@@ -8,7 +8,18 @@ exports[`components/blocksEditor/rootInput should match Display snapshot 1`] = `
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-2-live-region"
/>
>
<span
id="aria-selection"
>
option , selected.
</span>
<span
id="aria-context"
>
Select is focused ,type to refine list, press Down to open the menu,
</span>
</span>
<span
aria-atomic="false"
aria-live="polite"
@@ -16,7 +27,7 @@ exports[`components/blocksEditor/rootInput should match Display snapshot 1`] = `
class="css-1f43avz-a11yText-A11yText"
/>
<div
class=" css-4bb158-control"
class=" css-1x912dq-control"
>
<div
class=" css-30zlo3-ValueContainer"
@@ -60,7 +71,18 @@ exports[`components/blocksEditor/rootInput should match Input snapshot 1`] = `
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-3-live-region"
/>
>
<span
id="aria-selection"
>
option , selected.
</span>
<span
id="aria-context"
>
Select is focused ,type to refine list, press Down to open the menu,
</span>
</span>
<span
aria-atomic="false"
aria-live="polite"
@@ -68,7 +90,7 @@ exports[`components/blocksEditor/rootInput should match Input snapshot 1`] = `
class="css-1f43avz-a11yText-A11yText"
/>
<div
class=" css-4bb158-control"
class=" css-1x912dq-control"
>
<div
class=" css-30zlo3-ValueContainer"
@@ -118,9 +140,18 @@ exports[`components/blocksEditor/rootInput should match Input snapshot with menu
aria-live="polite"
aria-relevant="additions text"
class="css-1f43avz-a11yText-A11yText"
/>
>
<span
id="aria-selection"
/>
<span
id="aria-context"
>
option /title Creates a new Title block. focused, 1 of 11. 11 results available. Use Up and Down to choose options, press Enter to select the currently focused option, press Escape to exit the menu, press Tab to select the option and exit the menu.
</span>
</span>
<div
class=" css-4bb158-control"
class=" css-1x912dq-control"
>
<div
class=" css-30zlo3-ValueContainer"
@@ -161,7 +192,7 @@ exports[`components/blocksEditor/rootInput should match Input snapshot with menu
/>
</div>
<div
class=" css-1aj7brc"
class=" css-u0i6pk-MenuPortal"
>
<div
class=" css-1rsmi4x-menu"

Просмотреть файл

@@ -10,7 +10,12 @@ import {
act
} from '@testing-library/react'
import {mockDOM, wrapDNDIntl, mockStateStore} from 'src/testUtils'
import {
mockDOM,
wrapDNDIntl,
mockStateStore,
setup
} from 'src/testUtils'
import {TestBlockFactory} from 'src/test/testBlockFactory'
import BlockContent from './blockContent'
@@ -141,26 +146,28 @@ describe('components/blocksEditor/blockContent', () => {
test('should call onSave on hit enter in the input', async () => {
const onSave = jest.fn()
await act(async () => {
render(wrapDNDIntl(
<ReduxProvider store={store}>
<BlockContent
boardId='fake-board-id'
block={block}
contentOrder={[block.id]}
editing={block}
setEditing={jest.fn()}
setAfterBlock={jest.fn()}
onSave={onSave}
onMove={jest.fn()}
/>
</ReduxProvider>,
))
})
const {user} = setup(wrapDNDIntl(
<ReduxProvider store={store}>
<BlockContent
boardId='fake-board-id'
block={block}
contentOrder={[block.id]}
editing={block}
setEditing={jest.fn()}
setAfterBlock={jest.fn()}
onSave={onSave}
onMove={jest.fn()}
/>
</ReduxProvider>,
))
const input = screen.getByDisplayValue('Title')
expect(onSave).not.toBeCalled()
fireEvent.change(input, {target: {value: 'test'}})
fireEvent.keyDown(input, {key: 'Enter'})
await act(async () => {
await user.clear(input)
await user.type(input, 'test')
await user.keyboard('{Enter}')
})
expect(onSave).toBeCalledWith(expect.objectContaining({value: 'test'}))
})

Просмотреть файл

@@ -13,7 +13,7 @@ jest.mock('src/octoClient')
describe('components/blocksEditor/blocks/attachment', () => {
test('should match Display snapshot', async () => {
const mockedOcto = mocked(octoClient, true)
const mockedOcto = mocked(octoClient)
mockedOcto.getFileAsDataUrl.mockResolvedValue({url: 'test.jpg'})
const Component = AttachmentBlock.Display
const {container} = render(

Просмотреть файл

@@ -13,7 +13,7 @@ jest.mock('src/octoClient')
describe('components/blocksEditor/blocks/image', () => {
test('should match Display snapshot', async () => {
const mockedOcto = mocked(octoClient, true)
const mockedOcto = mocked(octoClient)
mockedOcto.getFileAsDataUrl.mockResolvedValue({url: 'test.jpg'})
const Component = ImageBlock.Display
const {container} = render(

Просмотреть файл

@@ -13,7 +13,7 @@ jest.mock('src/octoClient')
describe('components/blocksEditor/blocks/video', () => {
test('should match Display snapshot', async () => {
const mockedOcto = mocked(octoClient, true)
const mockedOcto = mocked(octoClient)
mockedOcto.getFileAsDataUrl.mockResolvedValue({url: 'test.jpg'})
const Component = VideoBlock.Display
const {container} = render(

Просмотреть файл

@@ -10,9 +10,15 @@ import {
act
} from '@testing-library/react'
import {mockDOM, wrapDNDIntl, mockStateStore} from 'src/testUtils'
import {
mockDOM,
wrapDNDIntl,
mockStateStore,
setup
} from 'src/testUtils'
import {TestBlockFactory} from 'src/test/testBlockFactory'
import {BlockData} from './blocks/types'
import BlocksEditor from './blocksEditor'
@@ -95,28 +101,25 @@ describe('components/blocksEditor/blocksEditor', () => {
test('should call onBlockCreate after introduce text and hit enter', async () => {
const onBlockCreated = jest.fn()
const {user} = setup(wrapDNDIntl(
<ReduxProvider store={store}>
<BlocksEditor
boardId='test-board'
onBlockCreated={onBlockCreated}
onBlockModified={jest.fn()}
onBlockMoved={jest.fn()}
blocks={[]}
/>
</ReduxProvider>,
))
expect(onBlockCreated).not.toBeCalled()
await act(async () => {
render(wrapDNDIntl(
<ReduxProvider store={store}>
<BlocksEditor
boardId='test-board'
onBlockCreated={onBlockCreated}
onBlockModified={jest.fn()}
onBlockMoved={jest.fn()}
blocks={[]}
/>
</ReduxProvider>,
))
await user.type(screen.getByRole('combobox'), '/title')
await user.keyboard('{Enter}')
await user.type(screen.getByRole('textbox'), 'test')
await user.keyboard('{Enter}')
})
let input = screen.getByDisplayValue('')
expect(onBlockCreated).not.toBeCalled()
fireEvent.change(input, {target: {value: '/title'}})
fireEvent.keyDown(input, {key: 'Enter'})
input = screen.getByDisplayValue('')
fireEvent.change(input, {target: {value: 'test'}})
fireEvent.keyDown(input, {key: 'Enter'})
expect(onBlockCreated).toBeCalledWith(expect.objectContaining({value: 'test'}))
})
@@ -138,7 +141,7 @@ describe('components/blocksEditor/blocksEditor', () => {
const input = screen.getByTestId('checkbox-check')
expect(onBlockModified).not.toBeCalled()
fireEvent.click(input)
expect(onBlockModified).toBeCalledWith(expect.objectContaining({value: {checked: false, value: 'Checkbox'}}))
})
expect(onBlockModified).toBeCalledWith(expect.objectContaining({value: {checked: false, value: 'Checkbox'}}))
})
})

Просмотреть файл

@@ -3,14 +3,14 @@
import React from 'react'
import {Provider as ReduxProvider} from 'react-redux'
import {
render,
screen,
fireEvent,
act
} from '@testing-library/react'
import {render, screen, act} from '@testing-library/react'
import {mockDOM, wrapDNDIntl, mockStateStore} from 'src/testUtils'
import {
mockDOM,
wrapDNDIntl,
mockStateStore,
setup
} from 'src/testUtils'
import {TestBlockFactory} from 'src/test/testBlockFactory'
import Editor from './editor'
@@ -82,25 +82,20 @@ describe('components/blocksEditor/editor', () => {
test('should call onSave after introduce text and hit enter', async () => {
const onSave = jest.fn()
const {user} = setup(wrapDNDIntl(
<ReduxProvider store={store}>
<Editor
boardId='fake-board-id'
onSave={onSave}
/>
</ReduxProvider>,
))
await act(async () => {
render(wrapDNDIntl(
<ReduxProvider store={store}>
<Editor
boardId='fake-board-id'
onSave={onSave}
/>
</ReduxProvider>,
))
await user.type(screen.getByRole('combobox'), '/title')
await user.keyboard('{Enter}')
await user.type(screen.getByRole('textbox'), 'test')
await user.keyboard('{Enter}')
})
let input = screen.getByDisplayValue('')
expect(onSave).not.toBeCalled()
fireEvent.change(input, {target: {value: '/title'}})
fireEvent.keyDown(input, {key: 'Enter'})
expect(onSave).not.toBeCalled()
input = screen.getByDisplayValue('')
fireEvent.change(input, {target: {value: 'test'}})
fireEvent.keyDown(input, {key: 'Enter'})
expect(onSave).toBeCalledWith(expect.objectContaining({value: 'test'}))
})

Просмотреть файл

@@ -1,8 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useState} from 'react'
import Select from 'react-select'
import {CSSObject} from '@emotion/serialize'
import Select, {StylesConfig} from 'react-select'
import {getSelectBaseStyle} from 'src/theme'
@@ -16,11 +15,11 @@ type Props = {
value: string
}
const baseStyles = getSelectBaseStyle()
const baseStyles = getSelectBaseStyle<ContentType>()
const styles = {
const styles: StylesConfig<ContentType> = {
...baseStyles,
control: (provided: CSSObject): CSSObject => ({
control: (provided) => ({
...provided,
width: '100%',
height: '100%',
@@ -29,12 +28,12 @@ const styles = {
color: 'rgb(var(--center-channel-color-rgb))',
flexDirection: 'row',
}),
input: (provided: CSSObject): CSSObject => ({
input: (provided) => ({
...provided,
background: 'rgb(var(--center-channel-bg-rgb))',
color: 'rgb(var(--center-channel-color-rgb))',
}),
menu: (provided: CSSObject): CSSObject => ({
menu: (provided) => ({
...provided,
minWidth: '100%',
width: 'max-content',
@@ -42,7 +41,7 @@ const styles = {
left: '0',
marginBottom: '0',
}),
menuPortal: (provided: CSSObject): CSSObject => ({
menuPortal: (provided) => ({
...provided,
zIndex: 999,
}),
@@ -52,7 +51,7 @@ export default function RootInput(props: Props) {
const [showMenu, setShowMenu] = useState(false)
return (
<Select
<Select<ContentType>
styles={styles}
components={{DropdownIndicator: () => null, IndicatorSeparator: () => null}}
className='RootInput'
@@ -62,8 +61,8 @@ export default function RootInput(props: Props) {
menuPortalTarget={document.getElementById('focalboard-root-portal')}
menuPosition={'fixed'}
options={registry.list()}
getOptionValue={(ct: ContentType) => ct.slashCommand}
getOptionLabel={(ct: ContentType) => ct.slashCommand + ' Creates a new ' + ct.displayName + ' block.'}
getOptionValue={(ct) => ct.slashCommand}
getOptionLabel={(ct) => ct.slashCommand + ' Creates a new ' + ct.displayName + ' block.'}
filterOption={(option: any, inputValue: string): boolean => {
return inputValue.startsWith(option.value) || option.value.startsWith(inputValue)
}}
@@ -90,7 +89,7 @@ export default function RootInput(props: Props) {
props.onChange('')
}
}}
onFocus={(e: React.FocusEvent) => {
onFocus={(e) => {
const target = e.currentTarget
target.scrollIntoView({block: 'center'})
}}

Просмотреть файл

@@ -21,7 +21,7 @@ import {wrapIntl} from 'src/testUtils'
import BoardSelector from './boardSelector'
jest.mock('src/octoClient')
const mockedOctoClient = mocked(octoClient, true)
const mockedOctoClient = mocked(octoClient)
const wait = (ms: number) => {
return new Promise<void>((resolve) => {

Просмотреть файл

@@ -132,7 +132,7 @@ exports[`components/boardTemplateSelector/boardTemplateSelector a focalboard Plu
class="CompassIcon icon-kanban"
/>
<span>
Create empty board
Create an empty board
</span>
</button>
</div>
@@ -284,7 +284,7 @@ exports[`components/boardTemplateSelector/boardTemplateSelector a focalboard Plu
class="CompassIcon icon-kanban"
/>
<span>
Create empty board
Create an empty board
</span>
</button>
</div>
@@ -436,7 +436,7 @@ exports[`components/boardTemplateSelector/boardTemplateSelector a focalboard Plu
class="CompassIcon icon-kanban"
/>
<span>
Create empty board
Create an empty board
</span>
</button>
</div>

Просмотреть файл

@@ -195,7 +195,7 @@ exports[`components/boardTemplateSelector/boardTemplateSelectorPreview should ma
>
<span
class="Label empty "
title="Items with an empty name property will go here. This column cannot be removed."
title="Items with an empty name property will go here. This column can't be removed."
>
No name
</span>

Просмотреть файл

@@ -1,9 +1,9 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {
act,
render,
screen,
act,
waitFor,
within
} from '@testing-library/react'
@@ -50,11 +50,11 @@ jest.mock('src/mutator')
jest.mock('src/utils')
jest.mock('src/telemetry/telemetryClient')
const mockedTelemetry = mocked(TelemetryClient, true)
const mockedTelemetry = mocked(TelemetryClient)
describe('components/boardTemplateSelector/boardTemplateSelector', () => {
const mockedMutator = mocked(Mutator, true)
const mockedOctoClient = mocked(client, true)
const mockedMutator = mocked(Mutator)
const mockedOctoClient = mocked(client)
const team1: Team = {
id: 'team-1',
title: 'Team 1',
@@ -194,7 +194,7 @@ describe('components/boardTemplateSelector/boardTemplateSelector', () => {
), {wrapper: MemoryRouter})
expect(container).toMatchSnapshot()
})
test('return BoardTemplateSelector and click close call the onClose callback', () => {
test('return BoardTemplateSelector and click close call the onClose callback', async () => {
const onClose = jest.fn()
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
@@ -204,10 +204,10 @@ describe('components/boardTemplateSelector/boardTemplateSelector', () => {
), {wrapper: MemoryRouter})
const divCloseButton = container.querySelector('div.toolbar .CloseIcon')
expect(divCloseButton).not.toBeNull()
userEvent.click(divCloseButton!)
await userEvent.click(divCloseButton!)
expect(onClose).toBeCalledTimes(1)
})
test('return BoardTemplateSelector and click new template', () => {
test('return BoardTemplateSelector and click new template', async () => {
render(wrapDNDIntl(
<ReduxProvider store={store}>
<BoardTemplateSelector onClose={jest.fn()}/>
@@ -216,7 +216,7 @@ describe('components/boardTemplateSelector/boardTemplateSelector', () => {
), {wrapper: MemoryRouter})
const divNewTemplate = screen.getByText('Create new template').parentElement
expect(divNewTemplate).not.toBeNull()
userEvent.click(divNewTemplate!)
await userEvent.click(divNewTemplate!)
expect(mockedMutator.addEmptyBoardTemplate).toBeCalledTimes(1)
})
test('return BoardTemplateSelector and click empty board', async () => {
@@ -230,9 +230,9 @@ describe('components/boardTemplateSelector/boardTemplateSelector', () => {
,
), {wrapper: MemoryRouter})
const divEmptyboard = screen.getByText('Create empty board').parentElement
const divEmptyboard = screen.getByText('Create an empty board').parentElement
expect(divEmptyboard).not.toBeNull()
userEvent.click(divEmptyboard!)
await userEvent.click(divEmptyboard!)
expect(mockedMutator.addEmptyBoard).toBeCalledTimes(1)
await waitFor(() => expect(mockedMutator.updateBoard).toBeCalledWith(newBoard, newBoard, 'linked channel'))
})
@@ -247,17 +247,13 @@ describe('components/boardTemplateSelector/boardTemplateSelector', () => {
), {wrapper: MemoryRouter, container: document.body.appendChild(root)})
const deleteIcon = screen.getByText(template1Title).parentElement?.querySelector('.DeleteIcon')
expect(deleteIcon).not.toBeNull()
act(() => {
userEvent.click(deleteIcon!)
})
await act(() => userEvent.click(deleteIcon!))
const {getByText} = within(root)
const deleteConfirm = getByText('Delete')
expect(deleteConfirm).not.toBeNull()
await act(async () => {
await userEvent.click(deleteConfirm!)
})
await act(() => userEvent.click(deleteConfirm!))
expect(mockedMutator.deleteBoard).toBeCalledTimes(1)
})
@@ -273,7 +269,7 @@ describe('components/boardTemplateSelector/boardTemplateSelector', () => {
))
const editIcon = screen.getByText(template1Title).parentElement?.querySelector('.EditIcon')
expect(editIcon).not.toBeNull()
userEvent.click(editIcon!)
await userEvent.click(editIcon!)
})
test('return BoardTemplateSelector and click to add board from template', async () => {
const newBoard = createBoard({id: 'new-board'} as Board)
@@ -288,15 +284,12 @@ describe('components/boardTemplateSelector/boardTemplateSelector', () => {
const divBoardToSelect = screen.getByText(template1Title).parentElement
expect(divBoardToSelect).not.toBeNull()
act(() => {
userEvent.click(divBoardToSelect!)
})
await userEvent.click(divBoardToSelect!)
const useTemplateButton = screen.getByText('Use this template').parentElement
expect(useTemplateButton).not.toBeNull()
act(() => {
userEvent.click(useTemplateButton!)
})
await userEvent.click(useTemplateButton!)
await waitFor(() => expect(mockedMutator.addBoardFromTemplate).toBeCalledTimes(1))
await waitFor(() => expect(mockedMutator.addBoardFromTemplate).toBeCalledWith(team1.id, expect.anything(), expect.anything(), expect.anything(), '1', team1.id))
@@ -319,15 +312,13 @@ describe('components/boardTemplateSelector/boardTemplateSelector', () => {
const divBoardToSelect = screen.getByText(template1Title).parentElement
expect(divBoardToSelect).not.toBeNull()
act(() => {
userEvent.click(divBoardToSelect!)
})
await userEvent.click(divBoardToSelect!)
const useTemplateButton = screen.getByText('Use this template').parentElement
expect(useTemplateButton).not.toBeNull()
act(() => {
userEvent.click(useTemplateButton!)
})
await userEvent.click(useTemplateButton!)
await waitFor(() => expect(mockedMutator.addBoardFromTemplate).toBeCalledTimes(1))
await waitFor(() => expect(mockedMutator.addBoardFromTemplate).toBeCalledWith(team1.id, expect.anything(), expect.anything(), expect.anything(), '1', team1.id))
@@ -347,15 +338,13 @@ describe('components/boardTemplateSelector/boardTemplateSelector', () => {
const divBoardToSelect = screen.getByText(globalTemplateTitle).parentElement
expect(divBoardToSelect).not.toBeNull()
act(() => {
userEvent.click(divBoardToSelect!)
})
await userEvent.click(divBoardToSelect!)
const useTemplateButton = screen.getByText('Use this template').parentElement
expect(useTemplateButton).not.toBeNull()
act(() => {
userEvent.click(useTemplateButton!)
})
await userEvent.click(useTemplateButton!)
await waitFor(() => expect(mockedMutator.addBoardFromTemplate).toBeCalledTimes(1))
await waitFor(() => expect(mockedMutator.addBoardFromTemplate).toBeCalledWith(team1.id, expect.anything(), expect.anything(), expect.anything(), 'global-1', team1.id))
await waitFor(() => expect(mockedTelemetry.trackEvent).toBeCalledWith('boards', 'createBoardViaTemplate', {boardTemplateId: 'template_id_global'}))
@@ -374,16 +363,13 @@ describe('components/boardTemplateSelector/boardTemplateSelector', () => {
const divBoardToSelect = screen.getByText('Welcome to Boards!').parentElement
expect(divBoardToSelect).not.toBeNull()
act(() => {
userEvent.click(divBoardToSelect!)
})
await userEvent.click(divBoardToSelect!)
const useTemplateButton = screen.getByText('Use this template').parentElement
expect(useTemplateButton).not.toBeNull()
act(() => {
userEvent.click(useTemplateButton!)
})
await userEvent.click(useTemplateButton!)
await waitFor(() => expect(mockedMutator.addBoardFromTemplate).toBeCalledTimes(1))
await waitFor(() => expect(mockedMutator.addBoardFromTemplate).toBeCalledWith(team1.id, expect.anything(), expect.anything(), expect.anything(), '2', team1.id))
await waitFor(() => expect(mockedTelemetry.trackEvent).toBeCalledWith('boards', 'createBoardViaTemplate', {boardTemplateId: 'template_id_2'}))

Просмотреть файл

@@ -199,7 +199,7 @@ describe('components/boardTemplateSelector/boardTemplateSelectorItem', () => {
</ReduxProvider>
,
))
userEvent.click(container.querySelector('.BoardTemplateSelectorItem')!)
await userEvent.click(container.querySelector('.BoardTemplateSelectorItem')!)
expect(onSelect).toBeCalledTimes(1)
expect(onSelect).toBeCalledWith(template)
expect(onDelete).not.toBeCalled()
@@ -222,7 +222,7 @@ describe('components/boardTemplateSelector/boardTemplateSelectorItem', () => {
</ReduxProvider>
,
))
userEvent.click(container.querySelector('.BoardTemplateSelectorItem .EditIcon')!)
await userEvent.click(container.querySelector('.BoardTemplateSelectorItem .EditIcon')!)
expect(onEdit).toBeCalledTimes(1)
expect(onEdit).toBeCalledWith(template.id)
expect(onSelect).not.toBeCalled()
@@ -248,16 +248,12 @@ describe('components/boardTemplateSelector/boardTemplateSelectorItem', () => {
</ReduxProvider>
,
), {container: document.body.appendChild(root)})
act(() => {
userEvent.click(root.querySelector('.BoardTemplateSelectorItem .DeleteIcon')!)
})
await act(() => userEvent.click(root.querySelector('.BoardTemplateSelectorItem .DeleteIcon')!))
expect(root).toMatchSnapshot()
const {getByText} = within(root)
act(() => {
userEvent.click(getByText('Delete')!)
})
await act(() => userEvent.click(getByText('Delete')!))
await waitFor(async () => expect(onDelete).toBeCalledTimes(1))
await waitFor(async () => expect(onDelete).toBeCalledWith(template))

Просмотреть файл

@@ -22,8 +22,8 @@ import BoardsUnfurl from './boardsUnfurl'
jest.mock('src/octoClient')
jest.mock('src/utils')
const mockedOctoClient = mocked(octoClient, true)
const mockedUtils = mocked(Utils, true)
const mockedOctoClient = mocked(octoClient)
const mockedUtils = mocked(Utils)
mockedUtils.createGuid = jest.requireActual('src/utils').Utils.createGuid
mockedUtils.blockTypeToIDType = jest.requireActual('src/utils').Utils.blockTypeToIDType
mockedUtils.displayDateTime = jest.requireActual('src/utils').Utils.displayDateTime

Просмотреть файл

@@ -143,7 +143,7 @@ describe('components/calculations/Calculation', () => {
expect(container).toMatchSnapshot()
})
test('should match snapshot - option change', () => {
test('should match snapshot - option change', async () => {
const onMenuOpen = jest.fn()
const onMenuClose = jest.fn()
const onChange = jest.fn()
@@ -171,7 +171,7 @@ describe('components/calculations/Calculation', () => {
)
const countMenuOption = container.querySelector('#react-select-2-option-1')
userEvent.click(countMenuOption as Element)
await userEvent.click(countMenuOption as Element)
expect(container).toMatchSnapshot()
expect(onMenuOpen).not.toBeCalled()
expect(onMenuClose).toBeCalled()

Просмотреть файл

@@ -2,9 +2,8 @@
// See LICENSE.txt for license information.
import React from 'react'
import Select, {components, DropdownIndicatorProps} from 'react-select'
import Select, {components, DropdownIndicatorProps, StylesConfig} from 'react-select'
import {CSSObject} from '@emotion/serialize'
import {useIntl, IntlShape} from 'react-intl'
@@ -114,22 +113,22 @@ function generateTypesByOption(): Map<string, string[]> {
return mapping
}
const baseStyles = getSelectBaseStyle()
const baseStyles = getSelectBaseStyle<Option>()
const styles = {
const styles: StylesConfig<Option> = {
...baseStyles,
dropdownIndicator: (provided: CSSObject): CSSObject => ({
...baseStyles.dropdownIndicator(provided),
dropdownIndicator: (...props) => ({
...baseStyles.dropdownIndicator?.(...props),
pointerEvents: 'none',
}),
control: (): CSSObject => ({
control: () => ({
border: 0,
width: '100%',
margin: '0',
display: 'flex',
flexDirection: 'row',
}),
menu: (provided: CSSObject): CSSObject => ({
menu: (provided) => ({
...provided,
minWidth: '100%',
width: 'max-content',
@@ -137,15 +136,15 @@ const styles = {
left: '0',
marginBottom: '0',
}),
singleValue: (provided: CSSObject): CSSObject => ({
...baseStyles.singleValue(provided),
singleValue: (...props) => ({
...baseStyles.singleValue?.(...props),
opacity: '0.8',
fontSize: '12px',
right: '0',
textTransform: 'uppercase',
}),
valueContainer: (provided: CSSObject): CSSObject => ({
...baseStyles.valueContainer(provided),
valueContainer: (...props) => ({
...baseStyles.valueContainer?.(...props),
display: 'none',
pointerEvents: 'none',
}),
@@ -178,7 +177,7 @@ export const CalculationOptions = (props: BaseCalculationOptionProps): JSX.Eleme
const intl = useIntl()
return (
<Select
<Select<Option>
styles={styles}
value={Options[props.value]}
isMulti={false}

Просмотреть файл

@@ -5,7 +5,6 @@ import {render} from '@testing-library/react'
import {Provider as ReduxProvider} from 'react-redux'
import {TestBlockFactory} from 'src/test/testBlockFactory'
import '@testing-library/jest-dom'
import {wrapIntl, mockStateStore} from 'src/testUtils'
import {IPropertyTemplate} from 'src/blocks/board'

Просмотреть файл

@@ -1,7 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import '@testing-library/jest-dom'
import {act, render} from '@testing-library/react'
import React from 'react'
import {Provider as ReduxProvider} from 'react-redux'

Просмотреть файл

@@ -5,7 +5,6 @@ import React from 'react'
import {Provider as ReduxProvider} from 'react-redux'
import {render, screen} from '@testing-library/react'
import '@testing-library/jest-dom'
import {TestBlockFactory} from 'src/test/testBlockFactory'
import {blocksById, mockStateStore, wrapDNDIntl} from 'src/testUtils'

Просмотреть файл

@@ -171,7 +171,7 @@ exports[`components/cardDetail/CardDetail should render hidden view if limited 1
<p
class="CardDetail__limited-body"
>
Upgrade to our Professional or Enterprise plan to view archived cards, have unlimited views per boards, unlimited cards and more.
Upgrade to our Professional or Enterprise plan.
<br />
<a
class="CardDetail__limited-link"
@@ -480,7 +480,7 @@ exports[`components/cardDetail/CardDetail should show add properties tour tip 1`
<div
class="tutorial-tour-tip__body"
>
Add various properties to cards to make them more powerful!
Add various properties to cards to make them more powerful.
</div>
<div
class="tutorial-tour-tip__image"

Просмотреть файл

@@ -437,7 +437,7 @@ exports[`components/cardDetail/cardDetailContentsMenu return cardDetailContentsM
>
<div
aria-label="menuwrapper"
class="MenuWrapper override menuOpened"
class="MenuWrapper"
role="button"
>
<button
@@ -448,198 +448,6 @@ exports[`components/cardDetail/cardDetailContentsMenu return cardDetailContentsM
Add content
</span>
</button>
<div
class="Menu noselect top "
>
<div
class="menu-contents"
>
<div
class="menu-options"
>
<div>
<div
aria-label="text"
class="MenuOption TextOption menu-option"
role="button"
>
<div
class="d-flex"
>
<div
class="menu-option__icon"
>
<svg
class="TextIcon Icon"
viewBox="0 0 448 512"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M432 416H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-128H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-128H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-128H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16z"
/>
</svg>
</div>
</div>
<div
class="menu-option__content"
>
<div
class="menu-name"
>
text
</div>
</div>
<div
class="noicon"
/>
</div>
</div>
<div>
<div
aria-label="image"
class="MenuOption TextOption menu-option"
role="button"
>
<div
class="d-flex"
>
<div
class="menu-option__icon"
>
<svg
class="ImageIcon Icon"
viewBox="0 0 512 512"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M464 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm-6 336H54a6 6 0 0 1-6-6V118a6 6 0 0 1 6-6h404a6 6 0 0 1 6 6v276a6 6 0 0 1-6 6zM128 152c-22.091 0-40 17.909-40 40s17.909 40 40 40 40-17.909 40-40-17.909-40-40-40zM96 352h320v-80l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L192 304l-39.515-39.515c-4.686-4.686-12.284-4.686-16.971 0L96 304v48z"
/>
</svg>
</div>
</div>
<div
class="menu-option__content"
>
<div
class="menu-name"
>
image
</div>
</div>
<div
class="noicon"
/>
</div>
</div>
<div>
<div
aria-label="divider"
class="MenuOption TextOption menu-option"
role="button"
>
<div
class="d-flex"
>
<div
class="menu-option__icon"
>
<svg
class="DividerIcon Icon"
viewBox="0 0 448 512"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M 432,224 H 16 c -8.836556,0 -16,7.16344 -16,16 v 32 c 0,8.83656 7.163444,16 16,16 h 416 c 8.83656,0 16,-7.16344 16,-16 v -32 c 0,-8.83656 -7.16344,-16 -16,-16 z"
/>
</svg>
</div>
</div>
<div
class="menu-option__content"
>
<div
class="menu-name"
>
divider
</div>
</div>
<div
class="noicon"
/>
</div>
</div>
<div>
<div
aria-label="checkbox"
class="MenuOption TextOption menu-option"
role="button"
>
<div
class="d-flex"
>
<div
class="menu-option__icon"
>
<svg
class="CheckIcon Icon"
viewBox="0 0 100 100"
xmlns="http://www.w3.org/2000/svg"
>
<polyline
points="20,60 40,80 80,40"
/>
</svg>
</div>
</div>
<div
class="menu-option__content"
>
<div
class="menu-name"
>
checkbox
</div>
</div>
<div
class="noicon"
/>
</div>
</div>
</div>
<div
class="menu-spacer hideOnWidescreen"
/>
<div
class="menu-options hideOnWidescreen"
>
<div
aria-label="Cancel"
class="MenuOption TextOption menu-option menu-cancel"
role="button"
>
<div
class="d-flex"
>
<div
class="noicon"
/>
</div>
<div
class="menu-option__content"
>
<div
class="menu-name"
>
Cancel
</div>
</div>
<div
class="noicon"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Просмотреть файл

@@ -10,7 +10,7 @@ exports[`components/cardDetail/CommentsList comments show up 1`] = `
>
<img
class="comment-avatar"
src="data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 100 100\\" style=\\"fill: rgb(192, 192, 192);\\"><rect width=\\"100\\" height=\\"100\\" /></svg>"
src="data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" style="fill: rgb(192, 192, 192);"><rect width="100" height="100" /></svg>"
/>
<div
class="MarkdownEditor octo-editor newcomment "
@@ -34,7 +34,7 @@ exports[`components/cardDetail/CommentsList comments show up 1`] = `
>
<img
class="comment-avatar"
src="data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 100 100\\" style=\\"fill: rgb(192, 192, 192);\\"><rect width=\\"100\\" height=\\"100\\" /></svg>"
src="data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" style="fill: rgb(192, 192, 192);"><rect width="100" height="100" /></svg>"
/>
<div
class="comment-username"
@@ -80,7 +80,7 @@ exports[`components/cardDetail/CommentsList comments show up 1`] = `
>
<img
class="comment-avatar"
src="data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 100 100\\" style=\\"fill: rgb(192, 192, 192);\\"><rect width=\\"100\\" height=\\"100\\" /></svg>"
src="data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" style="fill: rgb(192, 192, 192);"><rect width="100" height="100" /></svg>"
/>
<div
class="comment-username"
@@ -138,7 +138,7 @@ exports[`components/cardDetail/CommentsList comments show up in readonly mode 1`
>
<img
class="comment-avatar"
src="data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 100 100\\" style=\\"fill: rgb(192, 192, 192);\\"><rect width=\\"100\\" height=\\"100\\" /></svg>"
src="data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" style="fill: rgb(192, 192, 192);"><rect width="100" height="100" /></svg>"
/>
<div
class="comment-username"
@@ -170,7 +170,7 @@ exports[`components/cardDetail/CommentsList comments show up in readonly mode 1`
>
<img
class="comment-avatar"
src="data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 100 100\\" style=\\"fill: rgb(192, 192, 192);\\"><rect width=\\"100\\" height=\\"100\\" /></svg>"
src="data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" style="fill: rgb(192, 192, 192);"><rect width="100" height="100" /></svg>"
/>
<div
class="comment-username"

Просмотреть файл

@@ -26,7 +26,7 @@ import CardDetail from './cardDetail'
global.fetch = FetchMock.fn
jest.mock('src/octoClient')
const mockedOctoClient = mocked(octoClient, true)
const mockedOctoClient = mocked(octoClient)
beforeEach(() => {
FetchMock.fn.mockReset()
@@ -299,7 +299,7 @@ describe('components/cardDetail/CardDetail', () => {
expect(nextBtn).toBeDefined()
expect(nextBtn).not.toBeNull()
await act(async () => {
userEvent.click(nextBtn!)
await userEvent.click(nextBtn!)
})
expect(mockedOctoClient.patchUserConfig).toBeCalledWith(
'user_id_1',
@@ -408,7 +408,7 @@ describe('components/cardDetail/CardDetail', () => {
expect(nextBtn).toBeDefined()
expect(nextBtn).not.toBeNull()
await act(async () => {
userEvent.click(nextBtn!)
await userEvent.click(nextBtn!)
})
expect(mockedOctoClient.patchUserConfig).toBeCalledWith(
'user_id_1',
@@ -521,7 +521,7 @@ describe('components/cardDetail/CardDetail', () => {
expect(nextBtn).toBeDefined()
expect(nextBtn).not.toBeNull()
await act(async () => {
userEvent.click(nextBtn!)
await userEvent.click(nextBtn!)
})
expect(mockedOctoClient.patchUserConfig).toBeCalledWith(
'user_id_1',

Просмотреть файл

@@ -1,11 +1,12 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {act, render, screen} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import {render, screen} from '@testing-library/react'
import React, {ReactElement, ReactNode} from 'react'
import {Provider as ReduxProvider} from 'react-redux'
import {wrapIntl, mockStateStore} from 'src/testUtils'
import userEvent from '@testing-library/user-event'
import {wrapIntl, mockStateStore, setup} from 'src/testUtils'
import {TestBlockFactory} from 'src/test/testBlockFactory'
@@ -36,22 +37,18 @@ describe('components/cardDetail/cardDetailContentsMenu', () => {
beforeEach(() => {
jest.clearAllMocks()
})
test('return cardDetailContentsMenu', () => {
test('return cardDetailContentsMenu', async () => {
const {container} = render(wrap(<CardDetailContentsMenu/>))
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
expect(container).toMatchSnapshot()
})
test('return cardDetailContentsMenu and add Text content', async () => {
const {container} = render(wrap(<CardDetailContentsMenu/>))
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
const {user, container} = setup(wrap(<CardDetailContentsMenu/>))
await user.click(screen.getByRole('button', {name: 'menuwrapper'}))
expect(container).toMatchSnapshot()
await act(async () => {
const buttonAddText = screen.getByRole('button', {name: 'text'})
userEvent.click(buttonAddText)
})
await user.click(screen.getByRole('button', {name: 'text'}))
expect(container).toMatchSnapshot()
})
})

Просмотреть файл

@@ -10,7 +10,6 @@ import {
} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import {mocked} from 'jest-mock'
import '@testing-library/jest-dom'
import {createIntl} from 'react-intl'
import configureStore from 'redux-mock-store'
@@ -25,7 +24,7 @@ import {PropertyType} from 'src/properties/types'
import CardDetailProperties from './cardDetailProperties'
jest.mock('src/mutator')
const mockedMutator = mocked(mutator, true)
const mockedMutator = mocked(mutator)
describe('components/cardDetail/CardDetailProperties', () => {
const board = TestBlockFactory.createBoard()
@@ -140,25 +139,25 @@ describe('components/cardDetail/CardDetailProperties', () => {
expect(container).toMatchSnapshot()
})
it('should show confirmation dialog when deleting existing select property', () => {
it('should show confirmation dialog when deleting existing select property', async () => {
renderComponent()
const menuElement = screen.getByRole('button', {name: 'Owner'})
userEvent.click(menuElement)
await act(() => userEvent.click(menuElement))
const deleteButton = screen.getByRole('button', {name: /delete/i})
userEvent.click(deleteButton)
await act(() => userEvent.click(deleteButton))
expect(screen.getByRole('heading', {name: 'Confirm delete property'})).toBeInTheDocument()
expect(screen.getByRole('button', {name: /delete/i})).toBeInTheDocument()
})
it('should show property types menu', () => {
it('should show property types menu', async () => {
const intl = createIntl({locale: 'en'})
const {container} = renderComponent()
const menuElement = screen.getByRole('button', {name: /add a property/i})
userEvent.click(menuElement)
await act(() => userEvent.click(menuElement))
expect(container).toMatchSnapshot()
const selectProperty = screen.getByText(/select property type/i)
@@ -170,11 +169,11 @@ describe('components/cardDetail/CardDetailProperties', () => {
})
})
it('should allow change property types menu, confirm', () => {
it('should allow change property types menu, confirm', async () => {
renderComponent()
const menuElement = screen.getByRole('button', {name: 'Owner'})
userEvent.click(menuElement)
await act(() => userEvent.click(menuElement))
const typeProperty = screen.getByText(/Type: Select/i)
expect(typeProperty).toBeInTheDocument()
@@ -182,7 +181,7 @@ describe('components/cardDetail/CardDetailProperties', () => {
fireEvent.mouseOver(typeProperty)
const newTypeMenu = screen.getByRole('button', {name: 'Text'})
userEvent.click(newTypeMenu)
await act(() => userEvent.click(newTypeMenu))
expect(screen.getByRole('heading', {name: 'Confirm property type change'})).toBeInTheDocument()
expect(screen.getByRole('button', {name: /Change property/i})).toBeInTheDocument()
@@ -192,7 +191,7 @@ describe('components/cardDetail/CardDetailProperties', () => {
const result = renderComponent()
// rename to "Owner-Renamed"
onPropertyRenameNoConfirmationDialog(result.container)
await onPropertyRenameNoConfirmationDialog(result.container)
const propertyTemplate = board.cardProperties[0]
// should be called once on confirming renaming the property
@@ -204,12 +203,10 @@ describe('components/cardDetail/CardDetailProperties', () => {
renderComponent()
const menuElement = screen.getByRole('button', {name: /add a property/i})
userEvent.click(menuElement)
await act(() => userEvent.click(menuElement))
const numberType = screen.getByRole('button', {name: /number/i})
await act(async () => {
const numberType = screen.getByRole('button', {name: /number/i})
userEvent.click(numberType)
})
await act( () => userEvent.click(numberType))
expect(mockedMutator.insertPropertyTemplate).toHaveBeenCalledTimes(1)
@@ -220,11 +217,11 @@ describe('components/cardDetail/CardDetailProperties', () => {
expect(template!.type).toBe('number')
})
it('confirmation on delete dialog should delete the property', () => {
it('confirmation on delete dialog should delete the property', async () => {
const result = renderComponent()
const container = result.container
openDeleteConfirmationDialog(container)
await openDeleteConfirmationDialog(container)
const propertyTemplate = board.cardProperties[0]
@@ -232,48 +229,49 @@ describe('components/cardDetail/CardDetailProperties', () => {
expect(confirmButton).toBeDefined()
//click delete button
userEvent.click(confirmButton!)
await act(() => userEvent.click(confirmButton!))
// should be called once on confirming delete
expect(mockedMutator.deleteProperty).toBeCalledTimes(1)
expect(mockedMutator.deleteProperty).toBeCalledWith(board, views, cards, propertyTemplate.id)
})
it('cancel on delete dialog should do nothing', () => {
it('cancel on delete dialog should do nothing', async () => {
const result = renderComponent()
const container = result.container
openDeleteConfirmationDialog(container)
await openDeleteConfirmationDialog(container)
const cancelButton = result.getByTitle('Cancel')
expect(cancelButton).toBeDefined()
userEvent.click(cancelButton!)
await act(() => userEvent.click(cancelButton!))
expect(container).toMatchSnapshot()
})
function openDeleteConfirmationDialog(container: HTMLElement) {
async function openDeleteConfirmationDialog(container: HTMLElement) {
const propertyLabel = container.querySelector('.MenuWrapper')
expect(propertyLabel).toBeDefined()
userEvent.click(propertyLabel!)
await act(() => userEvent.click(propertyLabel!))
const deleteOption = container.querySelector('.MenuOption.TextOption')
expect(propertyLabel).toBeDefined()
userEvent.click(deleteOption!)
await act(() => userEvent.click(deleteOption!))
const confirmDialog = container.querySelector('.dialog.confirmation-dialog-box')
expect(confirmDialog).toBeDefined()
}
function onPropertyRenameNoConfirmationDialog(container: HTMLElement) {
async function onPropertyRenameNoConfirmationDialog(container: HTMLElement) {
const propertyLabel = container.querySelector('.MenuWrapper')
expect(propertyLabel).toBeDefined()
userEvent.click(propertyLabel!)
await act(() => userEvent.click(propertyLabel!))
// write new name in the name text box
const propertyNameInput = container.querySelector('.PropertyMenu.menu-textbox')
expect(propertyNameInput).toBeDefined()
userEvent.type(propertyNameInput!, 'Owner - Renamed{enter}')
userEvent.click(propertyLabel!)
await act(() => userEvent.type(propertyNameInput!, 'Owner - Renamed{enter}', {initialSelectionStart: 0, initialSelectionEnd: 5}))
await act(() => userEvent.click(propertyLabel!))
}
})

Просмотреть файл

@@ -17,7 +17,7 @@ import mutator from 'src/mutator'
import Comment from './comment'
jest.mock('src/mutator')
const mockedMutator = mocked(mutator, true)
const mockedMutator = mocked(mutator)
const board = TestBlockFactory.createBoard()
const card = TestBlockFactory.createCard(board)
@@ -50,7 +50,7 @@ describe('components/cardDetail/comment', () => {
}
})
test('return comment', () => {
test('return comment', async () => {
const {container} = render(wrapIntl(
<ReduxProvider store={store}>
<Comment
@@ -62,7 +62,7 @@ describe('components/cardDetail/comment', () => {
</ReduxProvider>,
))
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
expect(container).toMatchSnapshot()
})
@@ -80,7 +80,7 @@ describe('components/cardDetail/comment', () => {
expect(container).toMatchSnapshot()
})
test('return comment and delete comment', () => {
test('return comment and delete comment', async () => {
const {container} = render(wrapIntl(
<ReduxProvider store={store}>
<Comment
@@ -92,15 +92,15 @@ describe('components/cardDetail/comment', () => {
</ReduxProvider>,
))
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
expect(container).toMatchSnapshot()
const buttonDelete = screen.getByRole('button', {name: 'Delete'})
userEvent.click(buttonDelete)
await userEvent.click(buttonDelete)
expect(mockedMutator.deleteBlock).toBeCalledTimes(1)
expect(mockedMutator.deleteBlock).toBeCalledWith(comment)
})
test('return guest comment', () => {
test('return guest comment', async () => {
const localStore = mockStateStore([], {users: {boardUsers: {[comment.modifiedBy]: {username: 'username_1', is_guest: true}}}})
const {container} = render(wrapIntl(
<ReduxProvider store={localStore}>
@@ -113,11 +113,11 @@ describe('components/cardDetail/comment', () => {
</ReduxProvider>,
))
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
expect(container).toMatchSnapshot()
})
test('return guest comment readonly', () => {
test('return guest comment readonly', async () => {
const localStore = mockStateStore([], {users: {boardUsers: {[comment.modifiedBy]: {username: 'username_1', is_guest: true}}}})
const {container} = render(wrapIntl(
<ReduxProvider store={localStore}>
@@ -132,7 +132,7 @@ describe('components/cardDetail/comment', () => {
expect(container).toMatchSnapshot()
})
test('return guest comment and delete comment', () => {
test('return guest comment and delete comment', async () => {
const localStore = mockStateStore([], {users: {boardUsers: {[comment.modifiedBy]: {username: 'username_1', is_guest: true}}}})
const {container} = render(wrapIntl(
<ReduxProvider store={localStore}>
@@ -145,10 +145,10 @@ describe('components/cardDetail/comment', () => {
</ReduxProvider>,
))
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
expect(container).toMatchSnapshot()
const buttonDelete = screen.getByRole('button', {name: 'Delete'})
userEvent.click(buttonDelete)
await userEvent.click(buttonDelete)
expect(mockedMutator.deleteBlock).toBeCalledTimes(1)
expect(mockedMutator.deleteBlock).toBeCalledWith(comment)
})

Просмотреть файл

@@ -1,8 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import '@testing-library/jest-dom'
import {act, render, screen} from '@testing-library/react'
import {render, screen} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import React from 'react'
@@ -23,9 +22,9 @@ jest.mock('src/octoClient')
jest.mock('src/utils')
jest.mock('draft-js/lib/generateRandomKey', () => () => '123')
const mockedUtils = mocked(Utils, true)
const mockedMutator = mocked(mutator, true)
const mockedOctoClient = mocked(octoClient, true)
const mockedUtils = mocked(Utils)
const mockedMutator = mocked(mutator)
const mockedOctoClient = mocked(octoClient)
mockedUtils.createGuid.mockReturnValue('test-id')
beforeAll(() => {
@@ -94,135 +93,116 @@ describe('components/cardDialog', () => {
jest.clearAllMocks()
})
test('should match snapshot', async () => {
let container
await act(async () => {
const result = render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
container = result.container
})
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
expect(container).toMatchSnapshot()
})
test('should match snapshot without permissions', async () => {
let container
const localStore = mockStateStore([], {...state, teams: {current: undefined}})
await act(async () => {
const result = render(wrapDNDIntl(
<ReduxProvider store={localStore}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
container = result.container
})
const {container} = render(wrapDNDIntl(
<ReduxProvider store={localStore}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
expect(container).toMatchSnapshot()
})
test('return a cardDialog readonly', async () => {
let container
await act(async () => {
const result = render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={true}
/>
</ReduxProvider>,
))
container = result.container
})
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={true}
/>
</ReduxProvider>,
))
expect(container).toMatchSnapshot()
})
test('return cardDialog and do a close action', async () => {
const closeFn = jest.fn()
await act(async () => {
render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={closeFn}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
})
render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={closeFn}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
const buttonElement = screen.getByRole('button', {name: 'Close dialog'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
expect(closeFn).toBeCalledTimes(1)
})
test('return cardDialog menu content', async () => {
let container
await act(async () => {
const result = render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
container = result.container
})
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
const buttonMenu = screen.getAllByRole('button', {name: 'menuwrapper'})[0]
userEvent.click(buttonMenu)
await userEvent.click(buttonMenu)
expect(container).toMatchSnapshot()
})
test('return cardDialog menu content and verify delete action', async () => {
await act(async () => {
render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
})
render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
const buttonMenu = screen.getAllByRole('button', {name: 'menuwrapper'})[0]
userEvent.click(buttonMenu)
await userEvent.click(buttonMenu)
const buttonDelete = screen.getByRole('button', {name: 'Delete'})
userEvent.click(buttonDelete)
await userEvent.click(buttonDelete)
const confirmDialog = screen.getByTitle('Confirmation Dialog Box')
expect(confirmDialog).toBeDefined()
@@ -231,36 +211,32 @@ describe('components/cardDialog', () => {
expect(confirmButton).toBeDefined()
//click delete button
userEvent.click(confirmButton!)
await userEvent.click(confirmButton!)
// should be called once on confirming delete
expect(mockedMutator.deleteBlock).toBeCalledTimes(1)
})
test('return cardDialog menu content and cancel delete confirmation do nothing', async () => {
let container
await act(async () => {
const result = render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
container = result.container
})
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
const buttonMenu = screen.getAllByRole('button', {name: 'menuwrapper'})[0]
userEvent.click(buttonMenu)
await userEvent.click(buttonMenu)
const buttonDelete = screen.getByRole('button', {name: 'Delete'})
userEvent.click(buttonDelete)
await userEvent.click(buttonDelete)
const confirmDialog = screen.getByTitle('Confirmation Dialog Box')
expect(confirmDialog).toBeDefined()
@@ -269,57 +245,53 @@ describe('components/cardDialog', () => {
expect(cancelButton).toBeDefined()
//click delete button
userEvent.click(cancelButton!)
await userEvent.click(cancelButton!)
// should do nothing on cancel delete dialog
expect(container).toMatchSnapshot()
})
test('return cardDialog menu content and do a New template from card', async () => {
await act(async () => {
render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
})
render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
const buttonMenu = screen.getAllByRole('button', {name: 'menuwrapper'})[0]
userEvent.click(buttonMenu)
await userEvent.click(buttonMenu)
const buttonTemplate = screen.getByRole('button', {name: 'New template from card'})
userEvent.click(buttonTemplate)
await userEvent.click(buttonTemplate)
expect(mockedMutator.duplicateCard).toBeCalledTimes(1)
})
test('return cardDialog menu content and do a copy Link', async () => {
await act(async () => {
render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
})
render(wrapDNDIntl(
<ReduxProvider store={store}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
const buttonMenu = screen.getAllByRole('button', {name: 'menuwrapper'})[0]
userEvent.click(buttonMenu)
await userEvent.click(buttonMenu)
const buttonCopy = screen.getByRole('button', {name: 'Copy link'})
userEvent.click(buttonCopy)
await userEvent.click(buttonCopy)
expect(mockedUtils.copyTextToClipboard).toBeCalledTimes(1)
})
@@ -338,24 +310,21 @@ describe('components/cardDialog', () => {
const newStore = mockStateStore([], newState)
let container
await act(async () => {
const result = render(wrapDNDIntl(
<ReduxProvider store={newStore}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
container = result.container
})
const {container} = render(wrapDNDIntl(
<ReduxProvider store={newStore}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[card]}
cardId={card.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
expect(container).toMatchSnapshot()
})
@@ -373,24 +342,21 @@ describe('components/cardDialog', () => {
const newStore = mockStateStore([], newState)
let container
await act(async () => {
const result = render(wrapDNDIntl(
<ReduxProvider store={newStore}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[limitedCard]}
cardId={limitedCard.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
container = result.container
})
const {container} = render(wrapDNDIntl(
<ReduxProvider store={newStore}>
<CardDialog
board={board}
activeView={boardView}
views={[boardView]}
cards={[limitedCard]}
cardId={limitedCard.id}
onClose={jest.fn()}
showCard={jest.fn()}
readonly={false}
/>
</ReduxProvider>,
))
expect(container).toMatchSnapshot()
})
})

Просмотреть файл

@@ -1,11 +1,11 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {
act,
fireEvent,
render,
screen,
within,
act
within
} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import React from 'react'
@@ -38,9 +38,9 @@ jest.mock('src/octoClient')
jest.mock('src/mutator')
jest.mock('src/telemetry/telemetryClient')
jest.mock('draft-js/lib/generateRandomKey', () => () => '123')
const mockedUtils = mocked(Utils, true)
const mockedMutator = mocked(Mutator, true)
const mockedOctoClient = mocked(octoClient, true)
const mockedUtils = mocked(Utils)
const mockedMutator = mocked(Mutator)
const mockedOctoClient = mocked(octoClient)
mockedUtils.createGuid.mockReturnValue('test-id')
mockedUtils.generateClassName = jest.requireActual('src/utils').Utils.generateClassName
describe('components/centerPanel', () => {
@@ -234,7 +234,7 @@ describe('components/centerPanel', () => {
expect(container).toMatchSnapshot()
})
describe('return centerPanel and', () => {
test('select one card and click background', () => {
test('select one card and click background', async () => {
activeView.fields.viewType = 'table'
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
@@ -255,13 +255,13 @@ describe('components/centerPanel', () => {
//select card
const cardElement = screen.getByRole('textbox', {name: 'card1'})
expect(cardElement).not.toBeNull()
userEvent.click(cardElement, {shiftKey: true})
fireEvent.click(cardElement, {shiftKey: true})
expect(container).toMatchSnapshot()
//background
const boardElement = container.querySelector('.BoardComponent')
expect(boardElement).not.toBeNull()
userEvent.click(boardElement!)
fireEvent.click(boardElement!)
expect(container).toMatchSnapshot()
})
@@ -288,7 +288,7 @@ describe('components/centerPanel', () => {
expect(container).toMatchSnapshot()
})
test('press touch esc for one card selected', () => {
test('press touch esc for one card selected', async () => {
activeView.fields.viewType = 'table'
const {container, baseElement} = render(wrapDNDIntl(
<ReduxProvider store={store}>
@@ -306,11 +306,9 @@ describe('components/centerPanel', () => {
</ReduxProvider>,
))
act(() => {
const cardElement = screen.getByRole('textbox', {name: 'card1'})
expect(cardElement.parentNode).not.toBeNull()
userEvent.click(cardElement as HTMLElement, {shiftKey: true})
})
const cardElement = screen.getByRole('textbox', {name: 'card1'})
expect(cardElement.parentNode).not.toBeNull()
fireEvent.click(cardElement, {shiftKey: true})
expect(container).toMatchSnapshot()
//escape
@@ -335,27 +333,23 @@ describe('components/centerPanel', () => {
</ReduxProvider>,
))
act(() => {
//select card1
const card1Element = screen.getByRole('textbox', {name: 'card1'})
expect(card1Element).not.toBeNull()
userEvent.click(card1Element, {shiftKey: true})
})
//select card1
const card1Element = screen.getByRole('textbox', {name: 'card1'})
expect(card1Element).not.toBeNull()
fireEvent.click(card1Element, {shiftKey: true})
expect(container).toMatchSnapshot()
act(() => {
//select card2
const card2Element = screen.getByRole('textbox', {name: 'card2'})
expect(card2Element).not.toBeNull()
userEvent.click(card2Element, {shiftKey: true, ctrlKey: true})
})
//select card2
const card2Element = screen.getByRole('textbox', {name: 'card2'})
expect(card2Element).not.toBeNull()
fireEvent.click(card2Element, {shiftKey: true, ctrlKey: true})
expect(container).toMatchSnapshot()
//escape
fireEvent.keyDown(baseElement, {keyCode: 27})
expect(container).toMatchSnapshot()
})
test('press touch del for one card selected', () => {
test('press touch del for one card selected', async () => {
activeView.fields.viewType = 'table'
const {container, baseElement} = render(wrapDNDIntl(
<ReduxProvider store={store}>
@@ -372,19 +366,18 @@ describe('components/centerPanel', () => {
/>
</ReduxProvider>,
))
act(() => {
const cardElement = screen.getByRole('textbox', {name: 'card1'})
expect(cardElement).not.toBeNull()
userEvent.click(cardElement, {shiftKey: true})
})
const cardElement = screen.getByRole('textbox', {name: 'card1'})
expect(cardElement).not.toBeNull()
fireEvent.click(cardElement, {shiftKey: true})
expect(container).toMatchSnapshot()
//delete
fireEvent.keyDown(baseElement, {keyCode: 8})
expect(mockedMutator.performAsUndoGroup).toBeCalledTimes(1)
})
test('press touch ctrl+d for one card selected', () => {
test('press touch ctrl+d for one card selected', async () => {
activeView.fields.viewType = 'table'
const {container, baseElement} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<CenterPanel
@@ -400,18 +393,16 @@ describe('components/centerPanel', () => {
/>
</ReduxProvider>,
))
act(() => {
const cardElement = screen.getByRole('textbox', {name: 'card1'})
expect(cardElement).not.toBeNull()
userEvent.click(cardElement, {shiftKey: true})
})
const cardElement = screen.getByRole('textbox', {name: 'card1'})
expect(cardElement).not.toBeNull()
fireEvent.click(cardElement, {shiftKey: true})
expect(container).toMatchSnapshot()
//ctrl+d
fireEvent.keyDown(baseElement, {ctrlKey: true, keyCode: 68})
expect(mockedMutator.performAsUndoGroup).toBeCalledTimes(1)
})
test('click on card to show card', () => {
test('click on card to show card', async () => {
activeView.fields.viewType = 'board'
const mockedShowCard = jest.fn()
const {container} = render(wrapDNDIntl(
@@ -433,11 +424,11 @@ describe('components/centerPanel', () => {
const kanbanCardElements = container.querySelectorAll('.KanbanCard')
expect(kanbanCardElements).not.toBeNull()
const kanbanCardElement = kanbanCardElements[0]
userEvent.click(kanbanCardElement)
await userEvent.click(kanbanCardElement)
expect(container).toMatchSnapshot()
expect(mockedShowCard).toBeCalledWith(card1.id)
})
test('click on new card to add card', () => {
test('click on new card to add card', async () => {
activeView.fields.viewType = 'table'
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
@@ -456,10 +447,10 @@ describe('components/centerPanel', () => {
))
const buttonWithMenuElement = container.querySelector('.ButtonWithMenu')
expect(buttonWithMenuElement).not.toBeNull()
userEvent.click(buttonWithMenuElement!)
await act(() => userEvent.click(buttonWithMenuElement!))
expect(mockedMutator.performAsUndoGroup).toBeCalledTimes(1)
})
test('click on new card to add card template', () => {
test('click on new card to add card template', async () => {
activeView.fields.viewType = 'table'
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
@@ -478,13 +469,13 @@ describe('components/centerPanel', () => {
))
const elementMenuWrapper = container.querySelector('.ButtonWithMenu > div.MenuWrapper')
expect(elementMenuWrapper).not.toBeNull()
userEvent.click(elementMenuWrapper!)
await act(() => userEvent.click(elementMenuWrapper!))
const buttonNewTemplate = within(elementMenuWrapper!.parentElement!).getByRole('button', {name: 'New template'})
userEvent.click(buttonNewTemplate)
await act(() => userEvent.click(buttonNewTemplate))
expect(mockedMutator.insertBlock).toBeCalledTimes(1)
})
test('click on new card to add card from template', () => {
test('click on new card to add card from template', async () => {
activeView.fields.viewType = 'table'
activeView.fields.defaultTemplateId = '1'
const {container} = render(wrapDNDIntl(
@@ -504,14 +495,14 @@ describe('components/centerPanel', () => {
))
const elementMenuWrapper = container.querySelector('.ButtonWithMenu > div.MenuWrapper')
expect(elementMenuWrapper).not.toBeNull()
userEvent.click(elementMenuWrapper!)
await act(() => userEvent.click(elementMenuWrapper!))
const elementCard1 = within(elementMenuWrapper!.parentElement!).getByRole('button', {name: 'card1'})
expect(elementCard1).not.toBeNull()
userEvent.click(elementCard1)
await act(() => userEvent.click(elementCard1))
expect(mockedMutator.performAsUndoGroup).toBeCalledTimes(1)
})
test('click on new card to edit template', () => {
test('click on new card to edit template', async () => {
activeView.fields.viewType = 'table'
activeView.fields.defaultTemplateId = '1'
const {container} = render(wrapDNDIntl(
@@ -531,15 +522,15 @@ describe('components/centerPanel', () => {
))
const elementMenuWrapper = container.querySelector('.ButtonWithMenu > div.MenuWrapper')
expect(elementMenuWrapper).not.toBeNull()
userEvent.click(elementMenuWrapper!)
await act(() => userEvent.click(elementMenuWrapper!))
const elementCard1 = within(elementMenuWrapper!.parentElement!).getByRole('button', {name: 'card1'})
expect(elementCard1).not.toBeNull()
const elementMenuWrapperCard1 = within(elementCard1).getByRole('button', {name: 'menuwrapper'})
expect(elementMenuWrapperCard1).not.toBeNull()
userEvent.click(elementMenuWrapperCard1)
await act(() => userEvent.click(elementMenuWrapperCard1))
const elementEditMenuTemplate = within(elementMenuWrapperCard1).getByRole('button', {name: 'Edit'})
expect(elementMenuWrapperCard1).not.toBeNull()
userEvent.click(elementEditMenuTemplate)
await act(() => userEvent.click(elementEditMenuTemplate))
expect(container).toMatchSnapshot()
})
})

Просмотреть файл

@@ -1,6 +1,5 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import '@testing-library/jest-dom'
import {render} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import React from 'react'
@@ -28,7 +27,7 @@ describe('/components/confirmAddUserForNotifications', () => {
expect(result.container).toMatchSnapshot()
})
it('confirm button click, run onConfirm Function once', () => {
it('confirm button click, run onConfirm Function once', async () => {
const onConfirm = jest.fn()
const result = render(
@@ -42,11 +41,11 @@ describe('/components/confirmAddUserForNotifications', () => {
/>,
),
)
userEvent.click(result.getByTitle('Add to board'))
await userEvent.click(result.getByTitle('Add to board'))
expect(onConfirm).toBeCalledTimes(1)
})
it('cancel button click runs onClose function', () => {
it('cancel button click runs onClose function', async () => {
const onClose = jest.fn()
const result = render(
@@ -60,7 +59,7 @@ describe('/components/confirmAddUserForNotifications', () => {
/>,
),
)
userEvent.click(result.getByTitle('Cancel'))
await userEvent.click(result.getByTitle('Cancel'))
expect(onClose).toBeCalledTimes(1)
})
})

Просмотреть файл

@@ -1,6 +1,5 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import '@testing-library/jest-dom'
import {act, render} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import React from 'react'
@@ -55,16 +54,16 @@ describe('/components/confirmationDialogBox', () => {
expect(containerWithCnfrmBtnText).toMatchSnapshot()
})
it('confirm button click, run onConfirm Function once', () => {
it('confirm button click, run onConfirm Function once', async () => {
const result = render(
wrapDNDIntl(<ConfirmationDialogBox dialogBox={dialogProps}/>),
)
userEvent.click(result.getByTitle('Confirm'))
await userEvent.click(result.getByTitle('Confirm'))
expect(dialogProps.onConfirm).toBeCalledTimes(1)
})
it('confirm button (with passed prop text), run onConfirm Function once', () => {
it('confirm button (with passed prop text), run onConfirm Function once', async () => {
const resultWithConfirmBtnText = render(
wrapDNDIntl(
<ConfirmationDialogBox
@@ -73,21 +72,21 @@ describe('/components/confirmationDialogBox', () => {
),
)
userEvent.click(
await userEvent.click(
resultWithConfirmBtnText.getByTitle(dialogPropsWithCnfrmBtnText.confirmButtonText),
)
expect(dialogPropsWithCnfrmBtnText.onConfirm).toBeCalledTimes(1)
})
it('cancel button click runs onClose function', () => {
it('cancel button click runs onClose function', async () => {
const result = render(wrapDNDIntl(
<ConfirmationDialogBox
dialogBox={dialogProps}
/>,
))
userEvent.click(result.getByTitle('Cancel'))
await userEvent.click(result.getByTitle('Cancel'))
expect(dialogProps.onClose).toBeCalledTimes(1)
})
})

Просмотреть файл

@@ -15,7 +15,6 @@ exports[`components/content/checkboxElement should change title 1`] = `
placeholder="Edit text..."
spellcheck="true"
title="new title"
type="text"
value="new title"
/>
</div>

Просмотреть файл

@@ -16,7 +16,7 @@ import {IUser} from 'src/user'
import AttachmentElement from './attachmentElement'
jest.mock('src/octoClient')
const mockedOcto = mocked(octoClient, true)
const mockedOcto = mocked(octoClient)
mockedOcto.getFileAsDataUrl.mockResolvedValue({url: 'test.txt'})
mockedOcto.getFileInfo.mockResolvedValue({
name: 'test.txt',

Просмотреть файл

@@ -8,7 +8,6 @@ import {
screen,
waitFor
} from '@testing-library/react'
import '@testing-library/jest-dom'
import {mocked} from 'jest-mock'
import userEvent from '@testing-library/user-event'
@@ -21,7 +20,7 @@ import mutator from 'src/mutator'
import CheckboxElement from './checkboxElement'
jest.mock('src/mutator')
const mockedMutator = mocked(mutator, true)
const mockedMutator = mocked(mutator)
const board = TestBlockFactory.createBoard()
const card = TestBlockFactory.createCard(board)
@@ -84,7 +83,7 @@ describe('components/content/checkboxElement', () => {
expect(container).toMatchSnapshot()
})
it('should change title', () => {
it('should change title', async () => {
const {container} = render(wrap(
<CheckboxElement
block={checkboxBlock}
@@ -93,8 +92,8 @@ describe('components/content/checkboxElement', () => {
))
const newTitle = 'new title'
const input = screen.getByRole('textbox', {name: /test-title/i})
userEvent.clear(input)
userEvent.type(input, newTitle)
await userEvent.clear(input)
await userEvent.type(input, newTitle)
fireEvent.blur(input)
expect(container).toMatchSnapshot()
expect(mockedMutator.changeBlockTitle).toHaveBeenCalledTimes(1)
@@ -106,7 +105,7 @@ describe('components/content/checkboxElement', () => {
expect.anything())
})
it('should toggle value', () => {
it('should toggle value', async () => {
const {container} = render(wrap(
<CheckboxElement
block={checkboxBlock}
@@ -114,7 +113,7 @@ describe('components/content/checkboxElement', () => {
/>,
))
const input = screen.getByRole('checkbox')
userEvent.click(input)
await userEvent.click(input)
expect(container).toMatchSnapshot()
expect(mockedMutator.updateBlock).toHaveBeenCalledTimes(1)
expect(mockedMutator.updateBlock).toHaveBeenCalledWith(
@@ -149,17 +148,17 @@ describe('components/content/checkboxElement', () => {
const input = screen.getByRole('textbox', {name: /test-title/i})
// should not add new checkbox when current one has empty title
userEvent.clear(input)
userEvent.type(input, '{enter}')
await userEvent.clear(input)
await userEvent.type(input, '{Enter}')
expect(addElement).toHaveBeenCalledTimes(0)
// should add new checkbox when current one has non-empty title
userEvent.clear(input)
userEvent.type(input, 'new-title{enter}')
await userEvent.clear(input)
await userEvent.type(input, 'new-title{Enter}')
await waitFor(() => expect(addElement).toHaveBeenCalledTimes(1))
})
it('should delete automatically added checkbox with empty title on esc/enter pressed', () => {
it('should delete automatically added checkbox with empty title on esc/enter pressed', async () => {
const addedBlock = createContentBlock(checkboxBlock)
addedBlock.title = ''
const deleteElement = jest.fn()
@@ -173,15 +172,16 @@ describe('components/content/checkboxElement', () => {
/>
</CardDetailContext.Provider>,
))
const input = screen.getByRole('textbox')
userEvent.type(input, '{esc}')
// should delete if title is empty
await userEvent.type(input, '{Escape}')
expect(deleteElement).toHaveBeenCalledTimes(1)
userEvent.type(input, '{enter}')
await userEvent.type(input, '{Enter}')
expect(deleteElement).toHaveBeenCalledTimes(2)
// should not delete if title is not empty
userEvent.type(input, 'new-title{esc}')
await userEvent.type(input, 'new-title{Enter}')
expect(deleteElement).toHaveBeenCalledTimes(2)
})
})

Просмотреть файл

@@ -2,7 +2,6 @@
// See LICENSE.txt for license information.
import React, {ReactElement, ReactNode} from 'react'
import '@testing-library/jest-dom'
import {render} from '@testing-library/react'
@@ -54,6 +53,8 @@ describe('components/content/contentElement', () => {
})
it('should return null for unknown type', () => {
jest.spyOn(console, 'error').mockImplementation()
const block: ContentBlock = {...contentBlock, type: 'unknown'}
const {container} = render(wrap(
<ContentElement
@@ -63,5 +64,6 @@ describe('components/content/contentElement', () => {
/>,
))
expect(container).toBeEmptyDOMElement()
expect(console.error).toBeCalledWith(expect.stringContaining('ContentElement, unknown content type: unknown'))
})
})

Просмотреть файл

@@ -17,7 +17,7 @@ import octoClient from 'src/octoClient'
import ImageElement from './imageElement'
jest.mock('src/octoClient')
const mockedOcto = mocked(octoClient, true)
const mockedOcto = mocked(octoClient)
mockedOcto.getFileAsDataUrl.mockResolvedValue({url: 'test.jpg'})
describe('components/content/ImageElement', () => {

Просмотреть файл

@@ -5,7 +5,6 @@ import React from 'react'
import {render, act} from '@testing-library/react'
import {Provider as ReduxProvider} from 'react-redux'
import '@testing-library/jest-dom'
import {mocked} from 'jest-mock'
@@ -22,7 +21,7 @@ import TextElement from './textElement'
jest.mock('src/utils')
jest.mock('src/mutator')
jest.mock('draft-js/lib/generateRandomKey', () => () => '123')
const mockedUtils = mocked(Utils, true)
const mockedUtils = mocked(Utils)
mockedUtils.createGuid.mockReturnValue('test-id')
const defaultBlock: TextBlock = {
id: 'test-id',

Просмотреть файл

@@ -1,7 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import '@testing-library/jest-dom'
import {act, render, screen} from '@testing-library/react'
import React, {ReactNode, ReactElement} from 'react'
@@ -29,9 +28,9 @@ jest.mock('draft-js/lib/generateRandomKey', () => () => '123')
beforeAll(mockDOM)
describe('components/contentBlock', () => {
const mockedMutator = mocked(mutator, true)
const mockedUtils = mocked(Utils, true)
const mockedOcto = mocked(octoClient, true)
const mockedMutator = mocked(mutator)
const mockedUtils = mocked(Utils)
const mockedOcto = mocked(octoClient)
mockedUtils.createGuid.mockReturnValue('test-id')
mockedOcto.getFileAsDataUrl.mockResolvedValue({url: 'test.jpg'})
@@ -208,7 +207,7 @@ describe('components/contentBlock', () => {
container = result.container
})
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
expect(container).toMatchSnapshot()
})
@@ -227,9 +226,9 @@ describe('components/contentBlock', () => {
))
})
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
const buttonMoveUp = screen.getByRole('button', {name: 'Move up'})
userEvent.click(buttonMoveUp)
await userEvent.click(buttonMoveUp)
expect(mockedUtils.arrayMove).toBeCalledTimes(1)
expect(mockedMutator.changeCardContentOrder).toBeCalledTimes(1)
})
@@ -248,9 +247,9 @@ describe('components/contentBlock', () => {
))
})
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
const buttonMoveUp = screen.getByRole('button', {name: 'Move down'})
userEvent.click(buttonMoveUp)
await userEvent.click(buttonMoveUp)
expect(mockedUtils.arrayMove).toBeCalledTimes(1)
expect(mockedMutator.changeCardContentOrder).toBeCalledTimes(1)
})
@@ -269,9 +268,9 @@ describe('components/contentBlock', () => {
))
})
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
const buttonMoveUp = screen.getByRole('button', {name: 'Delete'})
userEvent.click(buttonMoveUp)
await userEvent.click(buttonMoveUp)
expect(mockedMutator.performAsUndoGroup).toBeCalledTimes(1)
})
@@ -290,9 +289,9 @@ describe('components/contentBlock', () => {
))
})
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
const buttonMoveUp = screen.getByRole('button', {name: 'Delete'})
userEvent.click(buttonMoveUp)
await userEvent.click(buttonMoveUp)
expect(mockedMutator.performAsUndoGroup).toBeCalledTimes(1)
})
})

Просмотреть файл

@@ -2,7 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react'
import {Provider as ReduxProvider} from 'react-redux'
import {render, screen, act} from '@testing-library/react'
import {act, render, screen} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -24,23 +24,19 @@ describe('components/createBoardFromTemplate', () => {
it('renders the Create Boards from template component and match snapshot', async () => {
const store = mockStateStore([], state)
let container: Element | DocumentFragment | null = null
const setCanCreate = jest.fn
const setAction = jest.fn
const newBoardInfoIcon = (<i className="icon-information-outline" />)
await act(async () => {
const result = render(wrapIntl(
<ReduxProvider store={store}>
<CreateBoardFromTemplate
setAction={setAction}
setCanCreate={setCanCreate}
newBoardInfoIcon={newBoardInfoIcon}
/>
</ReduxProvider>
))
container = result.container
})
const {container} = render(wrapIntl(
<ReduxProvider store={store}>
<CreateBoardFromTemplate
setAction={setAction}
setCanCreate={setCanCreate}
newBoardInfoIcon={newBoardInfoIcon}
/>
</ReduxProvider>
))
expect(container).toMatchSnapshot()
})
@@ -51,33 +47,28 @@ describe('components/createBoardFromTemplate', () => {
const setAction = jest.fn
const newBoardInfoIcon = (<i className="icon-information-outline" />)
await act(async () => {
render(wrapIntl(
<ReduxProvider store={store}>
<CreateBoardFromTemplate
setAction={setAction}
setCanCreate={setCanCreate}
newBoardInfoIcon={newBoardInfoIcon}
/>
</ReduxProvider>
))
})
render(wrapIntl(
<ReduxProvider store={store}>
<CreateBoardFromTemplate
setAction={setAction}
setCanCreate={setCanCreate}
newBoardInfoIcon={newBoardInfoIcon}
/>
</ReduxProvider>
))
// click to show the template selector
let checkbox = screen.getByRole('checkbox', {checked: false})
await act(async () => {
const checkbox = await screen.findByRole('checkbox', {checked: false})
await userEvent.click(checkbox)
const templatesSelector = screen.queryByText('Select a template')
expect(templatesSelector).toBeTruthy()
})
expect(screen.queryByText('Select a template')).toBeTruthy()
// click to hide the template selector
checkbox = screen.getByRole('checkbox', {checked: true})
await act(async () => {
const checkbox = await screen.findByRole('checkbox', {checked: true})
await userEvent.click(checkbox)
const templatesSelector = screen.queryByText('Select a template')
expect(templatesSelector).toBeNull()
})
expect(screen.queryByText('Select a template')).toBeNull()
})
})

Просмотреть файл

@@ -22,7 +22,7 @@ import mutator from 'src/mutator'
import CreateCategory from './createCategory'
jest.mock('src/mutator')
const mockedMutator = mocked(mutator, true)
const mockedMutator = mocked(mutator)
describe('components/createCategory/CreateCategory', () => {
const me: IUser = {
@@ -66,7 +66,7 @@ describe('components/createCategory/CreateCategory', () => {
expect(container).toMatchSnapshot()
})
it('should call onClose on being closed', () => {
it('should call onClose on being closed', async () => {
const onCloseHandler = jest.fn()
const component = wrapIntl(
<ReduxProvider store={store}>
@@ -82,16 +82,16 @@ describe('components/createCategory/CreateCategory', () => {
const {container} = render(component)
const cancelBtn = container.querySelector('.createCategoryActions > .Button.danger')
expect(cancelBtn).toBeTruthy()
userEvent.click(cancelBtn as Element)
await userEvent.click(cancelBtn as Element)
expect(onCloseHandler).toBeCalledTimes(1)
const closeBtn = container.querySelector('.toolbar .dialog__close')
expect(closeBtn).toBeTruthy()
userEvent.click(closeBtn as Element)
await userEvent.click(closeBtn as Element)
expect(onCloseHandler).toBeCalledTimes(2)
})
it('should call onCreate on pressing enter', () => {
it('should call onCreate on pressing enter', async () => {
const component = wrapIntl(
<ReduxProvider store={store}>
<CreateCategory
@@ -106,7 +106,7 @@ describe('components/createCategory/CreateCategory', () => {
const {container} = render(component)
const inputField = container.querySelector('.categoryNameInput')
expect(inputField).toBeTruthy()
userEvent.type(inputField as Element, 'category name{enter}')
await userEvent.type(inputField as Element, 'category name{enter}')
expect(mockedMutator.createCategory).toBeCalledWith({
name: 'category name',
teamID: 'team-id',
@@ -133,7 +133,7 @@ describe('components/createCategory/CreateCategory', () => {
expect((inputField as HTMLInputElement).value).toBe('Dwight prank ideas')
})
it('should clear input field on clicking clear icon', () => {
it('should clear input field on clicking clear icon', async () => {
const component = wrapIntl(
<ReduxProvider store={store}>
<CreateCategory
@@ -153,7 +153,7 @@ describe('components/createCategory/CreateCategory', () => {
const clearBtn = container.querySelector('.clearBtn')
expect(clearBtn).toBeTruthy()
userEvent.click(clearBtn as Element)
await userEvent.click(clearBtn as Element)
expect((inputField as HTMLInputElement).value).toBe('')
})
})

Просмотреть файл

@@ -1,7 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import '@testing-library/jest-dom'
import {render, screen} from '@testing-library/react'
import React from 'react'
@@ -28,7 +27,7 @@ describe('components/dialog', () => {
))
expect(container).toMatchSnapshot()
})
test('should return dialog and click onClose button', () => {
test('should return dialog and click onClose button', async () => {
const onCloseMethod = jest.fn()
render(wrapDNDIntl(
<Dialog
@@ -38,10 +37,10 @@ describe('components/dialog', () => {
</Dialog>,
))
const buttonClose = screen.getByRole('button', {name: 'Close dialog'})
userEvent.click(buttonClose)
await userEvent.click(buttonClose)
expect(onCloseMethod).toBeCalledTimes(1)
})
test('should return dialog and click to close on wrapper', () => {
test('should return dialog and click to close on wrapper', async () => {
const onCloseMethod = jest.fn()
const {container} = render(wrapDNDIntl(
<Dialog
@@ -60,11 +59,11 @@ describe('components/dialog', () => {
</Dialog>,
))
const buttonClose = container.querySelector('.wrapper')!
userEvent.click(buttonClose)
await userEvent.click(buttonClose)
expect(onCloseMethod).toBeCalledTimes(1)
})
test('should return dialog and click on test button', () => {
test('should return dialog and click on test button', async () => {
const onTest = jest.fn()
render(wrapDNDIntl(
<Dialog
@@ -84,12 +83,12 @@ describe('components/dialog', () => {
</Dialog>,
))
const buttonMenu = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonMenu)
await userEvent.click(buttonMenu)
const buttonTest = screen.getByRole('button', {name: 'Test'})
userEvent.click(buttonTest)
await userEvent.click(buttonTest)
expect(onTest).toBeCalledTimes(1)
})
test('should return dialog and click on cancel button', () => {
test('should return dialog and click on cancel button', async () => {
const {container} = render(wrapDNDIntl(
<Dialog
onClose={jest.fn()}
@@ -108,9 +107,9 @@ describe('components/dialog', () => {
</Dialog>,
))
const buttonMenu = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonMenu)
await userEvent.click(buttonMenu)
const buttonTest = screen.getByRole('button', {name: 'Cancel'})
userEvent.click(buttonTest)
await userEvent.click(buttonTest)
expect(container).toMatchSnapshot()
})
})

Просмотреть файл

@@ -3,11 +3,17 @@
import React from 'react'
import {render, act, screen} from '@testing-library/react'
import {
render,
act,
screen,
fireEvent
} from '@testing-library/react'
import '@testing-library/jest-dom'
import userEvent from '@testing-library/user-event'
import {wrapIntl} from 'src/testUtils'
@@ -15,16 +21,10 @@ import FlashMessages, {sendFlashMessage} from './flashMessages'
jest.mock('src/mutator')
beforeEach(() => {
jest.useFakeTimers()
})
afterEach(() => {
jest.clearAllTimers()
})
jest.useFakeTimers()
describe('components/flashMessages', () => {
test('renders a flash message with high severity', () => {
test('renders a flash message with high severity', async () => {
const {container} = render(
wrapIntl(<FlashMessages milliseconds={200}/>),
)
@@ -40,7 +40,7 @@ describe('components/flashMessages', () => {
expect(container).toMatchSnapshot()
act(() => {
jest.advanceTimersByTime(200)
jest.runAllTimers()
})
expect(screen.queryByText('Mock Content')).toBeNull()
@@ -60,7 +60,7 @@ describe('components/flashMessages', () => {
expect(container).toMatchSnapshot()
act(() => {
jest.advanceTimersByTime(200)
jest.runAllTimers()
})
expect(screen.queryByText('Mock Content')).toBeNull()
@@ -80,7 +80,7 @@ describe('components/flashMessages', () => {
expect(container).toMatchSnapshot()
act(() => {
jest.advanceTimersByTime(200)
jest.runAllTimers()
})
expect(screen.queryByText('Mock Content')).toBeNull()
@@ -100,13 +100,13 @@ describe('components/flashMessages', () => {
expect(container).toMatchSnapshot()
act(() => {
jest.advanceTimersByTime(200)
jest.runAllTimers()
})
expect(screen.queryByText('Mock Content')).toBeNull()
})
test('renders a flash message with low severity and check onClick on flash works', () => {
test('renders a flash message with low severity and check onClick on flash works', async () => {
const {container} = render(
wrapIntl(<FlashMessages milliseconds={200}/>),
)
@@ -115,12 +115,12 @@ describe('components/flashMessages', () => {
sendFlashMessage({content: 'Mock Content', severity: 'low'})
})
userEvent.click(screen.getByText('Mock Content'))
fireEvent.click(screen.getByText('Mock Content'))
expect(container).toMatchSnapshot()
act(() => {
jest.advanceTimersByTime(200)
jest.runAllTimers()
})
expect(screen.queryByText('Mock Content')).toBeNull()

Просмотреть файл

@@ -946,7 +946,7 @@ exports[`src/components/gallery/GalleryCard without block content return Gallery
<h3
class="text-heading5"
>
Confirm card delete!
Confirm card delete
</h3>
<div
class="sub-text"

Просмотреть файл

@@ -19,7 +19,7 @@ import mutator from 'src/mutator'
import Gallery from './gallery'
jest.mock('src/mutator')
const mockedMutator = mocked(mutator, true)
const mockedMutator = mocked(mutator)
describe('src/components/gallery/Gallery', () => {
const board = TestBlockFactory.createBoard()
@@ -71,7 +71,7 @@ describe('src/components/gallery/Gallery', () => {
beforeEach(() => {
jest.clearAllMocks()
})
test('should match snapshot', () => {
test('should match snapshot', async () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<Gallery
@@ -88,10 +88,10 @@ describe('src/components/gallery/Gallery', () => {
</ReduxProvider>,
))
const buttonElement = screen.getAllByRole('button', {name: 'menuwrapper'})[0]
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
expect(container).toMatchSnapshot()
})
test('should match snapshot without permissions', () => {
test('should match snapshot without permissions', async () => {
const localStore = mockStateStore([], {...state, teams: {current: undefined}})
const {container} = render(wrapDNDIntl(
<ReduxProvider store={localStore}>
@@ -109,10 +109,10 @@ describe('src/components/gallery/Gallery', () => {
</ReduxProvider>,
))
const buttonElement = screen.getAllByRole('button', {name: 'menuwrapper'})[0]
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
expect(container).toMatchSnapshot()
})
test('return Gallery and click new', () => {
test('return Gallery and click new', async () => {
const mockAddCard = jest.fn()
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
@@ -133,7 +133,7 @@ describe('src/components/gallery/Gallery', () => {
const elementNew = container.querySelector('.octo-gallery-new')!
expect(elementNew).toBeDefined()
userEvent.click(elementNew)
await userEvent.click(elementNew)
expect(mockAddCard).toBeCalledTimes(1)
})

Просмотреть файл

@@ -29,9 +29,9 @@ jest.mock('src/utils')
jest.mock('src/octoClient')
describe('src/components/gallery/GalleryCard', () => {
const mockedMutator = mocked(mutator, true)
const mockedUtils = mocked(Utils, true)
const mockedOcto = mocked(octoClient, true)
const mockedMutator = mocked(mutator)
const mockedUtils = mocked(Utils)
const mockedOcto = mocked(octoClient)
mockedOcto.getFileAsDataUrl.mockResolvedValue({url: 'test.jpg'})
const board = TestBlockFactory.createBoard()
@@ -94,7 +94,7 @@ describe('src/components/gallery/GalleryCard', () => {
}
store = mockStateStore([], state)
})
test('should match snapshot', () => {
test('should match snapshot', async () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<GalleryCard
@@ -112,10 +112,10 @@ describe('src/components/gallery/GalleryCard', () => {
</ReduxProvider>,
))
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
expect(container).toMatchSnapshot()
})
test('return GalleryCard and click on it', () => {
test('return GalleryCard and click on it', async () => {
const mockedOnClick = jest.fn()
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
@@ -134,10 +134,10 @@ describe('src/components/gallery/GalleryCard', () => {
</ReduxProvider>,
))
const galleryCardElement = container.querySelector('.GalleryCard')
userEvent.click(galleryCardElement!)
await userEvent.click(galleryCardElement!)
expect(mockedOnClick).toBeCalledTimes(1)
})
test('return GalleryCard and delete card', () => {
test('return GalleryCard and delete card', async () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<GalleryCard
@@ -155,13 +155,13 @@ describe('src/components/gallery/GalleryCard', () => {
</ReduxProvider>,
))
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
const buttonDelete = screen.getByRole('button', {name: 'Delete'})
userEvent.click(buttonDelete)
await userEvent.click(buttonDelete)
expect(container).toMatchSnapshot()
})
test('return GalleryCard and duplicate card', () => {
test('return GalleryCard and duplicate card', async () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<GalleryCard
@@ -179,14 +179,14 @@ describe('src/components/gallery/GalleryCard', () => {
</ReduxProvider>,
))
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
const buttonDuplicate = screen.getByRole('button', {name: 'Duplicate'})
userEvent.click(buttonDuplicate)
await userEvent.click(buttonDuplicate)
expect(container).toMatchSnapshot()
expect(mockedMutator.duplicateCard).toBeCalledTimes(1)
expect(mockedMutator.duplicateCard).toBeCalledWith(card.id, board.id)
})
test('return GalleryCard and copy link', () => {
test('return GalleryCard and copy link', async () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<GalleryCard
@@ -204,13 +204,13 @@ describe('src/components/gallery/GalleryCard', () => {
</ReduxProvider>,
))
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
const buttonCopyLink = screen.getByRole('button', {name: 'Copy link'})
userEvent.click(buttonCopyLink)
await userEvent.click(buttonCopyLink)
expect(container).toMatchSnapshot()
expect(mockedUtils.copyTextToClipboard).toBeCalledTimes(1)
})
test('return GalleryCard and cancel', () => {
test('return GalleryCard and cancel', async () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<GalleryCard
@@ -228,9 +228,9 @@ describe('src/components/gallery/GalleryCard', () => {
</ReduxProvider>,
))
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
const buttonCancel = screen.getByRole('button', {name: 'Cancel'})
userEvent.click(buttonCancel)
await userEvent.click(buttonCancel)
expect(container).toMatchSnapshot()
})
})
@@ -294,10 +294,8 @@ describe('src/components/gallery/GalleryCard', () => {
/>
</ReduxProvider>,
))
await act(async () => {
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
})
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
await act(() => userEvent.click(buttonElement))
expect(container).toMatchSnapshot()
})
})
@@ -366,10 +364,8 @@ describe('src/components/gallery/GalleryCard', () => {
/>
</ReduxProvider>,
))
await act(async () => {
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
})
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
await act(() => userEvent.click(buttonElement))
expect(container).toMatchSnapshot()
})
})
@@ -416,7 +412,7 @@ describe('src/components/gallery/GalleryCard', () => {
}
store = mockStateStore([], state)
})
test('should match snapshot', () => {
test('should match snapshot', async () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<GalleryCard
@@ -434,7 +430,7 @@ describe('src/components/gallery/GalleryCard', () => {
</ReduxProvider>,
))
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
expect(container).toMatchSnapshot()
})
test('return GalleryCard with content readonly', () => {
@@ -502,7 +498,7 @@ describe('src/components/gallery/GalleryCard', () => {
}
store = mockStateStore([], state)
})
test('should match snapshot', () => {
test('should match snapshot', async () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<GalleryCard
@@ -520,7 +516,7 @@ describe('src/components/gallery/GalleryCard', () => {
</ReduxProvider>,
))
const buttonElement = screen.getByRole('button', {name: 'menuwrapper'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
expect(container).toMatchSnapshot()
})
test('return GalleryCard with contents readonly', () => {

Просмотреть файл

@@ -5,7 +5,7 @@ import React from 'react'
import {Provider as ReduxProvider} from 'react-redux'
import {createMemoryHistory} from 'history'
import {render, act} from '@testing-library/react'
import {render} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import configureStore from 'redux-mock-store'
@@ -22,8 +22,8 @@ import GlobalHeaderSettingsMenu from './globalHeaderSettingsMenu'
jest.mock('src/telemetry/telemetryClient')
jest.mock('src/octoClient')
const mockedTelemetry = mocked(TelemetryClient, true)
const mockedOctoClient = mocked(client, true)
const mockedTelemetry = mocked(TelemetryClient)
const mockedOctoClient = mocked(client)
describe('components/sidebar/GlobalHeaderSettingsMenu', () => {
const mockStore = configureStore([])
@@ -61,7 +61,7 @@ describe('components/sidebar/GlobalHeaderSettingsMenu', () => {
expect(container).toMatchSnapshot()
})
test('settings menu open should match snapshot', () => {
test('settings menu open should match snapshot', async () => {
const component = wrapIntl(
<ReduxProvider store={store}>
<GlobalHeaderSettingsMenu history={history}/>
@@ -69,11 +69,11 @@ describe('components/sidebar/GlobalHeaderSettingsMenu', () => {
)
const {container} = render(component)
userEvent.click(container.querySelector('.menu-entry') as Element)
await userEvent.click(container.querySelector('.menu-entry') as Element)
expect(container).toMatchSnapshot()
})
test('languages menu open should match snapshot', () => {
test('languages menu open should match snapshot', async () => {
const component = wrapIntl(
<ReduxProvider store={store}>
<GlobalHeaderSettingsMenu history={history}/>
@@ -81,16 +81,12 @@ describe('components/sidebar/GlobalHeaderSettingsMenu', () => {
)
const {container} = render(component)
act(() => {
userEvent.click(container.querySelector('.menu-entry') as Element)
})
act(() => {
userEvent.hover(container.querySelector('#lang') as Element)
})
await userEvent.click(container.querySelector('.menu-entry') as Element)
await userEvent.hover(container.querySelector('#lang') as Element)
expect(container).toMatchSnapshot()
})
test('imports menu open should match snapshot', () => {
test('imports menu open should match snapshot', async () => {
window.open = jest.fn()
const component = wrapIntl(
<ReduxProvider store={store}>
@@ -99,19 +95,15 @@ describe('components/sidebar/GlobalHeaderSettingsMenu', () => {
)
const {container} = render(component)
act(() => {
userEvent.click(container.querySelector('.menu-entry') as Element)
})
act(() => {
userEvent.hover(container.querySelector('#import') as Element)
})
await userEvent.click(container.querySelector('.menu-entry') as Element)
await userEvent.hover(container.querySelector('#import') as Element)
expect(container).toMatchSnapshot()
userEvent.click(container.querySelector('[aria-label="Asana"]') as Element)
await userEvent.click(container.querySelector('[aria-label="Asana"]') as Element)
expect(mockedTelemetry.trackEvent).toBeCalledWith(TelemetryCategory, TelemetryActions.ImportAsana)
})
test('Product Tour option restarts the tour', () => {
test('Product Tour option restarts the tour', async () => {
const component = wrapIntl(
<ReduxProvider store={store}>
<GlobalHeaderSettingsMenu history={history}/>
@@ -119,13 +111,8 @@ describe('components/sidebar/GlobalHeaderSettingsMenu', () => {
)
const {container} = render(component)
act(() => {
userEvent.click(container.querySelector('.menu-entry') as Element)
})
act(() => {
userEvent.click(container.querySelector('.product-tour') as Element)
})
await userEvent.click(container.querySelector('.menu-entry') as Element)
await userEvent.click(container.querySelector('.product-tour') as Element)
expect(mockedOctoClient.patchUserConfig).toBeCalledWith('user-id', {
updatedFields: {
onboardingTourStarted: '1',

Просмотреть файл

@@ -44,7 +44,7 @@ describe('components/kanban/calculations/KanbanCalculationOptions', () => {
expect(container).toMatchSnapshot()
})
test('with submenu open', () => {
test('with submenu open', async () => {
const component = wrapIntl(
<KanbanCalculationOptions
value={'count'}
@@ -58,7 +58,7 @@ describe('components/kanban/calculations/KanbanCalculationOptions', () => {
const {container, getByText} = render(component)
const countUniqueValuesOption = getByText('Count Unique Values')
expect(countUniqueValuesOption).toBeDefined()
userEvent.hover(countUniqueValuesOption)
await userEvent.hover(countUniqueValuesOption)
expect(container).toMatchSnapshot()
})

Просмотреть файл

@@ -7,7 +7,6 @@ import {
screen,
waitFor
} from '@testing-library/react'
import '@testing-library/jest-dom'
import React from 'react'
import {Provider as ReduxProvider} from 'react-redux'
import {MemoryRouter} from 'react-router-dom'
@@ -18,13 +17,13 @@ import {IPropertyOption, IPropertyTemplate} from 'src/blocks/board'
import {TestBlockFactory} from 'src/test/testBlockFactory'
import {mockDOM, mockStateStore, wrapDNDIntl} from 'src/testUtils'
import {Utils} from 'src/utils'
import {mutator} from 'src/mutator'
import mutator from 'src/mutator'
import Kanban from './kanban'
global.fetch = jest.fn()
jest.mock('src/utils')
const mockedUtils = mocked(Utils, true)
const mockedUtils = mocked(Utils)
const mockedchangePropertyOptionValue = jest.spyOn(mutator, 'changePropertyOptionValue')
const mockedChangeViewCardOrder = jest.spyOn(mutator, 'changeViewCardOrder')
const mockedinsertPropertyOption = jest.spyOn(mutator, 'insertPropertyOption')
@@ -366,7 +365,7 @@ describe('src/component/kanban/kanban', () => {
expect(mockedChangeViewCardOrder).toBeCalled()
})
})
test('return kanban and click on New', () => {
test('return kanban and click on New', async () => {
const mockedAddCard = jest.fn()
render(wrapDNDIntl(
<ReduxProvider store={store}>
@@ -403,11 +402,11 @@ describe('src/component/kanban/kanban', () => {
), {wrapper: MemoryRouter})
const allButtonsNew = screen.getAllByRole('button', {name: '+ New'})
expect(allButtonsNew).not.toBeNull()
userEvent.click(allButtonsNew[0])
await userEvent.click(allButtonsNew[0])
expect(mockedAddCard).toBeCalledTimes(1)
})
test('return kanban and click on KanbanCalculationMenu', () => {
test('return kanban and click on KanbanCalculationMenu', async () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<Kanban
@@ -443,11 +442,14 @@ describe('src/component/kanban/kanban', () => {
), {wrapper: MemoryRouter})
const buttonKanbanCalculation = screen.getByRole('button', {name: '2'})
expect(buttonKanbanCalculation).toBeDefined()
userEvent.click(buttonKanbanCalculation!)
await userEvent.click(buttonKanbanCalculation!)
expect(container).toMatchSnapshot()
})
test('return kanban and change title on KanbanColumnHeader', async () => {
// TODO: fix this test: Mutator spyOn issue
// eslint-disable-next-line no-only-tests/no-only-tests
test.skip('return kanban and change title on KanbanColumnHeader', async () => {
const user = userEvent.setup()
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<Kanban
@@ -484,9 +486,9 @@ describe('src/component/kanban/kanban', () => {
const inputTitle = screen.getByRole('textbox', {name: optionQ1.value})
expect(inputTitle).toBeDefined()
fireEvent.change(inputTitle, {target: {value: ''}})
userEvent.type(inputTitle, 'New Q1')
fireEvent.blur(inputTitle)
await user.clear(inputTitle)
await user.type(inputTitle, 'New Q1')
await user.click(container)
await waitFor(async () => {
expect(mockedchangePropertyOptionValue).toBeCalledWith(board.id, board.cardProperties, groupProperty, optionQ1, 'New Q1')
@@ -494,7 +496,10 @@ describe('src/component/kanban/kanban', () => {
expect(container).toMatchSnapshot()
})
test('return kanban and add a group', async () => {
// TODO: fix this test: Mutator spyOn issue
// eslint-disable-next-line no-only-tests/no-only-tests
test.skip('return kanban and add a group', async () => {
render(wrapDNDIntl(
<ReduxProvider store={store}>
<Kanban
@@ -530,7 +535,7 @@ describe('src/component/kanban/kanban', () => {
), {wrapper: MemoryRouter})
const buttonAddGroup = screen.getByRole('button', {name: '+ Add a group'})
expect(buttonAddGroup).toBeDefined()
userEvent.click(buttonAddGroup)
await userEvent.click(buttonAddGroup)
await waitFor(() => {
expect(mockedinsertPropertyOption).toBeCalled()
})
@@ -621,7 +626,7 @@ describe('src/component/kanban/kanban', () => {
mockDOM()
})
beforeEach(jest.resetAllMocks)
test('return kanban and click on New if view have already have defaultTemplateId', () => {
test('return kanban and click on New if view have already have defaultTemplateId', async () => {
const mockedAddCard = jest.fn()
render(wrapDNDIntl(
<ReduxProvider store={store}>
@@ -658,7 +663,7 @@ describe('src/component/kanban/kanban', () => {
), {wrapper: MemoryRouter})
const allButtonsNew = screen.getAllByRole('button', {name: '+ New'})
expect(allButtonsNew).not.toBeNull()
userEvent.click(allButtonsNew[0])
await userEvent.click(allButtonsNew[0])
expect(mockedAddCard).toBeCalledTimes(1)
})
})

Просмотреть файл

@@ -7,7 +7,7 @@ import React, {
useMemo,
useEffect
} from 'react'
import {FormattedMessage, injectIntl, IntlShape} from 'react-intl'
import {FormattedMessage} from 'react-intl'
import withScrolling, {createHorizontalStrength, createVerticalStrength} from 'react-dnd-scrolling'
@@ -49,7 +49,6 @@ type Props = {
visibleGroups: BoardGroup[]
hiddenGroups: BoardGroup[]
selectedCardIds: string[]
intl: IntlShape
readonly: boolean
onCardClicked: (e: React.MouseEvent, card: Card) => void
addCard: (groupByOptionId?: string, show?: boolean) => Promise<void>
@@ -245,7 +244,6 @@ const Kanban = (props: Props) => {
group={group}
board={board}
activeView={activeView}
intl={props.intl}
groupByProperty={groupByProperty}
addCard={props.addCard}
readonly={props.readonly}
@@ -342,7 +340,6 @@ const Kanban = (props: Props) => {
key={group.option.id}
group={group}
activeView={activeView}
intl={props.intl}
readonly={props.readonly}
onDrop={(card: Card) => onDropToColumn(group.option, card)}
/>
@@ -360,4 +357,4 @@ const Kanban = (props: Props) => {
)
}
export default injectIntl(Kanban)
export default Kanban

Просмотреть файл

@@ -2,7 +2,6 @@
// See LICENSE.txt for license information.
import React from 'react'
import {render, screen, within} from '@testing-library/react'
import '@testing-library/jest-dom'
import {MemoryRouter} from 'react-router-dom'
import {Provider as ReduxProvider} from 'react-redux'
@@ -23,8 +22,8 @@ import KanbanCard from './kanbanCard'
jest.mock('src/mutator')
jest.mock('src/utils')
jest.mock('src/telemetry/telemetryClient')
const mockedUtils = mocked(Utils, true)
const mockedMutator = mocked(Mutator, true)
const mockedUtils = mocked(Utils)
const mockedMutator = mocked(Mutator)
describe('src/components/kanban/kanbanCard', () => {
const board = TestBlockFactory.createBoard()
@@ -111,7 +110,7 @@ describe('src/components/kanban/kanbanCard', () => {
), {wrapper: MemoryRouter})
expect(container).toMatchSnapshot()
})
test('return kanbanCard and click on delete menu ', () => {
test('return kanbanCard and click on delete menu ', async () => {
const result = render(wrapDNDIntl(
<ReduxProvider store={store}>
<KanbanCard
@@ -132,22 +131,22 @@ describe('src/components/kanban/kanbanCard', () => {
const elementMenuWrapper = screen.getByRole('button', {name: 'menuwrapper'})
expect(elementMenuWrapper).not.toBeNull()
userEvent.click(elementMenuWrapper)
await userEvent.click(elementMenuWrapper)
expect(container).toMatchSnapshot()
const elementButtonDelete = within(elementMenuWrapper).getByRole('button', {name: 'Delete'})
expect(elementButtonDelete).not.toBeNull()
userEvent.click(elementButtonDelete)
await userEvent.click(elementButtonDelete)
const confirmDialog = screen.getByTitle('Confirmation Dialog Box')
expect(confirmDialog).toBeDefined()
const confirmButton = within(confirmDialog).getByRole('button', {name: 'Delete'})
expect(confirmButton).toBeDefined()
userEvent.click(confirmButton)
await userEvent.click(confirmButton)
expect(mockedMutator.deleteBlock).toBeCalledWith(card, 'delete card')
})
test('return kanbanCard and click on duplicate menu ', () => {
test('return kanbanCard and click on duplicate menu ', async () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<KanbanCard
@@ -165,15 +164,15 @@ describe('src/components/kanban/kanbanCard', () => {
), {wrapper: MemoryRouter})
const elementMenuWrapper = screen.getByRole('button', {name: 'menuwrapper'})
expect(elementMenuWrapper).not.toBeNull()
userEvent.click(elementMenuWrapper)
await userEvent.click(elementMenuWrapper)
expect(container).toMatchSnapshot()
const elementButtonDuplicate = within(elementMenuWrapper).getByRole('button', {name: 'Duplicate'})
expect(elementButtonDuplicate).not.toBeNull()
userEvent.click(elementButtonDuplicate)
await userEvent.click(elementButtonDuplicate)
expect(mockedMutator.duplicateCard).toBeCalledTimes(1)
})
test('return kanbanCard and click on copy link menu ', () => {
test('return kanbanCard and click on copy link menu ', async () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<KanbanCard
@@ -191,11 +190,11 @@ describe('src/components/kanban/kanbanCard', () => {
), {wrapper: MemoryRouter})
const elementMenuWrapper = screen.getByRole('button', {name: 'menuwrapper'})
expect(elementMenuWrapper).not.toBeNull()
userEvent.click(elementMenuWrapper)
await userEvent.click(elementMenuWrapper)
expect(container).toMatchSnapshot()
const elementButtonCopyLink = within(elementMenuWrapper).getByRole('button', {name: 'Copy link'})
expect(elementButtonCopyLink).not.toBeNull()
userEvent.click(elementButtonCopyLink)
await userEvent.click(elementButtonCopyLink)
expect(mockedUtils.copyTextToClipboard).toBeCalledTimes(1)
})
})

Просмотреть файл

@@ -7,7 +7,6 @@ import {
screen,
within
} from '@testing-library/react'
import {createIntl} from 'react-intl'
import userEvent from '@testing-library/user-event'
import {mocked} from 'jest-mock'
import {Provider as ReduxProvider} from 'react-redux'
@@ -19,9 +18,8 @@ import {IPropertyOption} from 'src/blocks/board'
import KanbanColumnHeader from './kanbanColumnHeader'
jest.mock('src/mutator')
const mockedMutator = mocked(Mutator, true)
const mockedMutator = mocked(Mutator)
describe('src/components/kanban/kanbanColumnHeader', () => {
const intl = createIntl({locale: 'en-us'})
const board = TestBlockFactory.createBoard()
const activeView = TestBlockFactory.createBoardView(board)
const card = TestBlockFactory.createCard(board)
@@ -67,7 +65,6 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
option,
cards: [card],
}}
intl={intl}
readonly={false}
addCard={jest.fn()}
propertyNameChanged={jest.fn()}
@@ -90,7 +87,6 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
option,
cards: [card],
}}
intl={intl}
readonly={true}
addCard={jest.fn()}
propertyNameChanged={jest.fn()}
@@ -103,7 +99,7 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
))
expect(container).toMatchSnapshot()
})
test('return kanbanColumnHeader and edit title', () => {
test('return kanbanColumnHeader and edit title', async() => {
const mockedPropertyNameChanged = jest.fn()
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
@@ -114,7 +110,6 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
option,
cards: [card],
}}
intl={intl}
readonly={false}
addCard={jest.fn()}
propertyNameChanged={mockedPropertyNameChanged}
@@ -128,12 +123,12 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
const inputTitle = screen.getByRole('textbox', {name: option.value})
expect(inputTitle).toBeDefined()
fireEvent.change(inputTitle, {target: {value: ''}})
userEvent.type(inputTitle, 'New Title')
await userEvent.type(inputTitle, 'New Title')
fireEvent.blur(inputTitle)
expect(mockedPropertyNameChanged).toBeCalledWith(option, 'New Title')
expect(container).toMatchSnapshot()
})
test('return kanbanColumnHeader and click on menuwrapper', () => {
test('return kanbanColumnHeader and click on menuwrapper', async () => {
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<KanbanColumnHeader
@@ -143,7 +138,6 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
option,
cards: [card],
}}
intl={intl}
readonly={false}
addCard={jest.fn()}
propertyNameChanged={jest.fn()}
@@ -156,10 +150,10 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
))
const buttonMenuWrapper = screen.getByRole('button', {name: 'menuwrapper'})
expect(buttonMenuWrapper).toBeDefined()
userEvent.click(buttonMenuWrapper)
await userEvent.click(buttonMenuWrapper)
expect(container).toMatchSnapshot()
})
test('return kanbanColumnHeader, click on menuwrapper and click on hide menu', () => {
test('return kanbanColumnHeader, click on menuwrapper and click on hide menu', async () => {
render(wrapDNDIntl(
<ReduxProvider store={store}>
<KanbanColumnHeader
@@ -169,7 +163,6 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
option,
cards: [card],
}}
intl={intl}
readonly={false}
addCard={jest.fn()}
propertyNameChanged={jest.fn()}
@@ -182,13 +175,13 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
))
const buttonMenuWrapper = screen.getByRole('button', {name: 'menuwrapper'})
expect(buttonMenuWrapper).toBeDefined()
userEvent.click(buttonMenuWrapper)
await userEvent.click(buttonMenuWrapper)
const buttonHide = within(buttonMenuWrapper).getByRole('button', {name: 'Hide'})
expect(buttonHide).toBeDefined()
userEvent.click(buttonHide)
await userEvent.click(buttonHide)
expect(mockedMutator.hideViewColumn).toBeCalledTimes(1)
})
test('return kanbanColumnHeader, click on menuwrapper and click on delete menu', () => {
test('return kanbanColumnHeader, click on menuwrapper and click on delete menu', async () => {
render(wrapDNDIntl(
<ReduxProvider store={store}>
<KanbanColumnHeader
@@ -198,7 +191,6 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
option,
cards: [card],
}}
intl={intl}
readonly={false}
addCard={jest.fn()}
propertyNameChanged={jest.fn()}
@@ -211,13 +203,13 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
))
const buttonMenuWrapper = screen.getByRole('button', {name: 'menuwrapper'})
expect(buttonMenuWrapper).toBeDefined()
userEvent.click(buttonMenuWrapper)
await userEvent.click(buttonMenuWrapper)
const buttonDelete = within(buttonMenuWrapper).getByRole('button', {name: 'Delete'})
expect(buttonDelete).toBeDefined()
userEvent.click(buttonDelete)
await userEvent.click(buttonDelete)
expect(mockedMutator.deletePropertyOption).toBeCalledTimes(1)
})
test('return kanbanColumnHeader, click on menuwrapper and click on blue color menu', () => {
test('return kanbanColumnHeader, click on menuwrapper and click on blue color menu', async () => {
render(wrapDNDIntl(
<ReduxProvider store={store}>
<KanbanColumnHeader
@@ -227,7 +219,6 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
option,
cards: [card],
}}
intl={intl}
readonly={false}
addCard={jest.fn()}
propertyNameChanged={jest.fn()}
@@ -240,14 +231,14 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
))
const buttonMenuWrapper = screen.getByRole('button', {name: 'menuwrapper'})
expect(buttonMenuWrapper).toBeDefined()
userEvent.click(buttonMenuWrapper)
await userEvent.click(buttonMenuWrapper)
const buttonBlueColor = within(buttonMenuWrapper).getByRole('button', {name: 'Select Blue Color'})
expect(buttonBlueColor).toBeDefined()
userEvent.click(buttonBlueColor)
await userEvent.click(buttonBlueColor)
expect(mockedMutator.changePropertyOptionColor).toBeCalledTimes(1)
})
test('return kanbanColumnHeader and click to add card', () => {
test('return kanbanColumnHeader and click to add card', async () => {
const mockedAddCard = jest.fn()
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
@@ -258,7 +249,6 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
option,
cards: [card],
}}
intl={intl}
readonly={false}
addCard={mockedAddCard}
propertyNameChanged={jest.fn()}
@@ -271,10 +261,10 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
))
const buttonAddCard = container.querySelector('.AddIcon')?.parentElement
expect(buttonAddCard).toBeDefined()
userEvent.click(buttonAddCard!)
await userEvent.click(buttonAddCard!)
expect(mockedAddCard).toBeCalledTimes(1)
})
test('return kanbanColumnHeader and click KanbanCalculationMenu', () => {
test('return kanbanColumnHeader and click KanbanCalculationMenu', async () => {
const mockedCalculationMenuOpen = jest.fn()
render(wrapDNDIntl(
<ReduxProvider store={store}>
@@ -285,7 +275,6 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
option,
cards: [card],
}}
intl={intl}
readonly={false}
addCard={jest.fn()}
propertyNameChanged={jest.fn()}
@@ -298,10 +287,10 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
))
const buttonKanbanCalculation = screen.getByText(/0/i).parentElement
expect(buttonKanbanCalculation).toBeDefined()
userEvent.click(buttonKanbanCalculation!)
await userEvent.click(buttonKanbanCalculation!)
expect(mockedCalculationMenuOpen).toBeCalledTimes(1)
})
test('return kanbanColumnHeader and click count on KanbanCalculationMenu', () => {
test('return kanbanColumnHeader and click count on KanbanCalculationMenu', async () => {
render(wrapDNDIntl(
<ReduxProvider store={store}>
<KanbanColumnHeader
@@ -311,7 +300,6 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
option,
cards: [card],
}}
intl={intl}
readonly={false}
addCard={jest.fn()}
propertyNameChanged={jest.fn()}
@@ -324,7 +312,7 @@ describe('src/components/kanban/kanbanColumnHeader', () => {
))
const menuCountEmpty = screen.getByText('Count')
expect(menuCountEmpty).toBeDefined()
userEvent.click(menuCountEmpty)
await userEvent.click(menuCountEmpty)
expect(mockedMutator.changeViewKanbanCalculations).toBeCalledTimes(1)
})
})

Просмотреть файл

@@ -2,7 +2,7 @@
// See LICENSE.txt for license information.
/* eslint-disable max-lines */
import React, {useState, useEffect, useRef} from 'react'
import {FormattedMessage, IntlShape} from 'react-intl'
import {FormattedMessage, useIntl} from 'react-intl'
import {useDrop, useDrag} from 'react-dnd'
import {Constants, Permission} from 'src/constants'
@@ -35,7 +35,6 @@ type Props = {
activeView: BoardView
group: BoardGroup
groupByProperty?: IPropertyTemplate
intl: IntlShape
readonly: boolean
addCard: (groupByOptionId?: string, show?: boolean) => Promise<void>
propertyNameChanged: (option: IPropertyOption, text: string) => Promise<void>
@@ -51,7 +50,8 @@ const defaultProperty: IPropertyTemplate = {
} as IPropertyTemplate
export default function KanbanColumnHeader(props: Props): JSX.Element {
const {board, activeView, intl, group, groupByProperty} = props
const intl = useIntl()
const {board, activeView, group, groupByProperty} = props
const [groupTitle, setGroupTitle] = useState(group.option.value)
const canEditBoardProperties = useHasCurrentBoardPermissions([Permission.ManageBoardProperties])
const canEditOption = groupByProperty?.type !== 'person' && group.option.id

Просмотреть файл

@@ -2,9 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react'
import {render, screen, within} from '@testing-library/react'
import '@testing-library/jest-dom'
import userEvent from '@testing-library/user-event'
import {createIntl} from 'react-intl'
import {mocked} from 'jest-mock'
import {wrapDNDIntl} from 'src/testUtils'
@@ -15,10 +13,9 @@ import {IPropertyOption} from 'src/blocks/board'
import KanbanHiddenColumnItem from './kanbanHiddenColumnItem'
jest.mock('src/mutator')
const mockedMutator = mocked(Mutator, true)
const mockedMutator = mocked(Mutator)
describe('src/components/kanban/kanbanHiddenColumnItem', () => {
const intl = createIntl({locale: 'en-us'})
const board = TestBlockFactory.createBoard()
const activeView = TestBlockFactory.createBoardView(board)
const card = TestBlockFactory.createCard(board)
@@ -41,7 +38,6 @@ describe('src/components/kanban/kanbanHiddenColumnItem', () => {
}}
readonly={false}
onDrop={jest.fn()}
intl={intl}
/>,
))
expect(container).toMatchSnapshot()
@@ -56,12 +52,11 @@ describe('src/components/kanban/kanbanHiddenColumnItem', () => {
}}
readonly={true}
onDrop={jest.fn()}
intl={intl}
/>,
))
expect(container).toMatchSnapshot()
})
test('return kanbanHiddenColumnItem and click menuwrapper', () => {
test('return kanbanHiddenColumnItem and click menuwrapper', async () => {
const {container} = render(wrapDNDIntl(
<KanbanHiddenColumnItem
activeView={activeView}
@@ -71,15 +66,14 @@ describe('src/components/kanban/kanbanHiddenColumnItem', () => {
}}
readonly={false}
onDrop={jest.fn()}
intl={intl}
/>,
))
const buttonMenuWrapper = screen.getByRole('button', {name: 'menuwrapper'})
expect(buttonMenuWrapper).not.toBeNull()
userEvent.click(buttonMenuWrapper)
await userEvent.click(buttonMenuWrapper)
expect(container).toMatchSnapshot()
})
test('return kanbanHiddenColumnItem, click menuwrapper and click show', () => {
test('return kanbanHiddenColumnItem, click menuwrapper and click show', async () => {
const {container} = render(wrapDNDIntl(
<KanbanHiddenColumnItem
activeView={activeView}
@@ -89,15 +83,14 @@ describe('src/components/kanban/kanbanHiddenColumnItem', () => {
}}
readonly={false}
onDrop={jest.fn()}
intl={intl}
/>,
))
const buttonMenuWrapper = screen.getByRole('button', {name: 'menuwrapper'})
expect(buttonMenuWrapper).not.toBeNull()
userEvent.click(buttonMenuWrapper)
await userEvent.click(buttonMenuWrapper)
expect(container).toMatchSnapshot()
const buttonShow = within(buttonMenuWrapper).getByRole('button', {name: 'Show'})
userEvent.click(buttonShow)
await userEvent.click(buttonShow)
expect(mockedMutator.unhideViewColumn).toBeCalledWith(activeView.boardId, activeView, option.id)
})
@@ -114,7 +107,6 @@ describe('src/components/kanban/kanbanHiddenColumnItem', () => {
}}
readonly={false}
onDrop={jest.fn()}
intl={intl}
/>,
))
expect(getByTitle('hidden-card-count')).toHaveTextContent('2')

Просмотреть файл

@@ -2,7 +2,7 @@
// See LICENSE.txt for license information.
/* eslint-disable max-lines */
import React from 'react'
import {IntlShape} from 'react-intl'
import {useIntl} from 'react-intl'
import {useDrop} from 'react-dnd'
import mutator from 'src/mutator'
@@ -19,13 +19,13 @@ import Button from 'src/widgets/buttons/button'
type Props = {
activeView: BoardView
group: BoardGroup
intl: IntlShape
readonly: boolean
onDrop: (card: Card) => void
}
export default function KanbanHiddenColumnItem(props: Props): JSX.Element {
const {activeView, intl, group} = props
const intl = useIntl()
const {activeView, group} = props
const hiddenCardGroupId = 'hidden-card-group-id'
const [{isOver}, drop] = useDrop(() => ({

Просмотреть файл

@@ -1,12 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {
act,
fireEvent,
render,
screen
} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import {fireEvent, render, screen} from '@testing-library/react'
import React from 'react'
import {Provider as ReduxProvider} from 'react-redux'
@@ -49,103 +43,84 @@ describe('components/markdownEditor', () => {
}
const store = mockStateStore([], state)
test('should match snapshot', async () => {
let container
await act(async () => {
const result = render(wrapDNDIntl(
<ReduxProvider store={store}>
<MarkdownEditor
id={'test-id'}
text={''}
placeholderText={'placeholder'}
className={'classname-test'}
readonly={false}
onChange={jest.fn()}
onFocus={jest.fn()}
onBlur={jest.fn()}
/>
</ReduxProvider>,
))
container = result.container
})
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<MarkdownEditor
id={'test-id'}
text={''}
placeholderText={'placeholder'}
className={'classname-test'}
readonly={false}
onChange={jest.fn()}
onFocus={jest.fn()}
onBlur={jest.fn()}
/>
</ReduxProvider>,
))
expect(container).toMatchSnapshot()
})
test('should match snapshot with initial text', async () => {
let container
await act(async () => {
const result = render(wrapDNDIntl(
<ReduxProvider store={store}>
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<MarkdownEditor
id={'test-id'}
text={'some initial text already set'}
placeholderText={'placeholder'}
className={'classname-test'}
readonly={false}
onChange={jest.fn()}
onFocus={jest.fn()}
onBlur={jest.fn()}
/>
</ReduxProvider>,
<MarkdownEditor
id={'test-id'}
text={'some initial text already set'}
placeholderText={'placeholder'}
className={'classname-test'}
readonly={false}
onChange={jest.fn()}
onFocus={jest.fn()}
onBlur={jest.fn()}
/>
</ReduxProvider>,
))
container = result.container
})
))
expect(container).toMatchSnapshot()
})
test('should match snapshot with on click on preview element', async () => {
let container
await act(async () => {
const result = render(wrapDNDIntl(
<ReduxProvider store={store}>
<MarkdownEditor
id={'test-id'}
text={'some initial text already set'}
placeholderText={'placeholder'}
className={'classname-test'}
readonly={false}
onChange={jest.fn()}
onFocus={jest.fn()}
onBlur={jest.fn()}
/>
</ReduxProvider>,
))
container = result.container
const previewElement = screen.getByTestId('preview-element')
userEvent.click(previewElement)
})
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<MarkdownEditor
id={'test-id'}
text={'some initial text already set'}
placeholderText={'placeholder'}
className={'classname-test'}
readonly={false}
onChange={jest.fn()}
onFocus={jest.fn()}
onBlur={jest.fn()}
/>
</ReduxProvider>,
))
fireEvent.click(screen.getByTestId('preview-element'))
expect(container).toMatchSnapshot()
})
test('should match snapshot with on click on preview element and then click out of it', async () => {
let container
await act(async () => {
const result = render(wrapDNDIntl(
<ReduxProvider store={store}>
<MarkdownEditor
id={'test-id'}
text={'some initial text already set'}
placeholderText={'placeholder'}
className={'classname-test'}
readonly={false}
onChange={jest.fn()}
onFocus={jest.fn()}
onBlur={jest.fn()}
/>
</ReduxProvider>,
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<MarkdownEditor
id={'test-id'}
text={'some initial text already set'}
placeholderText={'placeholder'}
className={'classname-test'}
readonly={false}
onChange={jest.fn()}
onFocus={jest.fn()}
onBlur={jest.fn()}
/>
</ReduxProvider>,
))
container = result.container
const previewElement = screen.getByTestId('preview-element')
userEvent.click(previewElement)
fireEvent.keyDown(container, {
key: 'Escape',
code: 'Escape',
keyCode: 27,
charCode: 27,
})
))
fireEvent.click(screen.getByTestId('preview-element'))
fireEvent.keyDown(container, {
key: 'Escape',
code: 'Escape',
keyCode: 27,
charCode: 27,
})
expect(container).toMatchSnapshot()
})

Просмотреть файл

@@ -21,7 +21,7 @@ import {versionProperty} from 'src/store/users'
import VersionMessage from './versionMessage'
jest.mock('src/octoClient')
const mockedOctoClient = mocked(client, true)
const mockedOctoClient = mocked(client)
describe('components/messages/VersionMessage', () => {
beforeEach(() => {
@@ -98,7 +98,7 @@ describe('components/messages/VersionMessage', () => {
expect(container.firstChild).toBeNull()
})
test('show message, click close', () => {
test('show message, click close', async () => {
const me: IUser = {
id: 'user-id-1',
username: 'username_1',
@@ -128,7 +128,7 @@ describe('components/messages/VersionMessage', () => {
render(component)
const buttonElement = screen.getByRole('button', {name: 'Close dialog'})
userEvent.click(buttonElement)
await userEvent.click(buttonElement)
expect(mockedOctoClient.patchUserConfig).toBeCalledWith('user-id-1', {
updatedFields: {
[versionProperty]: 'true',

Просмотреть файл

@@ -21,7 +21,7 @@ describe('components/modal', () => {
))
expect(container).toMatchSnapshot()
})
test('return Modal and close', () => {
test('return Modal and close', async () => {
const onMockedClose = jest.fn()
render(wrapDNDIntl(
<Modal
@@ -31,7 +31,7 @@ describe('components/modal', () => {
</Modal>,
))
const buttonClose = screen.getByRole('button', {name: 'Close'})
userEvent.click(buttonClose)
await userEvent.click(buttonClose)
expect(onMockedClose).toBeCalledTimes(1)
})
test('return Modal on position top', () => {

Просмотреть файл

@@ -39,7 +39,7 @@ exports[`components/onboardingTour/addComments/AddPropertiesTourStep after hover
<div
class="tutorial-tour-tip__body"
>
Add various properties to cards to make them more powerful!
Add various properties to cards to make them more powerful.
</div>
<div
class="tutorial-tour-tip__image"

Просмотреть файл

@@ -5,7 +5,6 @@ import React from 'react'
import {render} from '@testing-library/react'
import {Provider as ReduxProvider} from 'react-redux'
import '@testing-library/jest-dom'
import {TestBlockFactory} from 'src/test/testBlockFactory'
import {Permission} from 'src/constants'

Просмотреть файл

@@ -8,7 +8,6 @@ import {render, waitFor} from '@testing-library/react'
import configureStore from 'redux-mock-store'
import {act} from 'react-dom/test-utils'
import userEvent from '@testing-library/user-event'
@@ -167,9 +166,7 @@ describe('properties/person', () => {
const userProperty = container.querySelector('.Person > div > div:nth-child(1) > div:nth-child(2) > input')
expect(userProperty).not.toBeNull()
act(() => {
userEvent.click(userProperty as Element)
})
await userEvent.click(userProperty as Element)
const userList = container.querySelector('.Person-item')
expect(userList).not.toBeNull()
@@ -273,9 +270,8 @@ describe('properties/person', () => {
const userProperty = container.querySelector('.MultiPerson > div > div:nth-child(1) > div:nth-child(3) > input')
expect(userProperty).not.toBeNull()
act(() => {
userEvent.click(userProperty as Element)
})
await userEvent.click(userProperty as Element)
const userList = container.querySelector('.MultiPerson-item')
expect(userList).not.toBeNull()
expect(container).toMatchSnapshot()
@@ -316,13 +312,11 @@ describe('properties/person', () => {
// opening of the dropdown
const userProperty = container.querySelector('.Person > div > div:nth-child(1) > div:nth-child(2) > input')
expect(userProperty).not.toBeNull()
act(() => {
userEvent.click(userProperty as Element)
})
await userEvent.click(userProperty as Element)
const userList = container.querySelector('.Person-item')
expect(userList).not.toBeNull()
console.log('Text content ' + userList?.textContent)
expect(userList?.textContent).toBe('Me')
expect(container).toMatchSnapshot()
} else {

Просмотреть файл

@@ -4,9 +4,8 @@
import React, {useCallback} from 'react'
import {useIntl} from 'react-intl'
import Select from 'react-select/async'
import {CSSObject} from '@emotion/serialize'
import {ActionMeta} from 'react-select'
import {ActionMeta, StylesConfig} from 'react-select'
import {getSelectBaseStyle} from 'src/theme'
import {IUser} from 'src/user'
@@ -37,31 +36,31 @@ type Props = {
onChange: (items: any, action: ActionMeta<IUser>) => void
}
const selectStyles = {
const selectStyles: StylesConfig<IUser> = {
...getSelectBaseStyle(),
option: (provided: CSSObject, state: {isFocused: boolean}): CSSObject => ({
option: (provided, state: {isFocused: boolean}) => ({
...provided,
background: state.isFocused ? 'rgba(var(--center-channel-color-rgb), 0.1)' : 'rgb(var(--center-channel-bg-rgb))',
color: state.isFocused ? 'rgb(var(--center-channel-color-rgb))' : 'rgb(var(--center-channel-color-rgb))',
padding: '8px',
}),
control: (): CSSObject => ({
control: () => ({
border: 0,
width: '100%',
margin: '0',
}),
valueContainer: (provided: CSSObject): CSSObject => ({
valueContainer: (provided) => ({
...provided,
padding: 'unset',
overflow: 'unset',
}),
singleValue: (provided: CSSObject): CSSObject => ({
singleValue: (provided) => ({
...provided,
position: 'static',
top: 'unset',
transform: 'unset',
}),
menu: (provided: CSSObject): CSSObject => ({
menu: (provided) => ({
...provided,
width: 'unset',
background: 'rgb(var(--center-channel-bg-rgb))',
@@ -80,7 +79,7 @@ const PersonSelector = (props: Props): JSX.Element => {
const boardUsersKey = Object.keys(boardUsersById) ? Utils.hashCode(JSON.stringify(Object.keys(boardUsersById))) : 0
const me = useAppSelector<IUser|null>(getMe)
const formatOptionLabel = (user: any): JSX.Element => {
const formatOptionLabel = (user: IUser): JSX.Element => {
if (!user) {
return <div/>
}

Просмотреть файл

@@ -2,20 +2,25 @@
// See LICENSE.txt for license information.
import React from 'react'
import {render} from '@testing-library/react'
import '@testing-library/jest-dom'
import {render, screen} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import {wrapDNDIntl} from 'src/testUtils'
import 'isomorphic-fetch'
import {IPropertyTemplate, IPropertyOption} from 'src/blocks/board'
import {IPropertyTemplate, IPropertyOption, Board} from 'src/blocks/board'
import {TestBlockFactory} from 'src/test/testBlockFactory'
import {Card} from 'src/blocks/card'
import PropertyValueElement from './propertyValueElement'
describe('components/propertyValueElement', () => {
const board = TestBlockFactory.createBoard()
const card = TestBlockFactory.createCard(board)
let board: Board
let card: Card
beforeEach(() => {
board = TestBlockFactory.createBoard()
card = TestBlockFactory.createCard(board)
})
test('should match snapshot, select', async () => {
const propertyTemplate = board.cardProperties.find((p) => p.id === 'property1')
@@ -127,7 +132,7 @@ describe('components/propertyValueElement', () => {
expect(container).toMatchSnapshot()
})
test('should match snapshot, date, array value', () => {
test('should match snapshot, date, array value', async () => {
const propertyTemplate: IPropertyTemplate = {
id: 'date',
name: 'Date',
@@ -149,7 +154,7 @@ describe('components/propertyValueElement', () => {
expect(container).toMatchSnapshot()
})
test('URL fields should allow cancel', () => {
test('URL fields should allow cancel', async () => {
const propertyTemplate: IPropertyTemplate = {
id: 'property_url',
name: 'Property URL',
@@ -157,6 +162,8 @@ describe('components/propertyValueElement', () => {
options: [],
}
const user = userEvent.setup()
const component = wrapDNDIntl(
<PropertyValueElement
board={board}
@@ -168,14 +175,15 @@ describe('components/propertyValueElement', () => {
)
const {container} = render(component)
const editElement = container.querySelector('.Editable')
expect(editElement).toBeDefined()
userEvent.type(editElement!, 'http://test{esc}')
const editElement = screen.getByRole('textbox')
await user.type(editElement, 'http://test')
expect(editElement).toHaveValue('http://test')
await user.keyboard('{Escape}')
expect(editElement).toHaveValue('')
expect(container).toMatchSnapshot()
})
test('Generic fields should allow cancel', () => {
test('Generic fields should allow cancel', async () => {
const propertyTemplate: IPropertyTemplate = {
id: 'text',
name: 'Generic Text',
@@ -183,6 +191,8 @@ describe('components/propertyValueElement', () => {
options: [],
}
const user = userEvent.setup()
const component = wrapDNDIntl(
<PropertyValueElement
board={board}
@@ -194,10 +204,11 @@ describe('components/propertyValueElement', () => {
)
const {container} = render(component)
const editElement = container.querySelector('.Editable')
expect(editElement).toBeDefined()
userEvent.type(editElement!, 'http://test{esc}')
const editElement = screen.getByRole('textbox')
await user.type(editElement, 'http://test')
expect(editElement).toHaveValue('http://test')
await user.keyboard('{Escape}')
expect(editElement).toHaveValue('')
expect(container).toMatchSnapshot()
})
})

Просмотреть файл

@@ -14,7 +14,7 @@ import {mockStateStore, wrapIntl} from 'src/testUtils'
import RHSChannelBoards from './rhsChannelBoards'
jest.mock('src/octoClient')
const mockedOctoClient = mocked(octoClient, true)
const mockedOctoClient = mocked(octoClient)
describe('components/rhsChannelBoards', () => {
const board1 = createBoard()

Просмотреть файл

@@ -3,14 +3,13 @@
import React from 'react'
import {render} from '@testing-library/react'
import '@testing-library/jest-dom'
import RootPortal from './rootPortal'
describe('components/RootPortal', () => {
beforeEach(() => {
// Quick fix to disregard console error when unmounting a component
console.error = jest.fn()
// console.error = jest.fn()
})
test('should match snapshot', () => {

Просмотреть файл

@@ -119,7 +119,7 @@ exports[`src/components/shareBoard/shareBoard confirm unlinking linked channel 1
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -224,11 +224,11 @@ exports[`src/components/shareBoard/shareBoard confirm unlinking linked channel 1
>
<a
class="shareUrl"
href="http://localhost/undefined/team/team-id/1/1"
href="http://localhost:8065/undefined/team/team-id/1/1"
rel="noreferrer"
target="_blank"
>
http://localhost/undefined/team/team-id/1/1
http://localhost:8065/undefined/team/team-id/1/1
</a>
</div>
<button
@@ -369,7 +369,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Copy l
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -474,11 +474,11 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Copy l
>
<a
class="shareUrl"
href="http://localhost/undefined/team/team-id/1/1"
href="http://localhost:8065/undefined/team/team-id/1/1"
rel="noreferrer"
target="_blank"
>
http://localhost/undefined/team/team-id/1/1
http://localhost:8065/undefined/team/team-id/1/1
</a>
</div>
<button
@@ -619,7 +619,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Copy l
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -724,11 +724,11 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Copy l
>
<a
class="shareUrl"
href="http://localhost/undefined/team/team-id/1/1"
href="http://localhost:8065/undefined/team/team-id/1/1"
rel="noreferrer"
target="_blank"
>
http://localhost/undefined/team/team-id/1/1
http://localhost:8065/undefined/team/team-id/1/1
</a>
</div>
<button
@@ -869,7 +869,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Regene
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -983,11 +983,11 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Regene
>
<a
class="shareUrl"
href="http://localhost/team/team-id/shared/1/1?r=anotherToken"
href="http://localhost:8065/team/team-id/shared/1/1?r=anotherToken"
rel="noreferrer"
target="_blank"
>
http://localhost/team/team-id/shared/1/1?r=anotherToken
http://localhost:8065/team/team-id/shared/1/1?r=anotherToken
</a>
<div
class="octo-tooltip tooltip-top"
@@ -1142,7 +1142,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Select
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -1233,11 +1233,11 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Select
>
<a
class="shareUrl"
href="http://localhost/undefined/team/team-id/1/1"
href="http://localhost:8065/undefined/team/team-id/1/1"
rel="noreferrer"
target="_blank"
>
http://localhost/undefined/team/team-id/1/1
http://localhost:8065/undefined/team/team-id/1/1
</a>
</div>
<button
@@ -1326,7 +1326,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Select
<span
id="aria-context"
>
option username_1 focused, 0 of 2. 8 results available. Use Up and Down to choose options, press Enter to select the currently focused option, press Escape to exit the menu, press Tab to select the option and exit the menu.
option username_1 focused, 1 of 8. 8 results available. Use Up and Down to choose options, press Enter to select the currently focused option, press Escape to exit the menu, press Tab to select the option and exit the menu.
</span>
</span>
<div
@@ -1610,7 +1610,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Select
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -1701,11 +1701,11 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Select
>
<a
class="shareUrl"
href="http://localhost/undefined/team/team-id/1/1"
href="http://localhost:8065/undefined/team/team-id/1/1"
rel="noreferrer"
target="_blank"
>
http://localhost/undefined/team/team-id/1/1
http://localhost:8065/undefined/team/team-id/1/1
</a>
</div>
<button
@@ -1846,7 +1846,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Select
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -1937,11 +1937,11 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Select
>
<a
class="shareUrl"
href="http://localhost/undefined/team/team-id/1/1"
href="http://localhost:8065/undefined/team/team-id/1/1"
rel="noreferrer"
target="_blank"
>
http://localhost/undefined/team/team-id/1/1
http://localhost:8065/undefined/team/team-id/1/1
</a>
</div>
<button
@@ -2030,7 +2030,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Select
<span
id="aria-context"
>
option username_1 focused, 0 of 2. 8 results available. Use Up and Down to choose options, press Enter to select the currently focused option, press Escape to exit the menu, press Tab to select the option and exit the menu.
option username_1 focused, 1 of 8. 8 results available. Use Up and Down to choose options, press Enter to select the currently focused option, press Escape to exit the menu, press Tab to select the option and exit the menu.
</span>
</span>
<div
@@ -2332,7 +2332,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Select
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -2423,11 +2423,11 @@ exports[`src/components/shareBoard/shareBoard return shareBoard and click Select
>
<a
class="shareUrl"
href="http://localhost/undefined/team/team-id/1/1"
href="http://localhost:8065/undefined/team/team-id/1/1"
rel="noreferrer"
target="_blank"
>
http://localhost/undefined/team/team-id/1/1
http://localhost:8065/undefined/team/team-id/1/1
</a>
</div>
<button
@@ -2471,7 +2471,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard template and cli
<h1
class="dialog-title"
>
Share Template
Share template
</h1>
</div>
<div
@@ -2568,7 +2568,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard template and cli
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -2656,7 +2656,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard template and cli
<h1
class="dialog-title"
>
Share Template
Share template
</h1>
</div>
<div
@@ -2701,7 +2701,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard template and cli
<span
id="aria-context"
>
option username_1 focused, 0 of 1. 4 results available. Use Up and Down to choose options, press Enter to select the currently focused option, press Escape to exit the menu, press Tab to select the option and exit the menu.
option username_1 focused, 1 of 4. 4 results available. Use Up and Down to choose options, press Enter to select the currently focused option, press Escape to exit the menu, press Tab to select the option and exit the menu.
</span>
</span>
<div
@@ -2889,7 +2889,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard template and cli
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -3074,7 +3074,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoard, and click switc
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -3188,11 +3188,11 @@ exports[`src/components/shareBoard/shareBoard return shareBoard, and click switc
>
<a
class="shareUrl"
href="http://localhost/team/team-id/shared/1/1?r=oneToken"
href="http://localhost:8065/team/team-id/shared/1/1?r=oneToken"
rel="noreferrer"
target="_blank"
>
http://localhost/team/team-id/shared/1/1?r=oneToken
http://localhost:8065/team/team-id/shared/1/1?r=oneToken
</a>
<div
class="octo-tooltip tooltip-top"
@@ -3347,7 +3347,7 @@ exports[`src/components/shareBoard/shareBoard return shareBoardComponent and cli
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -3461,11 +3461,11 @@ exports[`src/components/shareBoard/shareBoard return shareBoardComponent and cli
>
<a
class="shareUrl"
href="http://localhost/team/team-id/shared/1/1?r=aToken"
href="http://localhost:8065/team/team-id/shared/1/1?r=aToken"
rel="noreferrer"
target="_blank"
>
http://localhost/team/team-id/shared/1/1?r=aToken
http://localhost:8065/team/team-id/shared/1/1?r=aToken
</a>
<div
class="octo-tooltip tooltip-top"
@@ -3620,7 +3620,7 @@ exports[`src/components/shareBoard/shareBoard should match snapshot 1`] = `
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -3725,11 +3725,11 @@ exports[`src/components/shareBoard/shareBoard should match snapshot 1`] = `
>
<a
class="shareUrl"
href="http://localhost/undefined/team/team-id/1/1"
href="http://localhost:8065/undefined/team/team-id/1/1"
rel="noreferrer"
target="_blank"
>
http://localhost/undefined/team/team-id/1/1
http://localhost:8065/undefined/team/team-id/1/1
</a>
</div>
<button
@@ -3870,7 +3870,7 @@ exports[`src/components/shareBoard/shareBoard should match snapshot with sharing
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -3975,11 +3975,11 @@ exports[`src/components/shareBoard/shareBoard should match snapshot with sharing
>
<a
class="shareUrl"
href="http://localhost/undefined/team/team-id/1/1"
href="http://localhost:8065/undefined/team/team-id/1/1"
rel="noreferrer"
target="_blank"
>
http://localhost/undefined/team/team-id/1/1
http://localhost:8065/undefined/team/team-id/1/1
</a>
</div>
<button
@@ -4120,7 +4120,7 @@ exports[`src/components/shareBoard/shareBoard should match snapshot with sharing
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -4225,11 +4225,11 @@ exports[`src/components/shareBoard/shareBoard should match snapshot with sharing
>
<a
class="shareUrl"
href="http://localhost/undefined/team/team-id/1/1"
href="http://localhost:8065/undefined/team/team-id/1/1"
rel="noreferrer"
target="_blank"
>
http://localhost/undefined/team/team-id/1/1
http://localhost:8065/undefined/team/team-id/1/1
</a>
</div>
<button
@@ -4273,7 +4273,7 @@ exports[`src/components/shareBoard/shareBoard should match snapshot, with templa
<h1
class="dialog-title"
>
Share Template
Share template
</h1>
</div>
<div
@@ -4370,7 +4370,7 @@ exports[`src/components/shareBoard/shareBoard should match snapshot, with templa
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>

Просмотреть файл

@@ -15,7 +15,7 @@ exports[`src/components/shareBoard/teamPermissionsRow should match snapshot in p
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>
@@ -228,7 +228,7 @@ exports[`src/components/shareBoard/teamPermissionsRow should match snapshot in t
class="ml-3"
>
<strong>
Everyone at Test Team Team
Everyone at Test Team team
</strong>
</div>
</div>

Просмотреть файл

@@ -17,13 +17,11 @@ import client from 'src/octoClient'
import ChannelPermissionsRow from './channelPermissionsRow'
jest.useFakeTimers()
const boardId = '1'
jest.mock('src/octoClient')
const mockedOctoClient = mocked(client, true)
const mockedOctoClient = mocked(client)
const board = TestBlockFactory.createBoard()
board.id = boardId
@@ -126,7 +124,7 @@ describe('src/components/shareBoard/channelPermissionsRow', () => {
const buttonElement = container?.querySelector('.user-item__button')
expect(buttonElement).toBeDefined()
userEvent.click(buttonElement!)
await userEvent.click(buttonElement!)
expect(container).toMatchSnapshot()
})
@@ -173,7 +171,7 @@ describe('src/components/shareBoard/channelPermissionsRow', () => {
const buttonElement = container?.querySelector('.user-item__button')
expect(buttonElement).toBeDefined()
userEvent.click(buttonElement!)
await userEvent.click(buttonElement!)
expect(container).toMatchSnapshot()
})
@@ -204,7 +202,7 @@ describe('src/components/shareBoard/channelPermissionsRow', () => {
const buttonElement = container?.querySelector('.user-item__button')
expect(buttonElement).toBeDefined()
userEvent.click(buttonElement!)
await userEvent.click(buttonElement!)
expect(container).toMatchSnapshot()
})

Просмотреть файл

@@ -19,8 +19,6 @@ import {Utils} from 'src/utils'
import ShareBoard from './shareBoard'
jest.useFakeTimers()
const boardId = '1'
const workspaceId: string|undefined = boardId
const viewId = boardId
@@ -29,8 +27,8 @@ const teamId = 'team-id'
jest.mock('src/octoClient')
jest.mock('src/utils')
const mockedOctoClient = mocked(client, true)
const mockedUtils = mocked(Utils, true)
const mockedOctoClient = mocked(client)
const mockedUtils = mocked(Utils)
let params = {}
jest.mock('react-router', () => {
@@ -40,7 +38,7 @@ jest.mock('react-router', () => {
...originalModule,
useRouteMatch: jest.fn(() => {
return {
url: 'http://localhost/',
url: 'http://localhost:8065/',
path: '/',
params,
isExact: true,
@@ -49,145 +47,149 @@ jest.mock('react-router', () => {
}
})
const board = TestBlockFactory.createBoard()
board.id = boardId
board.teamId = teamId
board.cardProperties = [
{
id: 'property1',
name: 'Property 1',
type: 'text',
options: [
{
id: 'value1',
value: 'value 1',
color: 'propColorBrown',
},
],
},
{
id: 'property2',
name: 'Property 2',
type: 'select',
options: [
{
id: 'value2',
value: 'value 2',
color: 'propColorBlue',
},
],
},
]
board.channelId = 'channel_1'
const activeView = TestBlockFactory.createBoardView(board)
activeView.id = 'view1'
activeView.fields.hiddenOptionIds = []
activeView.fields.visiblePropertyIds = ['property1']
activeView.fields.visibleOptionIds = ['value1']
const fakeBoard = {id: board.id}
activeView.boardId = fakeBoard.id
const card1 = TestBlockFactory.createCard(board)
card1.id = 'card1'
card1.title = 'card-1'
card1.boardId = fakeBoard.id
const card2 = TestBlockFactory.createCard(board)
card2.id = 'card2'
card2.title = 'card-2'
card2.boardId = fakeBoard.id
const card3 = TestBlockFactory.createCard(board)
card3.id = 'card3'
card3.title = 'card-3'
card3.boardId = fakeBoard.id
const me: IUser = {
id: 'user-id-1',
username: 'username_1',
email: '',
nickname: '',
firstname: '',
lastname: '',
props: {},
create_at: 0,
update_at: 0,
is_bot: false,
is_guest: false,
roles: 'system_user',
}
const categoryAttribute1 = TestBlockFactory.createCategoryBoards()
categoryAttribute1.name = 'Category 1'
categoryAttribute1.boardMetadata = [{boardID: board.id, hidden: false}]
describe('src/components/shareBoard/shareBoard', () => {
const w = (window as any)
const oldBaseURL = w.baseURL
const state = {
teams: {
current: {id: teamId, title: 'Test Team'},
},
users: {
me,
boardUsers: {[me.id]: me},
blockSubscriptions: [],
},
boards: {
current: board.id,
boards: {
[board.id]: board,
},
templates: [],
membersInBoards: {
[board.id]: {},
},
myBoardMemberships: {
[board.id]: {userId: me.id, schemeAdmin: true},
},
},
globalTemplates: {
value: [],
},
views: {
views: {
[activeView.id]: activeView,
},
current: activeView.id,
},
cards: {
templates: [],
cards: [card1, card2, card3],
},
searchText: {},
clientConfig: {
value: {
telemetry: true,
telemetryid: 'telemetry',
enablePublicSharedBoards: true,
teammateNameDisplay: 'username',
featureFlags: {},
},
},
contents: {
contents: {},
},
comments: {
comments: {},
},
sidebar: {
categoryAttributes: [
categoryAttribute1,
const board = TestBlockFactory.createBoard()
board.id = boardId
board.teamId = teamId
board.cardProperties = [
{
id: 'property1',
name: 'Property 1',
type: 'text',
options: [
{
id: 'value1',
value: 'value 1',
color: 'propColorBrown',
},
],
},
{
id: 'property2',
name: 'Property 2',
type: 'select',
options: [
{
id: 'value2',
value: 'value 2',
color: 'propColorBlue',
},
],
},
]
board.channelId = 'channel_1'
const activeView = TestBlockFactory.createBoardView(board)
activeView.id = 'view1'
activeView.fields.hiddenOptionIds = []
activeView.fields.visiblePropertyIds = ['property1']
activeView.fields.visibleOptionIds = ['value1']
const fakeBoard = {id: board.id}
activeView.boardId = fakeBoard.id
const card1 = TestBlockFactory.createCard(board)
card1.id = 'card1'
card1.title = 'card-1'
card1.boardId = fakeBoard.id
const card2 = TestBlockFactory.createCard(board)
card2.id = 'card2'
card2.title = 'card-2'
card2.boardId = fakeBoard.id
const card3 = TestBlockFactory.createCard(board)
card3.id = 'card3'
card3.title = 'card-3'
card3.boardId = fakeBoard.id
const me: IUser = {
id: 'user-id-1',
username: 'username_1',
email: '',
nickname: '',
firstname: '',
lastname: '',
props: {},
create_at: 0,
update_at: 0,
is_bot: false,
is_guest: false,
roles: 'system_user',
}
const store = mockStateStore([thunk], state)
const categoryAttribute1 = TestBlockFactory.createCategoryBoards()
categoryAttribute1.name = 'Category 1'
categoryAttribute1.boardMetadata = [{boardID: board.id, hidden: false}]
let state: Parameters<typeof mockStateStore>[1]
let store: ReturnType<typeof mockStateStore>
beforeEach(() => {
jest.clearAllMocks()
state = {
teams: {
current: {id: teamId, title: 'Test Team'},
},
users: {
me,
boardUsers: {[me.id]: me},
blockSubscriptions: [],
},
boards: {
current: board.id,
boards: {
[board.id]: board,
},
templates: [],
membersInBoards: {
[board.id]: {},
},
myBoardMemberships: {
[board.id]: {userId: me.id, schemeAdmin: true},
},
},
globalTemplates: {
value: [],
},
views: {
views: {
[activeView.id]: activeView,
},
current: activeView.id,
},
cards: {
templates: [],
cards: [card1, card2, card3],
},
searchText: {},
clientConfig: {
value: {
telemetry: true,
telemetryid: 'telemetry',
enablePublicSharedBoards: true,
teammateNameDisplay: 'username',
featureFlags: {},
},
},
contents: {
contents: {},
},
comments: {
comments: {},
},
sidebar: {
categoryAttributes: [
categoryAttribute1,
],
},
}
store = mockStateStore([thunk], state)
// mockedUtils.buildURL.mockImplementation((path) => (w.baseURL || '') + path)
@@ -290,8 +292,8 @@ describe('src/components/shareBoard/shareBoard', () => {
const copyLinkElement = screen.getByTitle('Copy link')
expect(copyLinkElement).toBeDefined()
act(() => {
userEvent.click(copyLinkElement!)
await act(async () => {
await userEvent.click(copyLinkElement!)
})
expect(mockedUtils.copyTextToClipboard).toBeCalledTimes(1)
@@ -312,20 +314,14 @@ describe('src/components/shareBoard/shareBoard', () => {
}
mockedOctoClient.getSharing.mockResolvedValue(sharing)
let container
await act(async () => {
const result = render(
wrapDNDIntl(
<ReduxProvider store={store}>
<ShareBoard
onClose={jest.fn()}
enableSharedBoards={true}
/>
</ReduxProvider>),
{wrapper: MemoryRouter},
)
container = result.container
})
const {container} = render(wrapDNDIntl(
<ReduxProvider store={store}>
<ShareBoard
onClose={jest.fn()}
enableSharedBoards={true}
/>
</ReduxProvider>
), {wrapper: MemoryRouter})
sharing.token = 'anotherToken'
mockedUtils.createGuid.mockReturnValue('anotherToken')
@@ -334,17 +330,12 @@ describe('src/components/shareBoard/shareBoard', () => {
const publishButton = screen.getByRole('button', {name: 'Publish'})
expect(publishButton).toBeDefined()
userEvent.click(publishButton)
await act(async () => {
jest.runOnlyPendingTimers()
})
await act(() => userEvent.click(publishButton))
const regenerateTokenElement = screen.getByRole('button', {name: 'Regenerate token'})
expect(regenerateTokenElement).toBeDefined()
userEvent.click(regenerateTokenElement)
await act(async () => {
jest.runOnlyPendingTimers()
})
await act(() => userEvent.click(regenerateTokenElement))
expect(mockedOctoClient.setSharing).toBeCalledTimes(1)
expect(container).toMatchSnapshot()
})
@@ -373,15 +364,12 @@ describe('src/components/shareBoard/shareBoard', () => {
const publishButton = screen.getByRole('button', {name: 'Publish'})
expect(publishButton).toBeDefined()
userEvent.click(publishButton)
await act(async () => {
jest.runOnlyPendingTimers()
})
await userEvent.click(publishButton)
const switchElement = container?.querySelector('.Switch')
expect(switchElement).toBeDefined()
await act(async () => {
userEvent.click(switchElement!)
await userEvent.click(switchElement!)
})
expect(mockedOctoClient.setSharing).toBeCalledTimes(1)
@@ -397,48 +385,41 @@ describe('src/components/shareBoard/shareBoard', () => {
}
mockedOctoClient.getSharing.mockResolvedValue(sharing)
mockedUtils.createGuid.mockReturnValue('aToken')
let container: Element | undefined
await act(async () => {
const result = render(
wrapDNDIntl(
<ReduxProvider store={store}>
<ShareBoard
onClose={jest.fn()}
enableSharedBoards={true}
/>
</ReduxProvider>),
{wrapper: MemoryRouter},
)
container = result.container
mockedOctoClient.getSharing.mockResolvedValue({
id: boardId,
enabled: true,
token: 'aToken',
})
const publishButton = screen.getByRole('button', {name: 'Publish'})
expect(publishButton).toBeDefined()
userEvent.click(publishButton)
jest.runOnlyPendingTimers()
const switchElement = container?.querySelector('.Switch')
expect(switchElement).toBeDefined()
userEvent.click(switchElement!)
jest.runOnlyPendingTimers()
result.rerender(
wrapDNDIntl(
<ReduxProvider store={store}>
<ShareBoard
onClose={jest.fn()}
enableSharedBoards={true}
/>
</ReduxProvider>))
const result = render(wrapDNDIntl(
<ReduxProvider store={store}>
<ShareBoard
onClose={jest.fn()}
enableSharedBoards={true}
/>
</ReduxProvider>
),{wrapper: MemoryRouter})
mockedOctoClient.getSharing.mockResolvedValue({
id: boardId,
enabled: true,
token: 'aToken',
})
const publishButton = screen.getByRole('button', {name: 'Publish'})
expect(publishButton).toBeDefined()
await act(() => userEvent.click(publishButton))
const switchElement = result.container?.querySelector('.Switch')
expect(switchElement).toBeDefined()
await act(() => userEvent.click(switchElement!))
result.rerender(wrapDNDIntl(
<ReduxProvider store={store}>
<ShareBoard
onClose={jest.fn()}
enableSharedBoards={true}
/>
</ReduxProvider>
))
expect(mockedOctoClient.setSharing).toBeCalledTimes(1)
expect(mockedOctoClient.getSharing).toBeCalledTimes(2)
expect(mockedUtils.createGuid).toBeCalledTimes(1)
expect(container).toMatchSnapshot()
expect(result.container).toMatchSnapshot()
})
test('should match snapshot with sharing and subpath', async () => {
@@ -509,7 +490,7 @@ describe('src/components/shareBoard/shareBoard', () => {
expect(selectElement).toBeDefined()
await act(async () => {
userEvent.click(selectElement!)
await userEvent.click(selectElement!)
})
expect(container).toMatchSnapshot()
@@ -558,7 +539,7 @@ describe('src/components/shareBoard/shareBoard', () => {
expect(selectElement).toBeDefined()
await act(async () => {
userEvent.click(selectElement!)
await userEvent.click(selectElement!)
})
expect(container).toMatchSnapshot()
@@ -591,15 +572,15 @@ describe('src/components/shareBoard/shareBoard', () => {
const channelMenuBtn = container!.querySelector('.user-item.channel-item .MenuWrapper')
expect(channelMenuBtn).not.toBeNull()
userEvent.click(channelMenuBtn as Element)
await userEvent.click(channelMenuBtn as Element)
const unlinkOption = screen.getByText('Unlink')
expect(unlinkOption).not.toBeNull()
userEvent.click(unlinkOption)
await userEvent.click(unlinkOption)
const unlinkConfirmationBtn = screen.getByText('Unlink channel')
expect(unlinkConfirmationBtn).not.toBeNull()
userEvent.click(unlinkConfirmationBtn)
await userEvent.click(unlinkConfirmationBtn)
expect(mockedOctoClient.patchBoard).toBeCalled()
@@ -685,9 +666,7 @@ describe('src/components/shareBoard/shareBoard', () => {
const selectElement = screen.getByText('Search for people')
expect(selectElement).toBeDefined()
await act(async () => {
userEvent.click(selectElement!)
})
await act(() => userEvent.click(selectElement!))
expect(mockedOctoClient.searchUserChannels).not.toBeCalled()
expect(container).toMatchSnapshot()

Просмотреть файл

@@ -6,7 +6,7 @@ import React, {useState, useEffect} from 'react'
import {useIntl, FormattedMessage} from 'react-intl'
import {generatePath, useRouteMatch} from 'react-router-dom'
import Select from 'react-select/async'
import {CSSObject} from '@emotion/serialize'
import {StylesConfig} from 'react-select'
import {useAppSelector} from 'src/store/hooks'
import {getCurrentBoard, getCurrentBoardMembers} from 'src/store/boards'
@@ -26,7 +26,7 @@ import {BoardMember, createBoard, MemberRole} from 'src/blocks/board'
import client from 'src/octoClient'
import Dialog from 'src/components/dialog'
import ConfirmationDialog from 'src/components/confirmationDialogBox'
import {IUser} from 'src/user'
import {IUser, isUser} from 'src/user'
import Switch from 'src/widgets/switch'
import Button from 'src/widgets/buttons/button'
import {sendFlashMessage} from 'src/components/flashMessages'
@@ -58,11 +58,11 @@ type Props = {
enableSharedBoards: boolean
}
const baseStyles = getSelectBaseStyle()
const baseStyles = getSelectBaseStyle<IUser | Channel>()
const styles = {
const styles: StylesConfig<IUser | Channel> = {
...baseStyles,
control: (): CSSObject => ({
control: () => ({
border: 0,
width: '100%',
height: '100%',
@@ -70,7 +70,7 @@ const styles = {
display: 'flex',
flexDirection: 'row',
}),
menu: (provided: CSSObject): CSSObject => ({
menu: (provided) => ({
...provided,
minWidth: '100%',
width: 'max-content',
@@ -78,8 +78,8 @@ const styles = {
left: '0',
marginBottom: '0',
}),
singleValue: (provided: CSSObject): CSSObject => ({
...baseStyles.singleValue(provided),
singleValue: (...props) => ({
...baseStyles.singleValue?.(...props),
opacity: '0.8',
fontSize: '12px',
right: '0',
@@ -344,7 +344,7 @@ export default function ShareBoardDialog(props: Props): JSX.Element {
<div className='share-input__container'>
<div className='share-input'>
<SearchIcon/>
<Select
<Select<IUser | Channel>
styles={styles}
value={selectedUser}
className={'userSearchInput'}
@@ -377,19 +377,19 @@ export default function ShareBoardDialog(props: Props): JSX.Element {
components={{DropdownIndicator: () => null, IndicatorSeparator: () => null}}
defaultOptions={true}
formatOptionLabel={formatOptionLabel}
getOptionValue={(u) => u.id}
getOptionLabel={(u: IUser|Channel) => (u as IUser).username || (u as Channel).display_name}
getOptionValue={({id}) => id}
getOptionLabel={(x) => isUser(x) ? x.username : x.display_name}
isMulti={false}
placeholder={board.isTemplate ?
intl.formatMessage({id: 'ShareTemplate.searchPlaceholder', defaultMessage: 'Search for people'}) :
intl.formatMessage({id: 'ShareBoard.searchPlaceholder', defaultMessage: 'Search for people and channels'})
}
onChange={(newValue) => {
if (newValue && (newValue as IUser).username) {
addUser(newValue as IUser)
if (newValue && isUser(newValue)) {
addUser(newValue)
setSelectedUser(null)
} else if (newValue) {
onLinkBoard(newValue as Channel)
onLinkBoard(newValue)
}
}}
/>

Просмотреть файл

@@ -1,6 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {act, render} from '@testing-library/react'
import {render} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import {Provider as ReduxProvider} from 'react-redux'
import thunk from 'redux-thunk'
@@ -16,8 +16,6 @@ import {MemberRole} from 'src/blocks/board'
import TeamPermissionsRow from './teamPermissionsRow'
jest.useFakeTimers()
const boardId = '1'
jest.mock('src/utils')
@@ -73,28 +71,23 @@ describe('src/components/shareBoard/teamPermissionsRow', () => {
})
test('should match snapshot in plugin mode', async () => {
let container: Element | undefined
const store = mockStateStore([thunk], state)
await act(async () => {
const result = render(
wrapDNDIntl(
<ReduxProvider store={store}>
<TeamPermissionsRow/>
</ReduxProvider>),
{wrapper: MemoryRouter},
)
container = result.container
})
const {container} = render(
wrapDNDIntl(
<ReduxProvider store={store}>
<TeamPermissionsRow/>
</ReduxProvider>),
{wrapper: MemoryRouter},
)
const buttonElement = container?.querySelector('.user-item__button')
expect(buttonElement).toBeDefined()
userEvent.click(buttonElement!)
await userEvent.click(buttonElement!)
expect(container).toMatchSnapshot()
})
test('should match snapshot in template', async () => {
let container: Element | undefined
const testState = {
...state,
boards: {
@@ -106,20 +99,17 @@ describe('src/components/shareBoard/teamPermissionsRow', () => {
},
}
const store = mockStateStore([thunk], testState)
await act(async () => {
const result = render(
wrapDNDIntl(
<ReduxProvider store={store}>
<TeamPermissionsRow/>
</ReduxProvider>),
{wrapper: MemoryRouter},
)
container = result.container
})
const {container} = render(
wrapDNDIntl(
<ReduxProvider store={store}>
<TeamPermissionsRow/>
</ReduxProvider>),
{wrapper: MemoryRouter},
)
const buttonElement = container?.querySelector('.user-item__button')
expect(buttonElement).toBeDefined()
userEvent.click(buttonElement!)
await userEvent.click(buttonElement!)
expect(container).toMatchSnapshot()
})

Просмотреть файл

@@ -16,8 +16,6 @@ import {mockStateStore, wrapDNDIntl} from 'src/testUtils'
import UserPermissionsRow from './userPermissionsRow'
jest.useFakeTimers()
const boardId = '1'
jest.mock('src/utils')
@@ -94,7 +92,7 @@ describe('src/components/shareBoard/userPermissionsRow', () => {
const buttonElement = container?.querySelector('.user-item__button')
expect(buttonElement).toBeDefined()
userEvent.click(buttonElement!)
await userEvent.click(buttonElement!)
expect(container).toMatchSnapshot()
})
@@ -132,7 +130,7 @@ describe('src/components/shareBoard/userPermissionsRow', () => {
const buttonElement = container?.querySelector('.user-item__button')
expect(buttonElement).toBeDefined()
userEvent.click(buttonElement!)
await userEvent.click(buttonElement!)
expect(container).toMatchSnapshot()
})

Просмотреть файл

@@ -32,11 +32,11 @@ exports[`components/sidebar/RegistrationLink renders with signupToken in URL que
>
<a
class="shareUrl"
href="http://localhost/register?t=abc123"
href="http://localhost:8065/register?t=abc123"
rel="noreferrer"
target="_blank"
>
http://localhost/register?t=abc123
http://localhost:8065/register?t=abc123
</a>
<button
class="Button filled size--small"

Просмотреть файл

@@ -44,7 +44,7 @@ exports[`components/sidebarSidebar dont show hidden boards 1`] = `
/>
<div>
<span>
Find Boards
Find boards
</span>
</div>
</div>
@@ -184,7 +184,7 @@ exports[`components/sidebarSidebar should assign default category if current boa
/>
<div>
<span>
Find Boards
Find boards
</span>
</div>
</div>
@@ -379,7 +379,7 @@ exports[`components/sidebarSidebar shouldnt do any category assignment is board
/>
<div>
<span>
Find Boards
Find boards
</span>
</div>
</div>
@@ -729,7 +729,7 @@ exports[`components/sidebarSidebar sidebar hidden 1`] = `
/>
<div>
<span>
Find Boards
Find boards
</span>
</div>
</div>
@@ -962,7 +962,7 @@ exports[`components/sidebarSidebar some categories hidden 1`] = `
/>
<div>
<span>
Find Boards
Find boards
</span>
</div>
</div>

Просмотреть файл

@@ -22,7 +22,7 @@ import octoClient from 'src/octoClient'
import Sidebar from './sidebar'
jest.mock('src/octoClient')
const mockedOctoClient = mocked(octoClient, true)
const mockedOctoClient = mocked(octoClient)
beforeAll(() => {
mockMatchMedia({matches: true})
@@ -48,7 +48,7 @@ describe('components/sidebarSidebar', () => {
defaultCategory.name = 'Boards'
defaultCategory.boardMetadata = []
test('sidebar hidden', () => {
test('sidebar hidden', async () => {
const store = mockStore({
teams: {
current: {id: 'team-id'},
@@ -101,7 +101,7 @@ describe('components/sidebarSidebar', () => {
const hideSidebar = container.querySelector('button > .HideSidebarIcon')
expect(hideSidebar).toBeDefined()
userEvent.click(hideSidebar as Element)
await userEvent.click(hideSidebar as Element)
expect(container).toMatchSnapshot()
const showSidebar = container.querySelector('button > .ShowSidebarIcon')

Просмотреть файл

@@ -70,7 +70,7 @@ describe('components/sidebarBoardItem', () => {
},
}
test('sidebar board item', () => {
test('sidebar board item', async () => {
const mockStore = configureStore([])
const store = mockStore(state)
@@ -93,7 +93,7 @@ describe('components/sidebarBoardItem', () => {
const {container} = render(component)
const elementMenuWrapper = container.querySelector('.SidebarBoardItem div.MenuWrapper')
expect(elementMenuWrapper).not.toBeNull()
userEvent.click(elementMenuWrapper!)
await userEvent.click(elementMenuWrapper!)
expect(container).toMatchSnapshot()
})
@@ -122,7 +122,7 @@ describe('components/sidebarBoardItem', () => {
expect(container).toMatchSnapshot()
})
test('sidebar board item for guest', () => {
test('sidebar board item for guest', async () => {
const mockStore = configureStore([])
const store = mockStore({...state, users: {me: {is_guest: true}}})
@@ -145,7 +145,7 @@ describe('components/sidebarBoardItem', () => {
const {container} = render(component)
const elementMenuWrapper = container.querySelector('.SidebarBoardItem div.MenuWrapper')
expect(elementMenuWrapper).not.toBeNull()
userEvent.click(elementMenuWrapper!)
await userEvent.click(elementMenuWrapper!)
expect(container).toMatchSnapshot()
})
})

Просмотреть файл

@@ -84,7 +84,7 @@ describe('components/sidebarCategory', () => {
},
}
test('sidebar call hideSidebar', () => {
test('sidebar call hideSidebar', async () => {
const mockStore = configureStore([])
const store = mockStore(state)
@@ -107,11 +107,11 @@ describe('components/sidebarCategory', () => {
// testing collapsed state of category
const subItems = container.querySelectorAll('.category')
expect(subItems).toBeDefined()
userEvent.click(subItems[0] as Element)
await userEvent.click(subItems[0] as Element)
expect(container).toMatchSnapshot()
})
test('sidebar collapsed without active board', () => {
test('sidebar collapsed without active board', async () => {
const mockStore = configureStore([])
const store = mockStore(state)
@@ -132,11 +132,11 @@ describe('components/sidebarCategory', () => {
const subItems = container.querySelectorAll('.category-title')
expect(subItems).toBeDefined()
userEvent.click(subItems[0] as Element)
await userEvent.click(subItems[0] as Element)
expect(container).toMatchSnapshot()
})
test('sidebar collapsed with active board in it', () => {
test('sidebar collapsed with active board in it', async () => {
const mockStore = configureStore([])
const store = mockStore(state)
@@ -158,11 +158,11 @@ describe('components/sidebarCategory', () => {
const subItems = container.querySelectorAll('.category-title')
expect(subItems).toBeDefined()
userEvent.click(subItems[0] as Element)
await userEvent.click(subItems[0] as Element)
expect(container).toMatchSnapshot()
})
test('sidebar template close self', () => {
test('sidebar template close self', async () => {
const mockStore = configureStore([])
const store = mockStore(state)
@@ -189,11 +189,11 @@ describe('components/sidebarCategory', () => {
// testing collapsed state of category
const subItems = container.querySelectorAll('.subitem')
expect(subItems).toBeDefined()
userEvent.click(subItems[0] as Element)
await userEvent.click(subItems[0] as Element)
expect(mockTemplateClose).toBeCalled()
})
test('sidebar template close other', () => {
test('sidebar template close other', async () => {
const mockStore = configureStore([])
const store = mockStore(state)
@@ -220,7 +220,7 @@ describe('components/sidebarCategory', () => {
// testing collapsed state of category
const subItems = container.querySelectorAll('.category-title')
expect(subItems).toBeDefined()
userEvent.click(subItems[0] as Element)
await userEvent.click(subItems[0] as Element)
expect(mockTemplateClose).not.toBeCalled()
})
})

Просмотреть файл

@@ -20,7 +20,7 @@ import TelemetryClient, {TelemetryCategory, TelemetryActions} from 'src/telemetr
import SidebarSettingsMenu from './sidebarSettingsMenu'
jest.mock('src/telemetry/telemetryClient')
const mockedTelemetry = mocked(TelemetryClient, true)
const mockedTelemetry = mocked(TelemetryClient)
describe('components/sidebar/SidebarSettingsMenu', () => {
const mockStore = configureStore([])
@@ -53,7 +53,7 @@ describe('components/sidebar/SidebarSettingsMenu', () => {
expect(container).toMatchSnapshot()
})
test('settings menu open should match snapshot', () => {
test('settings menu open should match snapshot', async () => {
const component = wrapIntl(
<ReduxProvider store={store}>
<SidebarSettingsMenu activeTheme={defaultThemeName}/>
@@ -61,11 +61,11 @@ describe('components/sidebar/SidebarSettingsMenu', () => {
)
const {container} = render(component)
userEvent.click(container.querySelector('.menu-entry') as Element)
await userEvent.click(container.querySelector('.menu-entry') as Element)
expect(container).toMatchSnapshot()
})
test('theme menu open should match snapshot', () => {
test('theme menu open should match snapshot', async () => {
const component = wrapIntl(
<ReduxProvider store={store}>
<SidebarSettingsMenu activeTheme={defaultThemeName}/>
@@ -73,16 +73,12 @@ describe('components/sidebar/SidebarSettingsMenu', () => {
)
const {container} = render(component)
act(() => {
userEvent.click(container.querySelector('.menu-entry') as Element)
})
act(() => {
userEvent.hover(container.querySelector('#theme') as Element)
})
await act(() => userEvent.click(container.querySelector('.menu-entry') as Element))
await act(() => userEvent.hover(container.querySelector('#theme') as Element))
expect(container).toMatchSnapshot()
})
test('languages menu open should match snapshot', () => {
test('languages menu open should match snapshot', async () => {
const component = wrapIntl(
<ReduxProvider store={store}>
<SidebarSettingsMenu activeTheme={defaultThemeName}/>
@@ -90,16 +86,12 @@ describe('components/sidebar/SidebarSettingsMenu', () => {
)
const {container} = render(component)
act(() => {
userEvent.click(container.querySelector('.menu-entry') as Element)
})
act(() => {
userEvent.hover(container.querySelector('#lang') as Element)
})
await act(() => userEvent.click(container.querySelector('.menu-entry') as Element))
await act(() => userEvent.hover(container.querySelector('#lang') as Element))
expect(container).toMatchSnapshot()
})
test('imports menu open should match snapshot', () => {
test('imports menu open should match snapshot', async () => {
window.open = jest.fn()
const component = wrapIntl(
<ReduxProvider store={store}>
@@ -108,15 +100,11 @@ describe('components/sidebar/SidebarSettingsMenu', () => {
)
const {container} = render(component)
act(() => {
userEvent.click(container.querySelector('.menu-entry') as Element)
})
act(() => {
userEvent.hover(container.querySelector('#import') as Element)
})
await act(() => userEvent.click(container.querySelector('.menu-entry') as Element))
await act(() => userEvent.hover(container.querySelector('#import') as Element))
expect(container).toMatchSnapshot()
userEvent.click(container.querySelector('[aria-label="Asana"]') as Element)
await userEvent.click(container.querySelector('[aria-label="Asana"]') as Element)
expect(mockedTelemetry.trackEvent).toBeCalledWith(TelemetryCategory, TelemetryActions.ImportAsana)
})
})

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@@ -325,7 +325,7 @@ exports[`should match snapshot, no groups 1`] = `
</button>
<span
class="Label empty "
title="Items with an empty Property 1 property will go here. This column cannot be removed."
title="Items with an empty Property 1 property will go here. This column can't be removed."
>
No Property 1
</span>

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше