Skip to content

Commit e37c090

Browse files
committed
test: update article and popular tags snapshots to YAML format
1 parent 9c54204 commit e37c090

File tree

5 files changed

+29
-26
lines changed

5 files changed

+29
-26
lines changed

playwright/specs/article.spec.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { EditArticlePageObject } from 'page-objects/edit-article.page-object'
33
import type { Article } from 'src/services/api'
44
import { Route } from '../constant'
55
import { expect, test } from '../extends'
6-
import { formatHTML, formatJSON } from '../utils/prettify'
76

87
test.beforeEach(async ({ conduit }) => {
98
await conduit.intercept('GET', /articles\?limit/, { fixture: 'articles.json' })
@@ -47,8 +46,8 @@ test.describe('post article', () => {
4746
waitForArticleRequest(),
4847
conduit.goto(Route.ArticleDetail),
4948
])
50-
const innerHTML = await page.locator('.article-content').innerHTML()
51-
expect(formatHTML(innerHTML)).toMatchSnapshot('markdown-render.html')
49+
const articleContent = page.locator('.article-content')
50+
await expect(articleContent).toMatchAriaSnapshot({ name: 'article-content.yml' })
5251
})
5352
})
5453

@@ -115,13 +114,11 @@ test.describe('tag', () => {
115114
test('should display popular tags in home page', async ({ page, conduit }) => {
116115
await conduit.goto(Route.Home)
117116

118-
const tagItems = await page.getByText('Popular Tags')
117+
const tagItemsWrapper = page.getByText('Popular Tags')
119118
.locator('..')
120119
.locator('.tag-pill')
121-
.all()
122-
.then(items => Promise.all(items.map(item => item.textContent())))
123-
expect(tagItems).toHaveLength(8)
124-
expect(formatJSON(tagItems)).toMatchSnapshot('popular-tags-in-home-page.json')
120+
.locator('..')
121+
await expect(tagItemsWrapper).toMatchAriaSnapshot({ name: 'popular-tags.yml' })
125122
})
126123

127124
test('should show right articles of tag', async ({ page, conduit }) => {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- heading "Article body" [level=1]
2+
- paragraph:
3+
- text: This is
4+
- strong: Strong
5+
- text: text
6+
- list:
7+
- listitem: foo
8+
- listitem: bar

playwright/specs/article.spec.ts-snapshots/markdown-render-chromium-darwin.html

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

playwright/specs/article.spec.ts-snapshots/popular-tags-in-home-page-chromium-darwin.json

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
- link "HuManIty":
2+
- /url: '#/tag/HuManIty'
3+
- link "Gandhi":
4+
- /url: '#/tag/Gandhi'
5+
- link "HITLER":
6+
- /url: '#/tag/HITLER'
7+
- link "SIDA":
8+
- /url: '#/tag/SIDA'
9+
- link "BlackLivesMatter":
10+
- /url: '#/tag/BlackLivesMatter'
11+
- link "test":
12+
- /url: '#/tag/test'
13+
- link "dragons":
14+
- /url: '#/tag/dragons'
15+
- link "butt":
16+
- /url: '#/tag/butt'

0 commit comments

Comments
 (0)