Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Cypress E2E test for Creatodon feature's #1245

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintignore
Expand Up @@ -11,3 +11,6 @@
/tmp/**
/vendor/**
!.eslintrc.js
cypress.config.ts
cypress/**

4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -66,3 +66,7 @@ docker-compose.override.yml

# GoogleCloudVision Key
key.json

# cypress ignore file
cypress.env.json
cypress/videos
12 changes: 12 additions & 0 deletions cypress.config.ts
@@ -0,0 +1,12 @@
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
defaultCommandTimeout: 10000,
experimentalSourceRewriting: true,
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
12 changes: 12 additions & 0 deletions cypress/e2e/access_explore_spec.cy.ts
@@ -0,0 +1,12 @@
// エクスプローラーへのアクセステスト
describe('access to /explore', () => {
beforeEach(() => {
cy.visit('/explore');
});

// エクスプローラーへアクセスできているかをチェック
it('url check', () => {
cy.url().should('include', '/explore');
cy.url().should('eq', 'http://localhost:3000/explore');
});
});
33 changes: 33 additions & 0 deletions cypress/e2e/custom_theme_chane_spec.cy.ts
@@ -0,0 +1,33 @@
// カスタムテーマの変更テスト
describe('custom theme change test', () => {
// ログイン処理
beforeEach(() => {
cy.visit('/auth/sign_in');
cy.get('#user_email').type(Cypress.env('email'));
cy.get('#user_password').type(`${Cypress.env('password')}{enter}`);
});

// デフォルトのテーマに変更
it('change default theme', () => {
cy.visit('/settings/preferences/appearance');
cy.get('#user_settings_attributes_theme').select('default');
cy.get('.btn').click();
cy.visit('/home');
});

// 「琥珀の意味」のカスタムテーマに変更
it('change mean of amber theme', () => {
cy.visit('/settings/preferences/appearance');
cy.get('#user_settings_attributes_theme').select('mean-of-amber');
cy.get('.btn').click();
cy.visit('/home');
});

// 「Twitter」のカスタムテーマに変更
it('change twitetr theme', () => {
cy.visit('/settings/preferences/appearance');
cy.get('#user_settings_attributes_theme').select('twitter');
cy.get('.btn').click();
cy.visit('/home');
});
});
34 changes: 34 additions & 0 deletions cypress/e2e/feature_tags_timelin_spec.cy.ts
@@ -0,0 +1,34 @@
// 注目のハッシュタグタイムライン機能のE2Eテスト
describe('feature tag timeline', () => {
// URLのチェック
it('url check', () => {
cy.visit('/@S_H_/tagged/HALO');
cy.url().should('include', '/@S_H_/tagged/HALO');
cy.url().should('eq', 'http://localhost:3000/@S_H_/tagged/HALO');
});

// アカウントの詳細画面で注目のハッシュタグタイムラインが項目としてあるかをチェック
it('include feature tag timeline', () => {
cy.visit('/@S_H_');
cy.get('.feature_tag_timeline');
cy.contains('HALO');
});

// ログイン後にアカウントの詳細画面で注目のハッシュタグタイムラインが項目としてあるかをチェック
it('login to Creatodon and my feature tag timeline exist', () => {
// ログイン処理
cy.visit('/auth/sign_in');
cy.get('#user_email').type(Cypress.env('email'));
cy.get('#user_password').type(`${Cypress.env('password')}{enter}`);

// アカウントの詳細画面で注目のハッシュタグタイムラインが項目としてあるかをチェック
cy.visit('/@S_H_');
cy.get('.feature_tag_timeline');
cy.contains('HALO');

// 注目のハッシュタグタイムラインが表示されるかをチェック
cy.visit('/@S_H_/tagged/HALO');
cy.get('.feature_tag_timeline');
cy.contains('HALO');
});
});
29 changes: 29 additions & 0 deletions cypress/e2e/login_spec.cy.ts
@@ -0,0 +1,29 @@
// ログイン周りのE2Eテスト
describe('access to login page', () => {
beforeEach(() => {
cy.visit('/auth/sign_in');
});

// ログイン画面のURLチェック
it('url check', () => {
cy.url().should('include', '/auth/sign_in');
cy.url().should('eq', 'http://localhost:3000/auth/sign_in');
});

// ログイン画面内にあるテキストのチェック
it('include login page text', () => {
cy.contains('Login to localhost');
cy.contains('E-mail address');
cy.contains('Password');
});

// 実際にログイン
it('login to Creatodon', () => {
// メールアドレスとパスワードを入力し、ログイン
cy.get('#user_email').type(Cypress.env('email'));
cy.get('#user_password').type(`${Cypress.env('password')}{enter}`);

// ログイン後の画面で投稿フォームが表示されているのを確認
cy.contains('投稿');
});
});
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
@@ -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 cypress/support/e2e.ts
@@ -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')
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -178,6 +178,7 @@
"@typescript-eslint/eslint-plugin": "^5.59.6",
"@typescript-eslint/parser": "^5.59.6",
"babel-jest": "^29.5.0",
"cypress": "^12.12.0",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
Expand Down