|
1 | | -import { ArticleDetailPageObject } from 'page-objects/article-detail.page-object.ts' |
2 | | -import { EditArticlePageObject } from 'page-objects/edit-article.page-object.ts' |
3 | | -import type { Article } from 'src/services/api.ts' |
4 | | -import { Route } from '../constant.ts' |
| 1 | +import { ArticleDetailPageObject } from 'page-objects/article-detail.page-object' |
| 2 | +import { EditArticlePageObject } from 'page-objects/edit-article.page-object' |
| 3 | +import type { Article } from 'src/services/api' |
| 4 | +import { Route } from '../constant' |
5 | 5 | import { expect, test } from '../extends' |
6 | | -import { formatHTML, formatJSON } from '../utils/prettify.ts' |
| 6 | +import { formatHTML, formatJSON } from '../utils/prettify' |
7 | 7 |
|
8 | 8 | test.beforeEach(async ({ conduit }) => { |
9 | 9 | await conduit.intercept('GET', /articles\?limit/, { fixture: 'articles.json' }) |
10 | 10 | await conduit.intercept('GET', /tags/, { fixture: 'tags.json' }) |
11 | 11 | await conduit.intercept('GET', /profiles\/.+/, { fixture: 'profile.json' }) |
12 | | - |
13 | | - await conduit.login() |
14 | 12 | }) |
15 | 13 |
|
16 | 14 | test.describe('post article', () => { |
17 | 15 | let editArticlePage!: EditArticlePageObject |
18 | 16 |
|
19 | | - test.beforeEach(({ page }) => { |
| 17 | + test.beforeEach(async ({ conduit, page }) => { |
| 18 | + await conduit.login() |
20 | 19 | editArticlePage = new EditArticlePageObject(page) |
21 | 20 | }) |
22 | 21 |
|
@@ -56,6 +55,7 @@ test.describe('post article', () => { |
56 | 55 | test.describe('delete article', () => { |
57 | 56 | for (const position of ['banner', 'article footer'] as const) { |
58 | 57 | test(`delete article from ${position}`, async ({ page, conduit }) => { |
| 58 | + await conduit.login() |
59 | 59 | const articlePage = new ArticleDetailPageObject(page) |
60 | 60 | const waitForArticle = await articlePage.intercept('GET', /articles\/.+/, { fixture: 'article.json' }) |
61 | 61 | await conduit.goto(Route.ArticleDetail) |
@@ -102,12 +102,13 @@ test.describe('favorite article', () => { |
102 | 102 | page.getByRole('button', { name: 'Favorite article' }).first().click(), |
103 | 103 | ]) |
104 | 104 |
|
105 | | - await expect(page.getByRole('button', { name: 'Favorite article' }).first()).toHaveClass('btn-primary') |
| 105 | + await expect(page.getByRole('button', { name: 'Favorite article' }).first()).toContainClass('btn-primary') |
106 | 106 | }) |
107 | 107 | }) |
108 | 108 |
|
109 | 109 | test.describe('tag', () => { |
110 | 110 | test.beforeEach(async ({ conduit }) => { |
| 111 | + await conduit.login() |
111 | 112 | await conduit.intercept('GET', /articles\?tag=butt/, { fixture: 'articles-of-tag.json' }) |
112 | 113 | }) |
113 | 114 |
|
|
0 commit comments