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

Test stability #86

Merged
merged 8 commits into from
Jun 29, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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