feat: route ready-title issues through guided workflow
This commit is contained in:
@@ -7,7 +7,7 @@ const base = process.env.REVIEW_BASE || 'http://localhost:3114';
|
||||
try {
|
||||
const context = await browser.newContext();
|
||||
await context.addCookies([{ name: 'magent_logged_in', value: '1', url: base }]);
|
||||
const writes = [];
|
||||
const calls = [];
|
||||
const errors = [];
|
||||
await context.route('**/api/**', async route => {
|
||||
const request = route.request();
|
||||
@@ -28,15 +28,31 @@ const base = process.env.REVIEW_BASE || 'http://localhost:3114';
|
||||
},
|
||||
});
|
||||
if (path === '/api/requests/42/language') return reply({ language: null });
|
||||
if (path === '/api/requests/42/issue-options') return reply({
|
||||
request_id: '42', request_type: 'movie', title: 'Drive', can_act: true,
|
||||
movie: { selected_label: 'Drive', has_file: true, missing: false, best_fit: true, file_id: 77 },
|
||||
seasons: [], episodes: [],
|
||||
});
|
||||
if (path === '/api/portal/items' && request.method() === 'POST') {
|
||||
writes.push(request.postDataJSON());
|
||||
calls.push({ path, body: request.postDataJSON() });
|
||||
return reply({ item: { id: 73 } });
|
||||
}
|
||||
return reply({});
|
||||
if (path === '/api/requests/42/actions/replace' && request.method() === 'POST') {
|
||||
calls.push({ path, body: request.postDataJSON() });
|
||||
return reply({ status: 'ok', message: 'Replacement queued.' });
|
||||
}
|
||||
if (path.includes('/events/stream')) return route.fulfill({ contentType: 'text/event-stream', body: ': fixture\n\n' });
|
||||
if (path.includes('/branding/')) return route.fulfill({ status: 404 });
|
||||
return reply({ navigation: { showRequests: true }, items: [], total: 0, services: [] });
|
||||
});
|
||||
|
||||
const page = await context.newPage();
|
||||
page.on('pageerror', error => errors.push(error.message));
|
||||
const active = () => page.locator('.issue-procedure-step.is-current');
|
||||
const visibleStep = async title => {
|
||||
await active().getByRole('heading', { name: title, exact: true }).waitFor();
|
||||
assert.equal(await page.locator('.issue-procedure-step.is-current').count(), 1);
|
||||
};
|
||||
for (const width of [1440, 390]) {
|
||||
await page.setViewportSize({ width, height: 950 });
|
||||
await page.goto(base + '/requests/42');
|
||||
@@ -50,13 +66,20 @@ const base = process.env.REVIEW_BASE || 'http://localhost:3114';
|
||||
await page.getByRole('option', { name: /Drive.*Ready to watch/ }).waitFor();
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
await page.getByRole('button', { name: "Tell us what's wrong" }).click();
|
||||
const dialog = page.getByRole('dialog', { name: "What's wrong?" });
|
||||
await dialog.getByText('Drive (2011)', { exact: true }).waitFor();
|
||||
await dialog.getByLabel('Tell us what happened').fill('The movie freezes at 42 minutes.');
|
||||
await dialog.getByRole('button', { name: 'Send report' }).click();
|
||||
await page.getByRole('heading', { name: "Thanks, we've got it" }).waitFor();
|
||||
await page.getByRole('button', { name: 'Done' }).click();
|
||||
await page.getByRole('link', { name: /Start issue report/ }).click();
|
||||
await page.waitForURL('**/portal/issues?*');
|
||||
assert.equal(new URL(page.url()).searchParams.get('reportRequest'), '42');
|
||||
await visibleStep('What is wrong?');
|
||||
await active().locator('.issue-prefilled-request').getByText('Drive (2011)', { exact: true }).waitFor();
|
||||
await active().locator('.issue-prefilled-request').getByText(/Request #42 is already selected/).waitFor();
|
||||
|
||||
await active().getByRole('button').filter({ hasText: 'Picture or file is broken' }).click();
|
||||
await visibleStep('What needs to be corrected?');
|
||||
await active().getByRole('button', { name: 'Visual artefacts or corruption', exact: true }).click();
|
||||
await active().getByRole('button', { name: 'Continue', exact: true }).click();
|
||||
await visibleStep('Review and submit');
|
||||
await active().getByRole('button', { name: /Submit/ }).click();
|
||||
await visibleStep('What is wrong?');
|
||||
assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
|
||||
|
||||
if (width === 1440) {
|
||||
@@ -70,10 +93,22 @@ const base = process.env.REVIEW_BASE || 'http://localhost:3114';
|
||||
await page.getByRole('heading', { name: 'View stats & requests' }).waitFor();
|
||||
await page.getByText('Check your viewing stats, follow your requests, or make a new one.', { exact: true }).waitFor();
|
||||
|
||||
assert.equal(writes.length, 2);
|
||||
assert(writes.every(write => write.kind === 'issue' && write.title === 'Problem with Drive' && write.external_ref === '/requests/42' && write.description === 'The movie freezes at 42 minutes.'));
|
||||
const issueCalls = calls.filter(call => call.path === '/api/portal/items');
|
||||
const replaceCalls = calls.filter(call => call.path === '/api/requests/42/actions/replace');
|
||||
assert.equal(issueCalls.length, 2);
|
||||
assert.equal(replaceCalls.length, 2);
|
||||
assert(issueCalls.every(({ body }) =>
|
||||
body.kind === 'issue'
|
||||
&& body.title === 'Replace media: Drive'
|
||||
&& body.issue_type === 'broken_media'
|
||||
&& body.external_ref === '/requests/42'
|
||||
&& body.description.includes('Problem: Picture or file is broken')
|
||||
&& body.description.includes('What needs correction: Visual artefacts or corruption')
|
||||
&& body.description.includes('Magent request: #42')));
|
||||
assert(replaceCalls.every(({ body }) =>
|
||||
JSON.stringify(body) === JSON.stringify({ issue_id: 73, file_ids: [77], confirmed: true })));
|
||||
assert.deepEqual(errors, []);
|
||||
console.log('Passed: completed request actions, linked issue dialog, global search, navigation order, welcome copy, and desktop/mobile overflow. APIs intercepted.');
|
||||
console.log('Passed: completed requests hand off to the guided issue pipeline, create linked issues, start repairs, and preserve global navigation on desktop/mobile. APIs intercepted.');
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user