forked from alan2207/bulletproof-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smoke.spec.ts
95 lines (83 loc) · 3.26 KB
/
smoke.spec.ts
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
84
85
86
87
88
89
90
91
92
93
94
95
import { test, expect } from '@playwright/test';
import {
createDiscussion,
createComment,
} from '../../src/testing/data-generators';
test('smoke', async ({ page }) => {
const discussion = createDiscussion();
const comment = createComment();
await page.goto('/');
await page.getByRole('button', { name: 'Get started' }).click();
await page.waitForURL('/app');
// create discussion:
await page.getByRole('link', { name: 'Discussions' }).click();
await page.waitForURL('/app/discussions');
await page.getByRole('button', { name: 'Create Discussion' }).click();
await page.getByLabel('Title').click();
await page.getByLabel('Title').fill(discussion.title);
await page.getByLabel('Body').click();
await page.getByLabel('Body').fill(discussion.body);
await page.getByRole('button', { name: 'Submit' }).click();
await page
.getByLabel('Discussion Created')
.getByRole('button', { name: 'Close' })
.click();
// visit discussion page:
await page.getByRole('link', { name: 'View' }).click();
await expect(
page.getByRole('heading', { name: discussion.title }),
).toBeVisible();
await expect(page.getByText(discussion.body)).toBeVisible();
// update discussion:
await page.getByRole('button', { name: 'Update Discussion' }).click();
await page.getByLabel('Title').click();
await page.getByLabel('Title').fill(`${discussion.title} - updated`);
await page.getByLabel('Body').click();
await page.getByLabel('Body').fill(`${discussion.body} - updated`);
await page.getByRole('button', { name: 'Submit' }).click();
await page
.getByLabel('Discussion Updated')
.getByRole('button', { name: 'Close' })
.click();
await expect(
page.getByRole('heading', { name: `${discussion.title} - updated` }),
).toBeVisible();
await expect(page.getByText(`${discussion.body} - updated`)).toBeVisible();
// create comment:
await page.getByRole('button', { name: 'Create Comment' }).click();
await page.getByLabel('Body').click();
await page.getByLabel('Body').fill(comment.body);
await page.getByRole('button', { name: 'Submit' }).click();
await expect(page.getByText(comment.body)).toBeVisible();
await page
.getByLabel('Comment Created')
.getByRole('button', { name: 'Close' })
.click();
// delete comment:
await page.getByRole('button', { name: 'Delete Comment' }).click();
await expect(
page.getByText('Are you sure you want to delete this comment?'),
).toBeVisible();
await page.getByRole('button', { name: 'Delete Comment' }).click();
await page
.getByLabel('Comment Deleted')
.getByRole('button', { name: 'Close' })
.click();
await expect(
page.getByRole('heading', { name: 'No Comments Found' }),
).toBeVisible();
await expect(page.getByText(comment.body)).toBeHidden();
// go back to discussions:
await page.getByRole('link', { name: 'Discussions' }).click();
await page.waitForURL('/app/discussions');
// delete discussion:
await page.getByRole('button', { name: 'Delete Discussion' }).click();
await page.getByRole('button', { name: 'Delete Discussion' }).click();
await page
.getByLabel('Discussion Deleted')
.getByRole('button', { name: 'Close' })
.click();
await expect(
page.getByRole('heading', { name: 'No Entries Found' }),
).toBeVisible();
});