-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
フロントエンドの自動テストスイートを改善して[email protected]にアップデート
(AlesInfiny/maris#2169 を反映)
- Loading branch information
1 parent
1e745f5
commit ce747a5
Showing
6 changed files
with
187 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 31 additions & 10 deletions
41
samples/web-csr/dressca-frontend/admin/src/views/__tests__/ItemsAddView.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,43 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { flushPromises, mount } from '@vue/test-utils'; | ||
import { describe, it, expect, vi, beforeAll } from 'vitest'; | ||
import { flushPromises, mount, VueWrapper } from '@vue/test-utils'; | ||
import { router } from '@/router'; | ||
import { createPinia, setActivePinia } from 'pinia'; | ||
import { createCustomErrorHandler } from '@/shared/error-handler/custom-error-handler'; | ||
import ItemsAddView from '@/views/catalog/ItemsAddView.vue'; | ||
|
||
describe('アイテム追加画面のテスト', () => { | ||
it('アイテムを追加できる', async () => { | ||
const pinia = createPinia(); | ||
setActivePinia(pinia); | ||
const customErrorHandler = createCustomErrorHandler(); | ||
const wrapper = mount(ItemsAddView, { | ||
global: { plugins: [pinia, router, customErrorHandler] }, | ||
}); | ||
async function getWrapper() { | ||
const pinia = createPinia(); | ||
setActivePinia(pinia); | ||
const customErrorHandler = createCustomErrorHandler(); | ||
return mount(ItemsAddView, { | ||
global: { plugins: [pinia, router, customErrorHandler] }, | ||
}); | ||
} | ||
|
||
describe('アイテムを追加できる', () => { | ||
let wrapper: VueWrapper; | ||
|
||
beforeAll(async () => { | ||
wrapper = await getWrapper(); | ||
}); | ||
|
||
it('追加画面に遷移できる', async () => { | ||
// Arrange | ||
// Act | ||
await flushPromises(); | ||
// Assert | ||
expect(wrapper.html()).toContain('カタログアイテム追加'); | ||
}); | ||
|
||
it('追加ボタンを押下_追加成功_通知モーダルが開く', async () => { | ||
// Arrange | ||
// Act | ||
wrapper.find('button').trigger('click'); | ||
await flushPromises(); | ||
await vi.waitUntil(() => | ||
wrapper.findAllComponents({ name: 'NotificationModal' })[0].isVisible(), | ||
); | ||
// Assert | ||
expect(wrapper.html()).toContain('カタログアイテムを追加しました。'); | ||
}); | ||
}); |
103 changes: 81 additions & 22 deletions
103
samples/web-csr/dressca-frontend/admin/src/views/__tests__/ItemsEditView.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 30 additions & 10 deletions
40
samples/web-csr/dressca-frontend/admin/src/views/__tests__/ItemsView.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,39 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { flushPromises, mount } from '@vue/test-utils'; | ||
import { describe, it, expect, beforeAll } from 'vitest'; | ||
import { flushPromises, mount, VueWrapper } from '@vue/test-utils'; | ||
import { router } from '@/router'; | ||
import { createPinia, setActivePinia } from 'pinia'; | ||
import { createCustomErrorHandler } from '@/shared/error-handler/custom-error-handler'; | ||
import ItemsView from '@/views/catalog/ItemsView.vue'; | ||
|
||
describe('アイテム一覧画面のテスト', () => { | ||
it('アイテム一覧が表示できる', async () => { | ||
const pinia = createPinia(); | ||
setActivePinia(pinia); | ||
const customErrorHandler = createCustomErrorHandler(); | ||
const wrapper = mount(ItemsView, { | ||
global: { plugins: [pinia, router, customErrorHandler] }, | ||
}); | ||
async function getWrapper() { | ||
const pinia = createPinia(); | ||
setActivePinia(pinia); | ||
const customErrorHandler = createCustomErrorHandler(); | ||
return mount(ItemsView, { | ||
global: { plugins: [pinia, router, customErrorHandler] }, | ||
}); | ||
} | ||
describe('アイテム一覧が表示できる', () => { | ||
let wrapper: VueWrapper; | ||
|
||
beforeAll(async () => { | ||
wrapper = await getWrapper(); | ||
}); | ||
|
||
it('アイテム一覧画面に遷移できる', async () => { | ||
// Arrange | ||
// Act | ||
await flushPromises(); | ||
// Assert | ||
expect(wrapper.html()).toContain('カタログアイテム一覧'); | ||
}); | ||
|
||
it('アイテムが取得した個数分表示される', async () => { | ||
// Arrange | ||
const expectedItemCount = 11; | ||
// Act | ||
const tableRows = wrapper.find('tbody').findAll('tr'); | ||
// Assert | ||
expect(tableRows.length).toBe(expectedItemCount); | ||
}); | ||
}); |
Oops, something went wrong.