Skip to content

Commit c7a8ef5

Browse files
Attached screenshots
1 parent dc02c84 commit c7a8ef5

File tree

9 files changed

+74
-81
lines changed

9 files changed

+74
-81
lines changed

Taskfile.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,25 @@ tasks:
327327
328328
test:e2e:
329329
dir: test/e2e
330-
desc: Test tool using end-to-end tests using Playwright
330+
desc: Test tool using end-to-end tests
331331
cmd: |
332332
set -e
333333
sh nw npm install
334334
sh nw npx playwright {{.CLI_ARGS | default "test"}}
335335
336+
test:e2e:codegen:
337+
dir: test/e2e
338+
desc: Generate end-to-end test code from recording
339+
cmd: |
340+
sh nw npm install
341+
sh nw npx playwright codegen --target=ts {{.AEM_AUTHOR_HTTP_URL}}
342+
343+
test:e2e:report:
344+
dir: test/e2e
345+
desc: Show end-to-end test report
346+
cmd: |
347+
sh nw npx playwright show-report
348+
336349
rde:setup:
337350
desc: setup access to RDE
338351
cmds:

test/e2e/001-general.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import { test, expect } from '@playwright/test';
22
import { expectCodeExecutorStatus, expectHealthyStatus } from './utils/expect';
33
import { testOnEnv, apiHeaders } from './utils/env';
4+
import { attachScreenshot } from './utils/page';
45

