Skip to content

Commit

Permalink
Merge pull request #86 from poketrax/test-stability
Browse files Browse the repository at this point in the history
Test stability
  • Loading branch information
jgunzelman88 authored Jun 29, 2022
2 parents eed2202 + 1f31c90 commit 0c428bf
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"projectId": "bjcr3a",
"defaultCommandTimeout": 15000
"defaultCommandTimeout": 180000
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"start-electron-win": "set ELECTRON_START_URL=http://localhost:3000 && set NODE_ENV=development && electron .",
"start-test-server": "export NODE_ENV=development && node src/server/test-server.js",
"build": "vite build",
"test": "export NODE_ENV=test && mocha --timeout 5000",
"test": "export NODE_ENV=test && mocha --timeout 60000",
"test-cypress": "npx cypress run",
"make": "vite build && electron-builder"
},
Expand Down
2 changes: 1 addition & 1 deletion src/server/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async function checkForSoftwareUpdate() {
return new Promise(
async (resolve, _) => {
try {
let currentVerion = app.getVersion()
let currentVerion = process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'development' ? '1.0.0' : app.getVersion()
let release = await axios.get('https://api.github.com/repos/poketrax/poketrax/releases/latest')
let latestVersion = release.data.name.replace("v", "").replace("-beta", "")
resolve(compver(currentVerion, latestVersion) < 0 ? true : false)
Expand Down
4 changes: 2 additions & 2 deletions src/server/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,11 @@ app.put("/collections/card", bodyParser.json(),
let found = db.prepare(findSql).get(card)
await DB.getPrices(card)
if (found != null) {
db.prepare("UPDATE collectionCards SET count = $count, grade = $grade, paid = $paid WHERE cardId = $cardId AND variant = $variant AND grade = $grade")
await db.prepare("UPDATE collectionCards SET count = $count, grade = $grade, paid = $paid WHERE cardId = $cardId AND variant = $variant AND grade = $grade")
.run({ 'count': card.count, 'grade': card.grade, 'paid': card.paid, 'cardId': card.cardId, 'variant': card.variant })
res.status(201).send()
} else {
db.prepare("INSERT INTO collectionCards (cardId, collection, variant, paid, count, grade) VALUES ($cardId, $collection, $variant, $paid, $count, $grade)")
await db.prepare("INSERT INTO collectionCards (cardId, collection, variant, paid, count, grade) VALUES ($cardId, $collection, $variant, $paid, $count, $grade)")
.run({ 'cardId': card.cardId, 'collection': card.collection, 'variant': card.variant, 'paid': card.paid, 'count': card.count, 'grade': card.grade })
res.status(201).send()
}
Expand Down
2 changes: 1 addition & 1 deletion test/rest-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ describe(
}
)
})

it('Add Cards', async () => {
let cards = JSON.parse(fs.readFileSync('./test/testCollection.json'))
for (let card of cards) {
Expand All @@ -123,7 +124,6 @@ describe(
})

it('Test Get Cards', async () => {
await new Promise(resolve => setTimeout(resolve, 3000));
let resCol1 = await axios.get("http://localhost:3030/collections/collection1/cards/0")
let resCol2 = await axios.get("http://localhost:3030/collections/collection2/cards/0")
assert.equal(resCol1.data.total, 3, `Number of cards in Collection 1 not right ${JSON.stringify(resCol1.data)}`)
Expand Down

0 comments on commit 0c428bf

Please sign in to comment.