mirror of
https://github.com/strapi/strapi.git
synced 2025-09-22 14:59:07 +00:00
Fix tests
Signed-off-by: HichamELBSI <elabbassih@gmail.com>
This commit is contained in:
parent
cfb417689e
commit
3f23b6c01f
@ -187,7 +187,7 @@ const Wysiwyg = ({
|
|||||||
|
|
||||||
Wysiwyg.defaultProps = {
|
Wysiwyg.defaultProps = {
|
||||||
description: null,
|
description: null,
|
||||||
disabled: true,
|
disabled: false,
|
||||||
error: '',
|
error: '',
|
||||||
labelAction: undefined,
|
labelAction: undefined,
|
||||||
placeholder: null,
|
placeholder: null,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { IntlProvider } from 'react-intl';
|
import { IntlProvider } from 'react-intl';
|
||||||
import { render, waitFor, fireEvent } from '@testing-library/react';
|
import { render, waitFor, fireEvent } from '@testing-library/react';
|
||||||
import { lightTheme, ThemeProvider } from '@strapi/design-system';
|
import { ThemeProvider } from '@strapi/design-system/ThemeProvider';
|
||||||
|
import { lightTheme } from '@strapi/design-system/themes';
|
||||||
import Wysiwyg from '../index';
|
import Wysiwyg from '../index';
|
||||||
|
|
||||||
jest.mock('@strapi/helper-plugin', () => ({
|
jest.mock('@strapi/helper-plugin', () => ({
|
||||||
@ -39,6 +40,7 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
name="rich-text"
|
name="rich-text"
|
||||||
intlLabel={{ id: 'hello world', defaultMessage: 'hello world' }}
|
intlLabel={{ id: 'hello world', defaultMessage: 'hello world' }}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
disabled={false}
|
||||||
/>
|
/>
|
||||||
</IntlProvider>
|
</IntlProvider>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
@ -203,7 +205,7 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.c28 .sc-bjeSbO {
|
.c28 .sc-pVTFL {
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
display: -webkit-flex;
|
display: -webkit-flex;
|
||||||
display: -ms-flexbox;
|
display: -ms-flexbox;
|
||||||
@ -560,8 +562,6 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
min-height: 2rem;
|
min-height: 2rem;
|
||||||
color: #666687;
|
|
||||||
background: #eaeaef;
|
|
||||||
outline: none;
|
outline: none;
|
||||||
box-shadow: 0;
|
box-shadow: 0;
|
||||||
-webkit-transition-property: border-color,box-shadow,fill;
|
-webkit-transition-property: border-color,box-shadow,fill;
|
||||||
@ -598,7 +598,6 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
background: none;
|
background: none;
|
||||||
border: none;
|
border: none;
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.c18 svg {
|
.c18 svg {
|
||||||
@ -610,7 +609,7 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.c32 {
|
.c32 {
|
||||||
cursor: not-allowed !important;
|
cursor: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.c32 .CodeMirror-placeholder {
|
.c32 .CodeMirror-placeholder {
|
||||||
@ -1062,13 +1061,11 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="c9 c10"
|
class="c9 c10"
|
||||||
disabled=""
|
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
aria-disabled="true"
|
aria-disabled="false"
|
||||||
aria-expanded="false"
|
aria-expanded="false"
|
||||||
aria-haspopup="listbox"
|
aria-haspopup="listbox"
|
||||||
aria-label="Add a title"
|
|
||||||
aria-labelledby="selectTitle-label selectTitle-content"
|
aria-labelledby="selectTitle-label selectTitle-content"
|
||||||
class="c11"
|
class="c11"
|
||||||
id="selectTitle"
|
id="selectTitle"
|
||||||
@ -1097,7 +1094,6 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
<button
|
<button
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
class="c16 c17 c18"
|
class="c16 c17 c18"
|
||||||
disabled=""
|
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
@ -1126,7 +1122,7 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
<button
|
<button
|
||||||
aria-disabled="true"
|
aria-disabled="false"
|
||||||
aria-labelledby="tooltip-1"
|
aria-labelledby="tooltip-1"
|
||||||
class="c22 c23 c24 c25"
|
class="c22 c23 c24 c25"
|
||||||
id="Bold"
|
id="Bold"
|
||||||
@ -1152,7 +1148,7 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<button
|
<button
|
||||||
aria-disabled="true"
|
aria-disabled="false"
|
||||||
aria-labelledby="tooltip-3"
|
aria-labelledby="tooltip-3"
|
||||||
class="c22 c23 c24 c25"
|
class="c22 c23 c24 c25"
|
||||||
id="Italic"
|
id="Italic"
|
||||||
@ -1178,7 +1174,7 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<button
|
<button
|
||||||
aria-disabled="true"
|
aria-disabled="false"
|
||||||
aria-labelledby="tooltip-5"
|
aria-labelledby="tooltip-5"
|
||||||
class="c22 c23 c24 c25"
|
class="c22 c23 c24 c25"
|
||||||
id="Underline"
|
id="Underline"
|
||||||
@ -1203,7 +1199,7 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
</div>
|
</div>
|
||||||
<span>
|
<span>
|
||||||
<button
|
<button
|
||||||
aria-disabled="true"
|
aria-disabled="false"
|
||||||
aria-labelledby="tooltip-7"
|
aria-labelledby="tooltip-7"
|
||||||
class="c22 c23 c24 c26"
|
class="c22 c23 c24 c26"
|
||||||
id="more"
|
id="more"
|
||||||
@ -1234,7 +1230,7 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
<span
|
<span
|
||||||
class="c29 c30"
|
class="c29 c30"
|
||||||
>
|
>
|
||||||
Markdown mode
|
Preview mode
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -1244,7 +1240,6 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="c32"
|
class="c32"
|
||||||
disabled=""
|
|
||||||
>
|
>
|
||||||
<textarea
|
<textarea
|
||||||
style="display: none;"
|
style="display: none;"
|
||||||
@ -1260,8 +1255,6 @@ describe('Wysiwyg render and actions buttons', () => {
|
|||||||
aria-label="Editor"
|
aria-label="Editor"
|
||||||
autocapitalize="off"
|
autocapitalize="off"
|
||||||
autocorrect="off"
|
autocorrect="off"
|
||||||
disabled=""
|
|
||||||
readonly=""
|
|
||||||
spellcheck="false"
|
spellcheck="false"
|
||||||
style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; min-height: 1em; outline: none;"
|
style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; min-height: 1em; outline: none;"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
@ -1669,7 +1662,7 @@ describe('Wysiwyg render actions with initial value', () => {
|
|||||||
renderedContainer = container;
|
renderedContainer = container;
|
||||||
});
|
});
|
||||||
|
|
||||||
it.only('should add markdown with initial value', async () => {
|
it('should add markdown with initial value', async () => {
|
||||||
await waitFor(() => renderedContainer.querySelector('.CodeMirror-cursor'));
|
await waitFor(() => renderedContainer.querySelector('.CodeMirror-cursor'));
|
||||||
expect(returnedValue).toEqual('hello world');
|
expect(returnedValue).toEqual('hello world');
|
||||||
const expected = `${returnedValue}**Bold**`;
|
const expected = `${returnedValue}**Bold**`;
|
||||||
|
@ -94,10 +94,10 @@ describe('UploadAssetDialog', () => {
|
|||||||
target: { files: fileList },
|
target: { files: fileList },
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(screen.getByText('Upload new asset')).toBeInTheDocument();
|
expect(screen.getAllByText(`Add new assets`).length).toBe(2);
|
||||||
expect(
|
expect(
|
||||||
screen.getByText(
|
screen.getByText(
|
||||||
'{number, plural, =0 {No asset} one {1 asset} other {# assets}} selected'
|
'{number, plural, =0 {No asset} one {1 asset} other {# assets}} ready to upload'
|
||||||
)
|
)
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
expect(
|
expect(
|
||||||
@ -193,11 +193,11 @@ describe('UploadAssetDialog', () => {
|
|||||||
await waitFor(() =>
|
await waitFor(() =>
|
||||||
expect(
|
expect(
|
||||||
screen.getByText(
|
screen.getByText(
|
||||||
'{number, plural, =0 {No asset} one {1 asset} other {# assets}} selected'
|
'{number, plural, =0 {No asset} one {1 asset} other {# assets}} ready to upload'
|
||||||
)
|
)
|
||||||
).toBeInTheDocument()
|
).toBeInTheDocument()
|
||||||
);
|
);
|
||||||
expect(screen.getByText('Upload new asset')).toBeInTheDocument();
|
expect(screen.getAllByText(`Add new assets`).length).toBe(2);
|
||||||
expect(
|
expect(
|
||||||
screen.getByText('Manage the assets before uploading them to the Media Library')
|
screen.getByText('Manage the assets before uploading them to the Media Library')
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
@ -179,7 +179,7 @@ describe('Media library homepage', () => {
|
|||||||
|
|
||||||
renderML();
|
renderML();
|
||||||
|
|
||||||
await waitFor(() => expect(screen.queryByText(`Upload assets`)).not.toBeInTheDocument());
|
await waitFor(() => expect(screen.queryByText(`Add new assets`)).not.toBeInTheDocument());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows the "Upload assets" button when the user does have the permissions to', async () => {
|
it('shows the "Upload assets" button when the user does have the permissions to', async () => {
|
||||||
@ -193,7 +193,7 @@ describe('Media library homepage', () => {
|
|||||||
|
|
||||||
renderML();
|
renderML();
|
||||||
|
|
||||||
await waitFor(() => expect(screen.getByText(`Upload assets`)).toBeInTheDocument());
|
await waitFor(() => expect(screen.getByText(`Add new assets`)).toBeInTheDocument());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user