forked from CoreBunch/Instatic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore-owner-lifecycle.e2e.ts
More file actions
83 lines (74 loc) · 2.67 KB
/
Copy pathcore-owner-lifecycle.e2e.ts
File metadata and controls
83 lines (74 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { expect, test } from '@playwright/test'
import {
ANONYMOUS_STATE,
canvasFrame,
expectEditorReady,
insertNotchModule,
login,
logout,
openSiteEditor,
publishDraft,
saveDraft,
selectTreeLayer,
setPropValue,
visitPublicPage,
} from './helpers'
const PUBLISHED_TEXT = 'Automated E2E public headline'
const DRAFT_ONLY_TEXT = 'Automated E2E draft only headline'
/**
* Flagship owner journey. Covers SETUP-001 (via the `setup` project),
* AUTH-001, EDIT-001, SAVE-001, PUB-001, PUB-002, PUB-003, and the publish
* step-up (part of CAP-003).
*
* Runs in a fresh anonymous context (not the shared owner `storageState`) so its
* sign-out step invalidates only its own session, leaving the setup session — and
* every other spec — unaffected. It is the only spec that edits the homepage; all
* other specs work on their own pages, keeping this journey deterministic.
*/
test.describe('core owner lifecycle', () => {
test.use({ storageState: ANONYMOUS_STATE })
test('logs in, edits, publishes, and keeps later drafts private', async ({
page,
browser,
}) => {
await test.step('log in as the owner', async () => {
await login(page)
await openSiteEditor(page)
})
await test.step('log out and log back in (AUTH-001)', async () => {
await logout(page)
await login(page)
await openSiteEditor(page)
})
await test.step('add editable homepage text (EDIT-001)', async () => {
await insertNotchModule(page, 'text')
await setPropValue(page, 'text', PUBLISHED_TEXT)
await expect(canvasFrame(page).getByText(PUBLISHED_TEXT)).toBeVisible()
await saveDraft(page)
})
await test.step('reload and confirm draft persistence (SAVE-001)', async () => {
await page.reload()
await expectEditorReady(page)
await expect(canvasFrame(page).getByText(PUBLISHED_TEXT)).toBeVisible()
})
await test.step('publish and verify the visitor page (PUB-001, PUB-002)', async () => {
await publishDraft(page)
await visitPublicPage(browser, {
visibleText: PUBLISHED_TEXT,
hiddenText: DRAFT_ONLY_TEXT,
})
})
await test.step('edit the draft without publishing (PUB-003)', async () => {
await selectTreeLayer(page, 'Text')
await setPropValue(page, 'text', DRAFT_ONLY_TEXT)
await expect(canvasFrame(page).getByText(DRAFT_ONLY_TEXT)).toBeVisible()
await saveDraft(page)
// The unpublished edit must not leak: the public page still shows the
// last published headline, not the new draft-only text.
await visitPublicPage(browser, {
visibleText: PUBLISHED_TEXT,
hiddenText: DRAFT_ONLY_TEXT,
})
})
})
})