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

E2e test order cards #356

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
32 changes: 32 additions & 0 deletions .github/workflows/prod_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: e2e prod test
on:
push:
branches:
- master
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
branches:
- master
jobs:
test:
name: Run tests and publish test coverage
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run env -- mocha --timeout 10000 --recursive --require babel-register test_prod/
env:
API_KEY: ${{ secrets.API_KEY }}
API_SECRET: ${{ secrets.API_SECRET }}
25 changes: 25 additions & 0 deletions test_prod/razorpay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

const Razorpay = require("../dist/razorpay");
let request = require('request-promise');

class RazorpayBeta extends Razorpay {
constructor(options) {
super(options)
this.api.rq = request.defaults({
baseUrl: options.hostUrl,
json: true,
auth: {
user: options.key_id,
pass: options.key_secret
}
})
}
}


module.exports = new RazorpayBeta({
key_id: process.env.API_KEY || "",
key_secret: process.env.API_SECRET || "",
hostUrl : "https://api-web.dev.razorpay.in"
});
32 changes: 32 additions & 0 deletions test_prod/resources/addon.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict'

var assert = require('assert');
const rzpInstance = require('../razorpay')
const equal = require('deep-equal');
const { items } = require('../razorpay');

let addonId = null;

describe('ADDON', () => {

it('Fetch all addons', (done) => {

rzpInstance.addons.all({ "count": 1 }).then((response) => {
if (response.hasOwnProperty('items')) {
if ('id' in response.items[0]) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check for status code 200 here as well

addonId = response.items[0].id
}
}
assert.ok(response.hasOwnProperty('count'))
assert.ok(response.hasOwnProperty('items'))
done()
}).catch(err => console.log(err))
})

it('fetch order\'s payments', (done) => {
rzpInstance.addons.fetch(addonId).then((response) => {
assert.ok(response.hasOwnProperty('id'))
done()
})
})
})
17 changes: 17 additions & 0 deletions test_prod/resources/cards.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

var assert = require('assert');
const rzpInstance = require('../razorpay')
const equal = require('deep-equal');
const { items } = require('../razorpay');

let cardId = "card_LcQgzpfvWP0UKF";

describe('CARDS', () => {
it('fetch order\'s payments', (done) => {
rzpInstance.cards.fetch(cardId).then((response) => {
assert.ok(response.hasOwnProperty('id'))
done()
})
})
})