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
11 changes: 8 additions & 3 deletions e2e/import-document.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,21 @@ test('story import: preview and import a Word manuscript', async ({ page }) => {
title
);

// The settings page's Import button is the modal's second entry point;
// import-story.spec covers the library-menu one. Picking a file previews
// it at once.
await gotoReady(page, `/universes/docland-${stamp}`);
await page.getByRole('link', { name: 'Import and export' }).click();
await page.locator('input[name="archive"]').setInputFiles({
await page.getByRole('button', { name: 'Import a story...' }).click();
const dialog = page.getByRole('dialog', { name: 'Import a story' });
await expect(dialog).toBeVisible();
await dialog.locator('input[name="archive"]').setInputFiles({
name: 'manuscript.docx',
mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
buffer: docx
});
await page.getByRole('button', { name: 'Preview' }).click();

const report = page.locator('.import-report');
const report = dialog.locator('.import-report');
await expect(report).toContainText(`"${title}": 2 chapters, 3 scenes`);

await page.getByRole('button', { name: 'Import story' }).click();
Expand Down
19 changes: 13 additions & 6 deletions e2e/import-story.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { gotoReady } from './navigate';
import { pickFromLibraryMenu, startStoryInUniverse } from './library';

// The story import round trip: write a story, download its export zip, and
// import the zip back through the universe settings preview flow.
// import the zip back through the library's import modal preview flow.
test('story import: preview and import a story export zip', async ({ page }) => {
await gotoReady(page, '/');

Expand Down Expand Up @@ -63,16 +63,23 @@ test('story import: preview and import a story export zip', async ({ page }) =>
expect(archive.status()).toBe(200);
const zipBytes = await archive.body();

await gotoReady(page, `/universes/importland-${stamp}`);
await page.getByRole('link', { name: 'Import and export' }).click();
await page.locator('input[name="archive"]').setInputFiles({
// Feed it back through the import modal, opened from the universe's New
// story menu on the library. Picking a file previews it at once.
await gotoReady(page, '/');
await page
.locator('.universe-section', { hasText: universeName })
.getByRole('button', { name: 'New story', exact: true })
.click();
await page.getByRole('menuitem', { name: 'Import a story into this universe...' }).click();
const dialog = page.getByRole('dialog', { name: 'Import a story' });
await expect(dialog).toBeVisible();
await dialog.locator('input[name="archive"]').setInputFiles({
name: 'roundtrip.zip',
mimeType: 'application/zip',
buffer: zipBytes
});
await page.getByRole('button', { name: 'Preview' }).click();

const report = page.locator('.import-report');
const report = dialog.locator('.import-report');
await expect(report).toContainText('"Roundtrip": 1 chapter, 1 scene');
await expect(report).toContainText('A story named "Roundtrip" already exists');
await expect(report).toContainText('Bram');
Expand Down
Loading