Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kflorence committed Sep 25, 2024
1 parent a82a2ca commit 5250045
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 44 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"test-lint": "standard"
},
"devDependencies": {
"chromedriver": "^125.0.3",
"chromedriver": "^128.0.3",
"mocha": "^10.4.0",
"parcel": "^2.12.0",
"selenium-webdriver": "^4.21.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/items/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export class Tile extends Item {
}

onTap (event) {
console.debug(this.coordinates.offset.toString(), this)
this.items.forEach((item) => item.onTap(event))
}

Expand All @@ -88,6 +87,7 @@ export class Tile extends Item {
}

onSelected (deselectedTile) {
console.debug(this.toString(), 'selected')
this.selected = true
this.group.bringToFront()
this.#ui.hexagon.style = this.styles.selected
Expand Down Expand Up @@ -119,7 +119,7 @@ export class Tile extends Item {
}

toString () {
return this.coordinates.offset.toString()
return `[${this.type}:${this.coordinates.offset.toString()}]`
}

update () {
Expand Down
9 changes: 2 additions & 7 deletions test/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PuzzleFixture {

this.elements.body = await this.driver.findElement(By.tagName('body'))
this.elements.canvas = await this.driver.findElement(By.id('puzzle'))
this.elements.modifiers = await this.driver.findElement(By.id('modifiers-mutable'))
this.elements.modifiers = await this.driver.findElement(By.id('modifiers'))
}

async clickModifier (name, options = {}) {
Expand Down Expand Up @@ -81,14 +81,9 @@ class PuzzleFixture {
return this.driver.wait(untilElementHasClass(this.elements.body, 'puzzle-solved'))
}

async selectModifier (name) {
const origin = this.#getModifier(name)
await this.driver.actions({ async: true }).move({ origin }).press().pause(501).release().perform()
}

async #getModifier (name) {
await this.driver.wait(until.elementIsVisible(this.elements.modifiers))
return await this.driver.findElement(By.className(`modifier-${name}`))
return await this.driver.findElement(By.css(`.modifier-${name}:not(.disabled)`))
}

static baseUrl = 'http://localhost:1234'
Expand Down
5 changes: 4 additions & 1 deletion test/puzzles/002.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ describe('Puzzle 002', function () {
before(puzzle.before)

it('should be solved', async function () {
await puzzle.clickTile(0, 0)
await puzzle.clickModifier('toggle')

await puzzle.clickTile(2, 0)
await puzzle.clickModifier('rotate')
await puzzle.clickModifier('toggle')

assert(await puzzle.isSolved())
})
Expand Down
5 changes: 3 additions & 2 deletions test/puzzles/003.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ describe('Puzzle 003', function () {
before(puzzle.before)

it('should be solved', async function () {
await puzzle.clickTile(2, 1)
await puzzle.selectModifier('rotate')
await puzzle.clickTile(2, 0)
await puzzle.clickModifier('rotate')

await puzzle.clickTile(0, 0)
await puzzle.clickModifier('rotate', { times: 3 })

assert(await puzzle.isSolved())
})
})
4 changes: 0 additions & 4 deletions test/puzzles/007.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ describe('Puzzle 007', function () {
await puzzle.clickModifier('move')
await puzzle.clickTile(1, 0)

await puzzle.clickTile(2, 2)
await puzzle.selectModifier('move')
await puzzle.clickTile(2, 3)
await puzzle.clickModifier('move')
await puzzle.clickTile(1, 4)

await puzzle.clickTile(2, 3)
await puzzle.selectModifier('move')
await puzzle.clickTile(1, 2)
await puzzle.clickModifier('rotate')
await puzzle.clickModifier('move')
Expand Down
4 changes: 0 additions & 4 deletions test/puzzles/009.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ describe('Puzzle 009', function () {
await puzzle.clickModifier('move')
await puzzle.clickTile(0, 0)

await puzzle.clickTile(1, 1)
await puzzle.selectModifier('move')
await puzzle.clickTile(1, 5)
await puzzle.clickModifier('move')
await puzzle.clickTile(2, 5)

await puzzle.clickTile(1, 5)
await puzzle.selectModifier('move')
await puzzle.clickTile(1, 4)
await puzzle.clickModifier('move')
await puzzle.clickTile(0, 5)
Expand Down
4 changes: 0 additions & 4 deletions test/puzzles/010.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ describe('Puzzle 010', function () {
await puzzle.clickModifier('move')
await puzzle.clickTile(2, 4)

await puzzle.clickTile(1, 1)
await puzzle.selectModifier('move')
await puzzle.clickTile(1, 5)
await puzzle.clickModifier('move')
await puzzle.clickTile(0, 5)

await puzzle.clickTile(1, 5)
await puzzle.selectModifier('move')
await puzzle.clickTile(1, 0)
await puzzle.clickModifier('move')
await puzzle.clickTile(2, 5)
Expand Down
2 changes: 0 additions & 2 deletions test/puzzles/011.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ describe('Puzzle 011', function () {
await puzzle.clickTile(2, 1)
await puzzle.isNotMasked()

await puzzle.clickTile(1, 1)
await puzzle.selectModifier('rotate')
await puzzle.clickTile(2, 0)
await puzzle.clickModifier('rotate', { times: 3 })

Expand Down
12 changes: 0 additions & 12 deletions test/puzzles/012.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,29 @@ describe('Puzzle 012', function () {
await puzzle.clickTile(4, 4)
await puzzle.clickModifier('rotate', { times: 3 })

await puzzle.clickTile(3, 0)
await puzzle.selectModifier('move')
await puzzle.clickTile(4, 1)
await puzzle.clickModifier('move')
await puzzle.clickTile(1, 4)
await puzzle.isMasked()
await puzzle.clickTile(3, 1)

await puzzle.clickTile(3, 6)
await puzzle.selectModifier('move')
await puzzle.clickTile(4, 4)
await puzzle.clickModifier('move')
await puzzle.clickTile(1, 2)
await puzzle.isMasked()
await puzzle.clickTile(3, 5)

await puzzle.clickTile(4, 1)
await puzzle.selectModifier('move')
await puzzle.clickTile(3, 2)
await puzzle.clickModifier('move')
await puzzle.clickTile(2, 2)

await puzzle.clickTile(4, 4)
await puzzle.selectModifier('move')
await puzzle.clickTile(3, 4)
await puzzle.clickModifier('move')
await puzzle.clickTile(2, 3)

await puzzle.clickTile(4, 1)
await puzzle.selectModifier('rotate')
await puzzle.clickTile(2, 0)
await puzzle.clickModifier('rotate', { times: 2 })

await puzzle.clickTile(4, 4)
await puzzle.selectModifier('rotate')
await puzzle.clickTile(2, 5)
await puzzle.clickModifier('rotate', { times: 4 })

Expand Down

0 comments on commit 5250045

Please sign in to comment.