|
| 1 | +describe('総選挙内企画のページ', () => { |
| 2 | + beforeEach(() => { |
| 3 | + cy.visit('/events-in-event') |
| 4 | + }) |
| 5 | + |
| 6 | + it('ページタイトルが期待どおりであること', () => { |
| 7 | + cy.url().should('equal', 'http://localhost:3100/events-in-event') |
| 8 | + |
| 9 | + cy.get('title').should('have.text', '総選挙内企画 - 幻水総選挙2022') |
| 10 | + }) |
| 11 | + |
| 12 | + it('h1 タグ が期待どおりであること', () => { |
| 13 | + cy.url().should('equal', 'http://localhost:3100/events-in-event') |
| 14 | + |
| 15 | + cy.get('h1').should('have.length', 1) |
| 16 | + cy.get('h1').eq(0).should('have.text', '総選挙内企画') |
| 17 | + }) |
| 18 | + |
| 19 | + it('li タグ が期待どおりであること', () => { |
| 20 | + cy.url().should('equal', 'http://localhost:3100/events-in-event') |
| 21 | + |
| 22 | + // 単一コンポーネント内の li タグ |
| 23 | + cy.get('.hero li').should('have.length', 7) |
| 24 | + |
| 25 | + cy.get('.hero li').then(($hero_and_li_elements) => { |
| 26 | + const texts = $hero_and_li_elements.map((_index, item) => { |
| 27 | + // 各要素に対して jQuery の text() を実行している |
| 28 | + return Cypress.$(item).text() |
| 29 | + }) |
| 30 | + |
| 31 | + // jQuery のラップを外して単純な Array にする |
| 32 | + const gotTexts = texts.get() |
| 33 | + |
| 34 | + const expectedTexts = [ |
| 35 | + '選挙運動', |
| 36 | + '開票イラスト幻水総選挙本', |
| 37 | + '幻水総選挙本', |
| 38 | + 'お題小説', |
| 39 | + '推し台詞教えて!', |
| 40 | + 'オープニングイラスト・クロージングイラスト', |
| 41 | + 'ボーナス票', |
| 42 | + ] |
| 43 | + |
| 44 | + // Cypress のオブジェクトではないので expect を用いて比較している |
| 45 | + // そして配列なので deep.equal する |
| 46 | + expect(gotTexts).to.deep.equal(expectedTexts) |
| 47 | + }) |
| 48 | + }) |
| 49 | +}) |
| 50 | + |
| 51 | +describe('総選挙内企画のページ(英語版)', () => { |
| 52 | + beforeEach(() => { |
| 53 | + cy.visit('/en/events-in-event') |
| 54 | + }) |
| 55 | + |
| 56 | + it('ページタイトルが期待どおりであること', () => { |
| 57 | + cy.url().should('equal', 'http://localhost:3100/en/events-in-event') |
| 58 | + |
| 59 | + cy.get('title').should('have.text', 'Projects - Gensosenkyo 2022') |
| 60 | + }) |
| 61 | + |
| 62 | + it('h1 タグ が期待どおりであること', () => { |
| 63 | + cy.url().should('equal', 'http://localhost:3100/en/events-in-event') |
| 64 | + |
| 65 | + cy.get('h1').should('have.length', 1) |
| 66 | + cy.get('h1').eq(0).should('have.text', 'Projects') |
| 67 | + }) |
| 68 | +}) |
0 commit comments