Skip to content

Commit

Permalink
chore(cypress): Fix tests and update setup
Browse files Browse the repository at this point in the history
  • Loading branch information
on3iro committed Oct 8, 2023
1 parent 5388a00 commit ed73faf
Show file tree
Hide file tree
Showing 11 changed files with 367 additions and 423 deletions.
12 changes: 12 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from 'cypress'

export default defineConfig({
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
baseUrl: 'http://localhost:3000',
},
})
3 changes: 0 additions & 3 deletions cypress.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ describe('Expedition creation and run through', () => {
})

it('can run through the first battle', () => {
cy.get('h2')
cy.visit('expeditions')
.get('h2')
.contains('Test-Expedition 1')
.click()
.get('[data-test="btn-battle"]')
Expand Down Expand Up @@ -60,40 +61,44 @@ describe('Expedition creation and run through', () => {
.contains('Reflective Conduit')
.click()
.get('p')
.contains('Psychic Eruption')
.contains('Combustion')
.click()
.get('[data-test="btn-continue"]')
.click()
})

it('can run through the second battle', () => {
cy.visit('expeditions').get('h2').contains('Test-Expedition 1').click()
cy.get('[data-test="btn-battle"]').eq(1).click()
cy.get('[data-test="btn-start-battle"]').click()
cy.get('[data-test="btn-battle-won"]').click()
cy.get('p').contains('Energized Rubidium').click()
cy.get('p').contains('Primordial Fetish').click()
cy.get('p').contains('Char').click()
cy.get('p').contains('Catalyst').click()
cy.get('[data-test="btn-continue"]').click()
})

it('can run through the third battle', () => {
cy.visit('expeditions').get('h2').contains('Test-Expedition 1').click()
cy.get('[data-test="btn-battle"]').eq(2).click()
cy.get('[data-test="btn-start-battle"]').click()
cy.get('[data-test="btn-battle-won"]').click()
cy.get('p').contains('Searing Ruby').click()
cy.get('p').contains('Scholars Opus').click()
cy.get('p').contains('Carbonize').click()
cy.get('p').contains('Reduce To Ash').click()
cy.get('[data-test="btn-continue"]').click()
})

it('can run through the last battle', () => {
cy.visit('expeditions').get('h2').contains('Test-Expedition 1').click()
cy.get('[data-test="btn-battle"]').eq(3).click()
cy.get('[data-test="btn-start-battle"]').click()
cy.get('[data-test="btn-battle-won"]').click()
cy.get('[data-test="modal__btn-close"]').click()
})

it('has correct final barracks', () => {
cy.visit('expeditions').get('h2').contains('Test-Expedition 1').click()
cy.get('[data-test="btn-open-barracks"]').click()

// Mages
Expand All @@ -120,16 +125,16 @@ describe('Expedition creation and run through', () => {

// Supply
cy.get('[data-test="supply"]').click({ force: true })
cy.get('p').contains('Volcanic Glass').should('be.visible')
cy.get('p').contains('Bloodstone Jewel').should('be.visible')
cy.get('p').contains('Scoria Slag').should('be.visible')
cy.get('p').contains('Oblivium Resin').should('be.visible')
cy.get('p').contains('Transmogrifier').should('be.visible')
cy.get('p').contains('Breach Extractor').should('be.visible')
cy.get('p').contains('Amplify Vision').scrollIntoView()
cy.get('p').contains('Amplify Vision').should('be.visible')
cy.get('p').contains('Feral Lightning').should('be.visible')
cy.get('p').contains('Wildfire Whip').scrollIntoView()
cy.get('p').contains('Wildfire Whip').should('be.visible')
cy.get('p').contains('Celestial Spire').should('be.visible')
cy.get('p').contains('Scrying Bolt').should('be.visible')
cy.get('p').contains('Pyromancy').should('be.visible')

// Treasures
cy.get('[data-test="treasure"]').click({ force: true })
Expand Down Expand Up @@ -177,22 +182,19 @@ describe('Expedition creation and run through', () => {
cy.get('p').contains('Vriswood Amber').should('be.visible')
cy.get('p').contains('Dread Diamond').should('be.visible')
cy.get('p').contains('Reflective Conduit').should('be.visible')
cy.get('p')
.contains('Psychic Eruption')
.scrollIntoView()
.should('be.visible')
cy.get('p').contains('Combustion').scrollIntoView().should('be.visible')
cy.get('p').contains('Energized Rubidium').should('be.visible')
cy.get('p')
.contains('Primordial Fetish')
.scrollIntoView()
.should('be.visible')
cy.get('p').contains('Char').should('be.visible')
cy.get('p').contains('Catalyst').should('be.visible')
cy.get('p').contains('Searing Ruby').should('be.visible')
cy.get('p').contains('Scholars Opus').should('be.visible')
})

it('shows the correct data inside the overview', () => {
cy.get('[data-test="modal__btn-close"]').click()
cy.visit('expeditions').get('h2').contains('Test-Expedition 1').click()
cy.get('[data-test="backlink"]').click()

cy.get('[data-test="info--expedition-finished"]')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('seeds', () => {
cy.get('[data-test="btn-battle-won"]').click()
cy.get('p').contains('Dread Diamond').click()
cy.get('p').contains('Reflective Conduit').click()
cy.get('p').contains('Psychic Eruption').click()
cy.get('p').contains('Combustion').click()
cy.get('[data-test="btn-continue"]').click()

cy.get('[data-test=btn-battle]').eq(1).click()
Expand All @@ -60,6 +60,7 @@ describe('seeds', () => {
})

it('should produce same results in copy if everything is unchanged and done in the same order', () => {
cy.visit('expeditions').wait(1000)
cy.get('[data-test="Test: Base Expedition"]')
.get('[data-test=btn-copy]')
.click()
Expand All @@ -82,7 +83,7 @@ describe('seeds', () => {
cy.get('[data-test="btn-battle-won"]').click()
cy.get('p').contains('Dread Diamond').click()
cy.get('p').contains('Reflective Conduit').click()
cy.get('p').contains('Psychic Eruption').click()
cy.get('p').contains('Combustion').click()
cy.get('[data-test="btn-continue"]').click()

cy.get('[data-test=btn-battle]').eq(1).click()
Expand All @@ -99,6 +100,7 @@ describe('seeds', () => {
})

it('should produce correct nemesis if seed is identical but things are done differently', () => {
cy.visit('expeditions').wait(1000)
cy.get('[data-test="Test: Base Expedition"]')
.get('[data-test=btn-copy]')
.click()
Expand All @@ -114,7 +116,7 @@ describe('seeds', () => {
cy.get('[data-test="btn-battle-won"]').click()
cy.get('p').contains('Summonite').click()
cy.get('p').contains('Conclave Scroll').click()
cy.get('p').contains('Embody Flame').click()
cy.get('p').contains('Storm Vapor').click()

cy.get('[data-test="btn-continue"]').click()

Expand All @@ -132,6 +134,7 @@ describe('seeds', () => {
})

it('should procude completely different results when seed is changed', () => {
cy.visit('expeditions').wait(1000)
cy.get('[data-test="Test: Base Expedition"]')
.get('[data-test=btn-copy]')
.click()
Expand All @@ -146,9 +149,9 @@ describe('seeds', () => {
cy.get('[data-test="btn-start-battle"]').click()

cy.get('[data-test="btn-battle-won"]').click()
cy.get('p').contains('Muted Lacosite').click()
cy.get('p').contains('Voidium Spike').click()
cy.get('p').contains('Caged Fire').scrollIntoView().click()
cy.get('p').contains('Jagged Lightning').click()
cy.get('p').contains('Convection Field').click()

cy.get('[data-test="btn-continue"]').click()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ describe('Custom Supply Setup creation and run through', () => {
})

it('cancels edit of an existing custom supply setup', () => {
cy.visit('settings')
cy.wait(1000)
cy.get('[data-test=SupplySetups]').click({ force: true })
cy.get('span')
.contains('Test-Supply-Setup')
.closest('[data-test=supply-setup-wrapper]')
Expand All @@ -73,6 +76,9 @@ describe('Custom Supply Setup creation and run through', () => {
})

it('deletes an existing custom supply setup', () => {
cy.visit('settings')
cy.wait(1000)
cy.get('[data-test=SupplySetups]').click({ force: true })
cy.get('span')
.contains('Test-Supply-Setup')
.closest('[data-test=supply-setup-wrapper]')
Expand All @@ -83,6 +89,9 @@ describe('Custom Supply Setup creation and run through', () => {
})

it('creates a supply setup with all card types EXCEPT ANY and all different thresholds <,>,=,<=,>=, OR', () => {
cy.visit('settings')
cy.wait(1000)
cy.get('[data-test=SupplySetups]').click({ force: true })
cy.get('[data-test=btn-add-custom-supply-setup]').click()

// Set supply setup nam
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ describe('The landing page "/"', () => {
})

it('redirects to the nemesis randomizer', () => {
cy.location().should(loc => {
cy.visit('/')
cy.location().should((loc) => {
expect(loc.href).to.eq('http://localhost:3000/randomizer/nemesis')
})

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@types/classnames": "^2.2.7",
"@types/styled-components": "^5.1.2",
"babel-plugin-macros": "^2.5.0",
"cypress": "^5.2.0",
"cypress": "13.3.0",
"husky": "^4.0.10",
"prettier": "^2.1.2",
"pretty-quick": "^3.0.2",
Expand Down
Loading

0 comments on commit ed73faf

Please sign in to comment.