130 lines
7.3 KiB
JavaScript
130 lines
7.3 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const { open } = require('./dev-acceptance.cjs');
|
|
|
|
async function run() {
|
|
let session;
|
|
let step = 'fixture';
|
|
try {
|
|
session = await open();
|
|
const project = await session.project();
|
|
const book = await session.create('Books', '?projectId=' + project, {
|
|
BookTitle: 'Writer planning acceptance', BookNumber: 1
|
|
});
|
|
const chapters = [];
|
|
for (let index = 1; index <= 3; index++) {
|
|
chapters.push(await session.create('Chapters', '?bookId=' + book,
|
|
{ ChapterTitle: 'Chapter ' + index, ChapterNumber: index }));
|
|
}
|
|
const page = session.page;
|
|
const scope = `projectId=${project}&bookId=${book}`;
|
|
const groups = '/WriterGroups?bookId=' + book;
|
|
const schedules = '/Writer/WritingPlans?' + scope;
|
|
const create = '/Writer/ScheduleSetup?' + scope;
|
|
const button = name => page.getByRole('button', { name, exact: true });
|
|
|
|
step = 'multiple working groups and reload';
|
|
await session.goto(groups);
|
|
await page.locator('#Name').fill('Opening and ending');
|
|
await page.locator('#IsCurrent').check();
|
|
await page.locator(`input[name="ChapterIDs"][value="${chapters[0]}"]`).check();
|
|
await page.locator(`input[name="ChapterIDs"][value="${chapters[2]}"]`).check();
|
|
await button('Save working group').click();
|
|
await page.getByRole('link', { name: 'Schedule time for Opening and ending' }).waitFor();
|
|
await page.locator('#Name').fill('Middle');
|
|
await page.locator(`input[name="ChapterIDs"][value="${chapters[1]}"]`).check();
|
|
await button('Save working group').click();
|
|
await page.getByRole('link', { name: 'Edit Middle' }).waitFor();
|
|
await page.reload();
|
|
await page.getByRole('link', { name: 'Schedule time for Opening and ending' }).waitFor();
|
|
|
|
step = 'impossible capacity and cancellation';
|
|
await session.goto(create);
|
|
await page.locator('#PlanName').fill('Impossible cancelled plan');
|
|
const start = await page.locator('#StartDate').inputValue();
|
|
await page.locator('#DeadlineDate').fill(start);
|
|
const available = page.locator('input[type="checkbox"][name$=".IsAvailable"]');
|
|
for (const checkbox of await available.all()) await checkbox.check();
|
|
await button('Review activities').click();
|
|
await page.locator('input[type="checkbox"][name$=".Selected"]').first().check();
|
|
const selectedBudget = page.locator('input[name="Candidates[0].Minutes"]');
|
|
await selectedBudget.fill('1440');
|
|
await button('Preview schedule').click();
|
|
await page.getByText('The selected work exceeds usable time.', { exact: false }).waitFor();
|
|
assert.equal(await button('Save writing schedule').count(), 0);
|
|
await page.getByRole('link', { name: 'Cancel', exact: true }).click();
|
|
await session.goto(schedules);
|
|
assert.equal(await page.getByText('Impossible cancelled plan', { exact: true }).count(), 0);
|
|
|
|
step = 'persist group allocations and preserve completed work';
|
|
await session.goto(groups);
|
|
await page.getByRole('link', { name: 'Schedule time for Opening and ending' }).click();
|
|
await page.locator('#PlanName').fill('Reviewed group plan');
|
|
for (const checkbox of await available.all()) await checkbox.check();
|
|
await button('Review activities').click();
|
|
await page.locator('input[name="Candidates[0].Minutes"]').fill('100');
|
|
await button('Preview schedule').click();
|
|
await page.getByRole('heading', { name: 'Schedule preview', exact: true }).waitFor();
|
|
await assert.doesNotReject(() => button('Save writing schedule').click());
|
|
await page.waitForURL(url => url.pathname === '/Writer/SchedulePreview');
|
|
await page.reload();
|
|
await page.getByRole('heading', { name: 'Reviewed writing activities' }).waitFor();
|
|
await button('Mark complete').first().click();
|
|
await page.getByText('Done', { exact: true }).first().waitFor();
|
|
await page.getByRole('link', { name: 'Review or recalculate writing activities' }).click();
|
|
await button('Preview remaining work').click();
|
|
await button('Save revised allocations').click();
|
|
await page.waitForURL(url => url.pathname === '/Writer/SchedulePreview');
|
|
await page.reload();
|
|
await page.getByText('Done', { exact: true }).first().waitFor();
|
|
|
|
step = 'board drag across and reorder within a column';
|
|
await session.goto('/Writer/Plan?' + scope + '&view=board');
|
|
for (const title of ['First board activity', 'Second board activity']) {
|
|
await page.getByText('Add planned activity', { exact: true }).click();
|
|
await page.locator('details[open] [data-activity-save] input[name="Title"]').fill(title);
|
|
await button('Save activity').click();
|
|
await page.getByText(title, { exact: true }).first().waitFor();
|
|
}
|
|
const next = page.locator('[data-board-status="Next"]');
|
|
const doing = page.locator('[data-board-status="In progress"]');
|
|
await next.getByText('First board activity', { exact: true }).dragTo(doing.locator('h3'));
|
|
await doing.getByText('First board activity', { exact: true }).waitFor();
|
|
await next.getByText('Second board activity', { exact: true }).dragTo(doing.locator('h3'));
|
|
await doing.getByText('Second board activity', { exact: true }).waitFor();
|
|
await page.reload();
|
|
await doing.getByText('First board activity', { exact: true }).waitFor();
|
|
assert.deepEqual(await doing.locator('[data-board-handle]').allTextContents(),
|
|
['Second board activity', 'First board activity']);
|
|
|
|
step = 'map pasted notes and checklist to canonical chapter Intent';
|
|
await session.goto('/Writer/ImportIntent?bookId=' + book);
|
|
await page.locator('#Text').fill('# Opening\nFirst planning note\n\nChapter 3\n- Shared checklist item');
|
|
await button('Preview pasted intentions').click();
|
|
await page.locator('[name="Mappings[0].ChapterID"]').selectOption(String(chapters[0]));
|
|
await page.locator('[name="Mappings[1].ChapterID"]').selectOption(String(chapters[2]));
|
|
await page.locator('[name="Mappings[1].Mode"]').selectOption('checklist');
|
|
await button('Save chapter intentions').click();
|
|
await page.waitForURL('**/Writer/Write?*');
|
|
await session.close();
|
|
session = await open();
|
|
await session.goto(`/Writing/Context?${scope}&chapterId=${chapters[2]}&panel=intent&pinned=true`);
|
|
await session.page.getByText('Shared checklist item', { exact: true }).waitFor();
|
|
await session.goto(`/Writer/WritingPlans?${scope}`);
|
|
await session.page.getByText('Reviewed group plan', { exact: true }).waitFor();
|
|
console.log('PASS Writer planning groups, failure/cancellation, persistence, recalculation and canonical Intent');
|
|
} catch {
|
|
console.error('Writer planning acceptance failed at ' + step);
|
|
process.exitCode = 1;
|
|
} finally {
|
|
if (session) {
|
|
try { await session.cleanup(); }
|
|
finally { await session.close(); }
|
|
}
|
|
}
|
|
}
|
|
|
|
run().catch(() => {
|
|
console.error('Writer planning acceptance cleanup or fixture initialization failed.');
|
|
process.exitCode = 1;
|
|
});
|