56
test.describe('General', () => {
6-
test('Tool is accessible', async ({ page }) => {
7+
test('Tool is accessible', async ({ page }, testInfo) => {
78
await page.goto('/acm');
89

910
const title = page.locator('.granite-title', { hasText: 'Content Manager' });
1011
await expect(title).toBeVisible();
1112

12-
await page.screenshot();
13+
await attachScreenshot(page, testInfo, 'Dashboard Page');
1314
});
1415

1516
testOnEnv('local')('Tool state is reset', async ({ page }) => {
@@ -26,18 +27,18 @@ test.describe('General', () => {
2627
await page.waitForTimeout(10000);
2728
});
2829

29-
test('System is healthy', async ({ page }) => {
30+
test('System is healthy', async ({ page }, testInfo) => {
3031
await page.goto('/acm#/maintenance?tab=health-checker');
3132

3233
await expectHealthyStatus(page);
33-
await page.screenshot();
34+
await attachScreenshot(page, testInfo, 'Health Checker');
3435
});
3536

36-
test('Code executor is idle', async ({ page }) => {
37+
test('Code executor is idle', async ({ page }, testInfo) => {
3738
await page.goto('/acm#/maintenance?tab=code-executor');
3839

3940
await expectCodeExecutorStatus(page);
40-
await page.screenshot();
41+
await attachScreenshot(page, testInfo, 'Code Executor');
4142
});
4243

4344
});

test/e2e/002-console.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { test, expect } from '@playwright/test';
22
import { expectCompilationSucceeded, expectExecutionProgressBarSucceeded, expectToHaveMultilineText } from './utils/expect'
33
import { readFromCodeEditor, writeToCodeEditor } from './utils/editor';
4+
import { attachScreenshot } from './utils/page';
45

56
test.describe('Console', () => {
6-
test('Executes script', async ({ page }) => {
7+
test('Executes script', async ({ page }, testInfo) => {
78
await page.goto('/acm#/console');
89

910
await expectCompilationSucceeded(page);
@@ -29,7 +30,7 @@ test.describe('Console', () => {
2930
expectToHaveMultilineText(output, `
3031
Hello World!
3132
`);
32-
await page.screenshot();
33+
await attachScreenshot(page, testInfo, 'Console Output');
3334
});
3435
});
3536

test/e2e/003-tool-access.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { test, expect } from '@playwright/test';
22
import { expectCompilationSucceeded, expectExecutionProgressBarSucceeded } from './utils/expect';
33
import { readFromCodeEditor, writeToCodeEditor } from './utils/editor';
44
import { newAemContext } from './utils/context';
5+
import { attachScreenshot } from './utils/page';
56

67
test.describe('Tool Access', () => {
7-
test('Admin user has full access', async ({ page }) => {
8+
test('Admin user has full access', async ({ page }, testInfo) => {
89
await page.goto('/acm');
910

1011
await expect(page.getByRole('button', { name: 'Console' })).toBeVisible();
@@ -19,10 +20,10 @@ test.describe('Tool Access', () => {
1920
await expectCompilationSucceeded(page);
2021
await expect(page.getByRole('button', { name: 'Execute' })).toBeEnabled();
2122

22-
await page.screenshot();
23+
await attachScreenshot(page, testInfo, 'Admin Full Access');
2324
});
2425

25-
test('Setup test user and verify limited access', async ({ page, browser }) => {
26+
test('Setup test user and verify limited access', async ({ page, browser }, testInfo) => {
2627
await page.goto('/acm#/console');
2728

2829
await expectCompilationSucceeded(page);
@@ -79,7 +80,7 @@ test.describe('Tool Access', () => {
7980
await expect(testUserPage.getByRole('button', { name: 'History' })).not.toBeVisible();
8081
await expect(testUserPage.getByRole('button', { name: 'Maintenance' })).not.toBeVisible();
8182

82-
await testUserPage.screenshot();
83+
await attachScreenshot(testUserPage, testInfo, 'Test User Access - Dashboard');
8384

8485
await testUserPage.getByRole('button', { name: 'Scripts' }).click();
8586
await expect(testUserPage).toHaveURL(/\/acm#\/scripts/);
@@ -99,7 +100,7 @@ test.describe('Tool Access', () => {
99100
await testUserPage.goto('/acm#/maintenance');
100101
await expect(testUserPage.getByRole('button', { name: 'Maintenance' })).not.toBeVisible();
101102

102-
await testUserPage.screenshot();
103+
await attachScreenshot(testUserPage, testInfo, 'Test User Access - Script List');
103104
});
104105
});
105106
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { test, expect } from '@playwright/test';
2+
import { readFromCodeEditor } from './utils/editor';
3+
import { attachScreenshot } from './utils/page';
4+
5+
test.describe('Automatic Scripts', () => {
6+
7+
test('Executions saved in history', async ({ page }, testInfo) => {
8+
await page.goto('/acm');
9+
await page.getByRole('button', { name: 'History' }).click();
10+
11+
const grid = page.locator('[role="grid"][aria-label="Executions table"]');
12+
await expect(grid).toBeVisible();
13+
const rows = grid.locator('[role="row"]');
14+
15+
await page.getByRole('searchbox', { name: 'Executable' }).fill('example/ACME-20_once');
16+
await expect(rows.nth(1)).toContainText('Script \'example/ACME-20_once\'');
17+
await expect(rows.nth(1)).toContainText('succeeded');
18+
await attachScreenshot(page, testInfo, `Script List filtered by 'ACME-20_once'`);
19+
20+
await page.getByRole('searchbox', { name: 'Executable' }).fill('example/ACME-21_changed');
21+
await expect(rows.nth(1)).toContainText('Script \'example/ACME-21_changed\'');
22+
await expect(rows.nth(1)).toContainText('succeeded');
23+
await attachScreenshot(page, testInfo, `Script List filtered by 'ACME-21_changed'`);
24+
});
25+
});

test/e2e/004-history.spec.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

test/e2e/005-manual-scripts.spec.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,34 @@ import {
99
expectOutputFileDownload,
1010
} from './utils/expect';
1111
import { readFromCodeEditor } from './utils/editor';
12+
import { attachScreenshot } from './utils/page';
1213

1314
test.describe('Manual Scripts', () => {
14-
test('Execute CSV Generation With I/O', async ({ page }) => {
15+
test('Execute CSV Generation With I/O', async ({ page }, testInfo) => {
1516
await page.goto('/acm');
1617
await page.getByRole('button', { name: 'Scripts' }).click();
17-
await page.screenshot({ path: 'test-results/screenshots/005-scripts-list.png' });
18+
await attachScreenshot(page, testInfo, 'Scripts list');
1819
await page.getByText('example/ACME-203_output-csv').click();
19-
await page.screenshot({ path: 'test-results/screenshots/005-script-details.png' });
20+
await attachScreenshot(page, testInfo, 'Script details');
2021
await page.getByRole('button', { name: 'Execute' }).click();
2122

2223
await page.getByRole('textbox', { name: 'Users to' }).fill('5000');
2324
await page.getByRole('textbox', { name: 'First names' }).fill('John\nJane\nJack\nAlice\nBob\nRobert');
2425
await page.getByRole('textbox', { name: 'Last names' }).fill('Doe\nSmith\nBrown\nJohnson\nWhite\nJordan');
25-
await page.screenshot({ path: 'test-results/screenshots/005-execution-inputs-filled.png' });
26+
await attachScreenshot(page, testInfo, 'Execution inputs filled');
2627

2728
await page.getByRole('button', { name: 'Start' }).click();
2829
await expectExecutionProgressBarSucceeded(page);
29-
await page.screenshot();
30+
await attachScreenshot(page, testInfo, 'Execution progress');
3031

3132
const output = await readFromCodeEditor(page, 'Execution Output');
3233
expect(output).toContain('[SUCCESS] Users CSV report generation ended successfully');
33-
await page.screenshot({ path: 'test-results/screenshots/005-execution-output.png' });
34+
await attachScreenshot(page, testInfo, 'Execution output');
3435

3536
await page.getByRole('tab', { name: 'Details' }).click();
3637

3738
await page.waitForTimeout(1000);
38-
await page.screenshot();
39+
await attachScreenshot(page, testInfo, 'Execution details');
3940

4041
await expectExecutionDetails(page);
4142
await expectExecutionTimings(page);
@@ -59,19 +60,19 @@ test.describe('Manual Scripts', () => {
5960
value: 'Processed 5000 user(s)',
6061
},
6162
]);
62-
await page.screenshot({ path: 'test-results/screenshots/005-execution-outputs.png' });
63+
await attachScreenshot(page, testInfo, 'Execution outputs');
6364

6465
await page.getByRole('tab', { name: 'Output' }).click();
6566

6667
await page.getByRole('button', { name: 'Review' }).click();
6768
await page.getByRole('tab', { name: 'Texts' }).click();
6869
await expectOutputTexts(page, ['Processed 5000 user(s)']);
69-
await page.screenshot({ path: 'test-results/screenshots/005-output-review-texts.png' });
70+
await attachScreenshot(page, testInfo, 'Output review texts');
7071
await page.getByTestId('modal').getByRole('button', { name: 'Close' }).click();
7172

7273
await page.getByRole('button', { name: 'Review' }).click();
7374
await page.getByRole('tab', { name: 'Files' }).click();
74-
await page.screenshot({ path: 'test-results/screenshots/005-output-review-files.png' });
75+
await attachScreenshot(page, testInfo, 'Output review files');
7576
await expectOutputFileDownload(page, 'Download Archive', /\.(zip)$/);
7677

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

test/e2e/playwright.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ export default defineConfig({
4141
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
4242
trace: 'on-first-retry',
4343

44-
/* Screenshots on failure */
45-
screenshot: 'on',
44+
/* Screenshots only on failure (manual screenshots still work) */
45+
screenshot: 'only-on-failure',
4646

4747
/* Videos on failure */
4848
video: 'retain-on-failure',

test/e2e/utils/page.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Page, TestInfo } from '@playwright/test';
2+
3+
export async function attachScreenshot(page: Page, testInfo: TestInfo, name: string): Promise<void> {
4+
const screenshot = await page.screenshot();
5+
await testInfo.attach(name, { body: screenshot, contentType: 'image/png' });
6+
}

0 commit comments

Comments
 (0)