Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ and this project adheres to
- ♿(frontend) improve header accessibility #1270
- ♿(frontend) improve accessibility for decorative images in editor #1282
- #1338
- #1281
- ♻️(backend) fallback to email identifier when no name #1298
- 🐛(backend) allow ASCII characters in user sub field #1295
- ⚡️(frontend) improve fallback width calculation #1333
Expand Down
89 changes: 14 additions & 75 deletions src/frontend/apps/e2e/__tests__/app-impress/doc-export.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ test.describe('Doc Export', () => {
})
.click();

await expect(
page
.locator('div')
.filter({ hasText: /^Download$/ })
.first(),
).toBeVisible();
await expect(page.getByTestId('modal-export-title')).toBeVisible();
await expect(
page.getByText('Download your document in a .docx or .pdf format.'),
).toBeVisible();
Expand All @@ -45,7 +40,7 @@ test.describe('Doc Export', () => {
await expect(
page.getByRole('button', { name: 'Close the modal' }),
).toBeVisible();
await expect(page.getByRole('button', { name: 'Download' })).toBeVisible();
await expect(page.getByTestId('modal-download-button')).toBeVisible();
});

test('it exports the doc with pdf line break', async ({
Expand Down Expand Up @@ -136,23 +131,13 @@ test.describe('Doc Export', () => {
await page.getByRole('combobox', { name: 'Format' }).click();
await page.getByRole('option', { name: 'Docx' }).click();

await expect(
page.getByRole('button', {
name: 'Download',
exact: true,
}),
).toBeVisible();
await expect(page.getByTestId('modal-download-button')).toBeVisible();

const downloadPromise = page.waitForEvent('download', (download) => {
return download.suggestedFilename().includes(`${randomDoc}.docx`);
});

void page
.getByRole('button', {
name: 'Download',
exact: true,
})
.click();
void page.getByTestId('modal-download-button').click();

const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDoc}.docx`);
Expand Down Expand Up @@ -218,11 +203,7 @@ test.describe('Doc Export', () => {

await new Promise((resolve) => setTimeout(resolve, 1000));

await expect(
page.getByRole('button', {
name: 'Download',
}),
).toBeVisible();
await expect(page.getByTestId('modal-download-button')).toBeVisible();

const responseCorsPromise = page.waitForResponse(
(response) =>
Expand All @@ -233,11 +214,7 @@ test.describe('Doc Export', () => {
return download.suggestedFilename().includes(`${randomDoc}.pdf`);
});

void page
.getByRole('button', {
name: 'Download',
})
.click();
void page.getByTestId('modal-download-button').click();

const responseCors = await responseCorsPromise;
expect(responseCors.ok()).toBe(true);
Expand Down Expand Up @@ -279,21 +256,13 @@ test.describe('Doc Export', () => {
})
.click();

await expect(
page.getByRole('button', {
name: 'Download',
}),
).toBeVisible();
await expect(page.getByTestId('modal-download-button')).toBeVisible();

const downloadPromise = page.waitForEvent('download', (download) => {
return download.suggestedFilename().includes(`${randomDoc}.pdf`);
});

void page
.getByRole('button', {
name: 'Download',
})
.click();
void page.getByTestId('modal-download-button').click();

const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDoc}.pdf`);
Expand Down Expand Up @@ -329,23 +298,13 @@ test.describe('Doc Export', () => {
})
.click();

await expect(
page.getByRole('button', {
name: 'Download',
exact: true,
}),
).toBeVisible();
await expect(page.getByTestId('modal-download-button')).toBeVisible();

const downloadPromise = page.waitForEvent('download', (download) => {
return download.suggestedFilename().includes(`${randomDoc}.pdf`);
});

void page
.getByRole('button', {
name: 'Download',
exact: true,
})
.click();
void page.getByTestId('modal-download-button').click();

const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDoc}.pdf`);
Expand Down Expand Up @@ -391,23 +350,13 @@ test.describe('Doc Export', () => {
})
.click();

await expect(
page.getByRole('button', {
name: 'Download',
exact: true,
}),
).toBeVisible();
await expect(page.getByTestId('modal-download-button')).toBeVisible();

const downloadPromise = page.waitForEvent('download', (download) => {
return download.suggestedFilename().includes(`${randomDoc}.pdf`);
});

void page
.getByRole('button', {
name: 'Download',
exact: true,
})
.click();
void page.getByTestId('modal-download-button').click();

const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDoc}.pdf`);
Expand Down Expand Up @@ -469,12 +418,7 @@ test.describe('Doc Export', () => {
return download.suggestedFilename().includes(`${randomDocFrench}.pdf`);
});

void page
.getByRole('button', {
name: 'Télécharger',
exact: true,
})
.click();
void page.getByTestId('modal-download-button').click();

const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDocFrench}.pdf`);
Expand Down Expand Up @@ -536,12 +480,7 @@ test.describe('Doc Export', () => {
})
.click();

void page
.getByRole('button', {
name: 'Download',
exact: true,
})
.click();
void page.getByTestId('modal-download-button').click();

const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${docChild}.pdf`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ test.describe('Doc Header', () => {

await page.getByRole('button', { name: 'Share' }).click();

const shareModal = page.getByLabel('Share modal');
const shareModal = page.getByRole('dialog', {
name: 'Share modal content',
});
await expect(shareModal).toBeVisible();
await expect(page.getByText('Share the document')).toBeVisible();

Expand Down Expand Up @@ -581,7 +583,10 @@ test.describe('Documents Header mobile', () => {
await page.getByLabel('Open the document options').click();
await page.getByLabel('Share').click();

await expect(page.getByLabel('Share modal')).toBeVisible();
const shareModal = page.getByRole('dialog', {
name: 'Share modal content',
});
await expect(shareModal).toBeVisible();
await page.getByRole('button', { name: 'close' }).click();
await expect(page.getByLabel('Share modal')).toBeHidden();
});
Expand Down
1 change: 1 addition & 0 deletions src/frontend/apps/e2e/__tests__/app-impress/home.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ test.describe('Home page', () => {
await page.waitForLoadState('domcontentloaded');

// Wait a bit more for the responsive store to be initialized
// eslint-disable-next-line playwright/no-wait-for-timeout
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

await page.waitForTimeout(500);

// Check header content
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/apps/impress/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './AlertModal';
export * from './modal/AlertModal';
export * from './Box';
export * from './BoxButton';
export * from './Card';
Expand All @@ -9,7 +9,7 @@ export * from './Icon';
export * from './InfiniteScroll';
export * from './Link';
export * from './Loading';
export * from './SideModal';
export * from './modal/SideModal';
export * from './separators';
export * from './Text';
export * from './TextErrors';
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Button, Modal, ModalSize } from '@openfun/cunningham-react';
import { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';

import { Box } from './Box';
import { Text } from './Text';
import { Box } from '../Box';
import { Text } from '../Text';

export type AlertModalProps = {
description: ReactNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Button, type ButtonProps } from '@openfun/cunningham-react';
import React from 'react';

import { Box } from '@/components';

const ButtonCloseModal = (props: ButtonProps) => {
return (
<Button
type="button"
size="small"
color="primary-text"
icon={
<Box as="span" aria-hidden="true" className="material-icons-filled">
close
</Box>
}
{...props}
/>
);
};

export default ButtonCloseModal;
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useTranslation } from 'react-i18next';
import { css } from 'styled-components';

import { Box, Text } from '@/components';
import ButtonCloseModal from '@/components/modal/ButtonCloseModal';
import { useEditorStore } from '@/docs/doc-editor';
import { Doc, useTrans } from '@/docs/doc-management';

Expand Down Expand Up @@ -131,6 +132,7 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
isOpen
closeOnClickOutside
onClose={() => onClose()}
hideCloseButton
rightActions={
<>
<Button
Expand All @@ -148,16 +150,34 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
fullWidth
onClick={() => void onSubmit()}
disabled={isExporting}
data-testid="modal-download-button"
>
{t('Download')}
</Button>
</>
}
size={ModalSize.MEDIUM}
title={
<Text $size="h6" $variation="1000" $align="flex-start">
{t('Download')}
</Text>
<Box
$direction="row"
$justify="space-between"
$align="center"
$width="100%"
>
<Text
$size="h6"
$variation="1000"
$align="flex-start"
data-testid="modal-export-title"
>
{t('Download')}
</Text>
<ButtonCloseModal
aria-label={t('Close the download modal')}
onClick={() => onClose()}
disabled={isExporting}
/>
</Box>
}
>
<Box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useRouter } from 'next/router';
import { Trans, useTranslation } from 'react-i18next';

import { Box, Text, TextErrors } from '@/components';
import ButtonCloseModal from '@/components/modal/ButtonCloseModal';

import { useRemoveDoc } from '../api/useRemoveDoc';
import { Doc } from '../types';
Expand Down Expand Up @@ -53,11 +54,12 @@ export const ModalRemoveDoc = ({
<Modal
isOpen
closeOnClickOutside
hideCloseButton
onClose={() => onClose()}
rightActions={
<>
<Button
aria-label={t('Close the modal')}
aria-label={t('Close the delete modal')}
color="secondary"
fullWidth
onClick={() => onClose()}
Expand All @@ -80,15 +82,26 @@ export const ModalRemoveDoc = ({
}
size={ModalSize.MEDIUM}
title={
<Text
$size="h6"
as="h6"
$margin={{ all: '0' }}
$align="flex-start"
$variation="1000"
<Box
$direction="row"
$justify="space-between"
$align="center"
$width="100%"
>
{t('Delete a doc')}
</Text>
<Text
$size="h6"
as="h6"
$margin={{ all: '0' }}
$align="flex-start"
$variation="1000"
>
{t('Delete a doc')}
</Text>
<ButtonCloseModal
aria-label={t('Close the delete modal')}
onClick={() => onClose()}
/>
</Box>
}
>
<Box
Expand Down
Loading
Loading