Skip to content

Commit

Permalink
Merge branch 'main' into feat/nuxt-content
Browse files Browse the repository at this point in the history
# Conflicts:
#	apps/web/app/pages/index.vue
#	apps/web/nuxt.config.ts
#	bun.lockb
  • Loading branch information
jiyuujin committed Feb 13, 2024
2 parents 65b95ca + c49f7df commit 9049e12
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 1 deletion.
19 changes: 19 additions & 0 deletions apps/web/app/components/I18nSample.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script setup>
const { locale } = useI18n();

Check warning on line 2 in apps/web/app/components/I18nSample.vue

View workflow job for this annotation

GitHub Actions / lint (18.19.0)

'useI18n' is not defined
</script>

<template>
<form class="locale">
<select id="locale" v-model="locale">

Check warning on line 7 in apps/web/app/components/I18nSample.vue

View workflow job for this annotation

GitHub Actions / lint (18.19.0)

'v-model' should be on a new line
<option value="ja">ja</option>
<option value="en">en</option>
</select>
<p>{{ $t("welcome") }}</p>
</form>
</template>

<style scoped>
.locale {
margin: 20px;
}
</style>
1 change: 1 addition & 0 deletions apps/web/app/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<template>
<ContentDoc path="sample" />
<I18nSample />
<NuxtWelcome />
</template>
12 changes: 12 additions & 0 deletions apps/web/i18n.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default defineI18nConfig(() => ({

Check warning on line 1 in apps/web/i18n.config.ts

View workflow job for this annotation

GitHub Actions / lint (18.19.0)

'defineI18nConfig' is not defined
legacy: false,
locale: 'ja',
messages: {
en: {
welcome: 'Welcome!'
},
ja: {
welcome: 'ようこそ!'
}
}
}))
5 changes: 4 additions & 1 deletion apps/web/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({

Check warning on line 2 in apps/web/nuxt.config.ts

View workflow job for this annotation

GitHub Actions / lint (18.19.0)

'defineNuxtConfig' is not defined
srcDir: 'app/',
modules: ['@vuejs-jp/vuefes-ui', '@nuxt/content'],
modules: ['@vuejs-jp/vuefes-ui', '@nuxtjs/i18n', '@nuxt/content'],
i18n: {
vueI18n: './i18n.config.ts',
},
devtools: { enabled: true },
});
2 changes: 2 additions & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
"preview": "nuxt preview",
"lint": "eslint . --ext js,jsx,ts,tsx,vue --ignore-path .eslintignore",
"lint-fix": "eslint . --ext js,jsx,ts,tsx,vue --ignore-path .eslintignore --fix",
"cypress:open": "cypress open --config-file tests/cypress.config.ts",
"postinstall": "nuxt prepare"
},
"devDependencies": {
"@vuejs-jp/eslint-config": "workspace:*",
"@vuejs-jp/typescript-config": "workspace:*",
"@vuejs-jp/vuefes-ui": "workspace:*",
"cypress": "13.6.4",
"nuxt": "3.10.0"
}
}
26 changes: 26 additions & 0 deletions apps/web/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Cypress

アプリをビルドしてからローカルのサーバ上で実行し挙動をチェックします。

つまり統合テストなのでユニット単位で行うunit testとは別物です。

- コンポーネントごとにテストすることも可能です

基本的にページごとテストを作成していきます。

- シナリオテストのようなものも書けます。

## 方針

- 必要に応じて各ページの以下の挙動をチェックし、デグレードが発生していないかを確認することで思い切ったリファクタリングなどができるようになります。
- **レンダリング**
- しかるべきパーツがレンダーされているか
- 特定のボタンを押したあとちゃんとダイアログが出力されているか、または閉じられているか
- 特定のアクション後に期待どおりの項目を出力しているか(成功または失敗)
- **バリデーション**
- フォームのバリデーションが機能しているか
- **リクエスト**
- 期待どおりのパラメータを送信しているか
- ローカルやCIで動作チェックをするため、apiなどのデータ取得やデータ送信についてはすべてモックします。
- ただし、CIの実行時間を食いつぶさないようにミニマムなテストにしていきたいと思います。
- もしくは開発branchとmain branchにて実行内容を変えるなどの工夫をするかもしれません。
15 changes: 15 additions & 0 deletions apps/web/tests/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {

Check warning on line 5 in apps/web/tests/cypress.config.ts

View workflow job for this annotation

GitHub Actions / lint (18.19.0)

'on' is defined but never used

Check warning on line 5 in apps/web/tests/cypress.config.ts

View workflow job for this annotation

GitHub Actions / lint (18.19.0)

'config' is defined but never used
// implement node event listeners here
},
supportFile: 'tests/cypress/support/e2e.ts',
specPattern: 'tests/cypress/e2e/*.cy.ts',
},
downloadsFolder: 'tests/cypress/downloads',
fixturesFolder: 'tests/cypress/fixtures',
screenshotsFolder: 'tests/cypress/screenshots',
videosFolder: 'tests/cypress/videos',
});
5 changes: 5 additions & 0 deletions apps/web/tests/cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('template spec', () => {

Check warning on line 1 in apps/web/tests/cypress/e2e/spec.cy.ts

View workflow job for this annotation

GitHub Actions / lint (18.19.0)

'describe' is not defined
it('passes', () => {

Check warning on line 2 in apps/web/tests/cypress/e2e/spec.cy.ts

View workflow job for this annotation

GitHub Actions / lint (18.19.0)

'it' is not defined
cy.visit('https://example.cypress.io')

Check warning on line 3 in apps/web/tests/cypress/e2e/spec.cy.ts

View workflow job for this annotation

GitHub Actions / lint (18.19.0)

'cy' is not defined
})
})
5 changes: 5 additions & 0 deletions apps/web/tests/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
37 changes: 37 additions & 0 deletions apps/web/tests/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
20 changes: 20 additions & 0 deletions apps/web/tests/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
4 changes: 4 additions & 0 deletions apps/web/tests/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "@vuejs-jp/typescript-config/vue-library.json"
}
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"lint:fix": "turbo lint-fix"
},
"devDependencies": {
"@nuxtjs/i18n": "^8.1.0",
"@vuejs-jp/eslint-config": "workspace:*",
"@vuejs-jp/typescript-config": "workspace:*",
"turbo": "1.12.2"
Expand Down

0 comments on commit 9049e12

Please sign in to comment.