Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Incorporate inputMedia into mainComposer #185

Merged
merged 9 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
# npx lint-staged
JpBurgarelli marked this conversation as resolved.
Show resolved Hide resolved

exec < /dev/tty && npx cz --hook || true
121 changes: 64 additions & 57 deletions src/components/MainComposer/MainComposer.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,89 +2,96 @@

.wrapper {
width: 100%;
}

.innerHeader {
padding: 1rem 3rem;
border: 0.1rem solid global.$primaryGray;
border-bottom: 0;
.mainComposerInputMedia {
display: flex;
gap: 3.2rem;

background-color: global.$secondaryPurple;
border-radius: 2rem 2rem 0 0;
}
margin-top: 2.4rem;
}

.innerHeader {
padding: 1rem 3rem;
border: 0.1rem solid global.$primaryGray;
border-bottom: 0;

.innerHeader .mainContent {
.mainText {
color: global.$primaryWhite;
font-size: 2.2rem;
font-weight: 400;
font-style: normal;
line-height: 2.8rem;
background-color: global.$secondaryPurple;
border-radius: 2rem 2rem 0 0;
}

.mainText::before {
width: 1.5rem;
height: 1.5rem;
.innerHeader .mainContent {
.mainText {
color: global.$primaryWhite;
font-size: 2.2rem;
font-weight: 400;
font-style: normal;
line-height: 2.8rem;
}

display: inline-block;
.mainText::before {
width: 1.5rem;
height: 1.5rem;

float: left;
display: inline-block;

margin-top: 0.7rem;
float: left;

margin-right: 1rem;
margin-top: 0.7rem;

background-color: global.$primaryWhite;
border-radius: 50%;
margin-right: 1rem;

content: '';
}
background-color: global.$primaryWhite;
border-radius: 50%;

content: '';
}

.mainText::after {
width: 2rem;
height: 0.5rem;
.mainText::after {
width: 2rem;
height: 0.5rem;

display: inline-block;
display: inline-block;

float: right;
float: right;

margin-top: 1.4rem;
margin-left: 1rem;
margin-top: 1.4rem;
margin-left: 1rem;

background-color: global.$primaryWhite;
background-color: global.$primaryWhite;

content: '';
content: '';
}
}
}

.content {
padding: 2.4rem 1.6rem;
border: 0.1rem solid global.$primaryGray;
.content {
padding: 2.4rem 1.6rem;
border: 0.1rem solid global.$primaryGray;

border-radius: 0 0 0.5rem 0.5rem;
}
border-radius: 0 0 0.5rem 0.5rem;
}

.textInput textarea {
width: 100%;
height: 15rem;
.textInput textarea {
width: 100%;
height: 15rem;

font-size: 1.6rem;
font-size: 1.6rem;

margin-bottom: 2.4rem;
border: 0;
box-sizing: border-box;
margin-bottom: 2.4rem;
border: 0;
box-sizing: border-box;

resize: none;
}
resize: none;
}

.contentBotTop {
font-size: 1.6rem;
.contentBotTop {
font-size: 1.6rem;

border-bottom: 0.1rem solid global.$primaryGray;
}
border-bottom: 0.1rem solid global.$primaryGray;
}

.contentBotBot {
font-size: 1.6rem;
.contentBotBot {
font-size: 1.6rem;

margin-bottom: 2.4rem;
margin-bottom: 2.4rem;
}
}
68 changes: 68 additions & 0 deletions src/components/MainComposer/MainComposer.spec.ct.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { test, expect } from '@playwright/experimental-ct-react';

import MainComposer from '../MainComposer/MainComposer';

test.describe('MainComposer', () => {
test.describe('MediaInputs', () => {
test('upload the image', async ({ mount }) => {
const component = await mount(<MainComposer />);

await component
.getByTestId('imageInput')
.setInputFiles('src/assets/logo.png');

await expect(
component.getByAltText('uploaded image logo.png')
).toBeVisible();
});

test('upload two images', async ({ mount }) => {
const component = await mount(<MainComposer />);

await component
.getByTestId('imageInput')
.setInputFiles(['src/assets/logo.png', 'src/assets/imagetest.jpg']);

await expect(
component.getByAltText('uploaded image logo.png')
).toBeVisible();
await expect(
component.getByAltText('uploaded image imagetest.jpg')
).toBeVisible();
});

test.describe('when the file is diferent from image or video', () => {
test('doesnt select the file', async ({ mount }) => {
const mediaSelected: string | null = null;

const component = await mount(<MainComposer />);

await component
.getByTestId('imageInput')
.setInputFiles('public/robots.txt');

await expect(mediaSelected).toBeNull();
});
});

test.describe('when add img and click on remove button', () => {
test('remove image', async ({ mount }) => {
const component = await mount(<MainComposer />);

await component
.getByTestId('imageInput')
.setInputFiles('src/assets/logo.png');

await expect(
component.getByAltText('uploaded image logo.png')
).toBeVisible();

await component.getByRole('button', { name: 'X' }).click();

await expect(
component.getByAltText('uploaded image logo.png')
).not.toBeVisible();
});
});
});
});
7 changes: 6 additions & 1 deletion src/components/MainComposer/MainComposer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useTranslation } from 'react-i18next';

import ComposerEditor from '~components/ComposerEditor/ComposerEditor';
import ComposerEditor from '../ComposerEditor/ComposerEditor';
import MediaInputs from '../MediaInputs/MediaInput';

import '../../i18n';
JpBurgarelli marked this conversation as resolved.
Show resolved Hide resolved

import scss from './MainComposer.module.scss';
Expand All @@ -24,6 +26,9 @@ function MainComposer() {
<h2>content-bot-top</h2>
</div>
<div className={scss.contentBotBot}>
<div className={scss.mainComposerInputMedia}>
<MediaInputs />
</div>
<h2>content-bot-bot</h2>
<p>{t('We have a lot of work')}</p>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/MediaInputs/MediaInput.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

.manyMediaContainer {
display: grid;
grid-template-columns: repeat(5, minmax(10.4rem, auto));
grid-template-columns: repeat(10, minmax(10.4rem, auto));

gap: 2.1px;
gap: 1.4rem;

align-items: center;

Expand Down
2 changes: 1 addition & 1 deletion src/components/MediaInputs/MediaInput.spec.ct.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/experimental-ct-react';

import MediaInputs from './MediaInput';
import MediaInputs from './MediaInput'; // Forna de importar diferente
JpBurgarelli marked this conversation as resolved.
Show resolved Hide resolved

test.describe('ManyInputs', () => {
test.describe('when click on input', () => {
Expand Down
Loading