From 98105e460d4f1b7cc98fbd61fd64ecbda57615c9 Mon Sep 17 00:00:00 2001 From: sanjay Date: Fri, 9 Feb 2024 10:54:59 +0530 Subject: [PATCH 1/2] run cases on PR creation --- .github/workflows/apiRunner.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/apiRunner.yml b/.github/workflows/apiRunner.yml index 3632157..f453fb7 100644 --- a/.github/workflows/apiRunner.yml +++ b/.github/workflows/apiRunner.yml @@ -4,6 +4,9 @@ on: push: branches: - main + pull_request: + branches: + - main jobs: cypress-tests: From 9356980909a43a9f21bbf9765d0e958934eda5fe Mon Sep 17 00:00:00 2001 From: sanjay Date: Tue, 13 Feb 2024 16:17:48 +0530 Subject: [PATCH 2/2] optimize cases --- cypress/e2e/2-advanced-examples/test.cy.js | 11 +++++------ cypress/support/utils.js | 4 +++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cypress/e2e/2-advanced-examples/test.cy.js b/cypress/e2e/2-advanced-examples/test.cy.js index 5867326..851ca7b 100644 --- a/cypress/e2e/2-advanced-examples/test.cy.js +++ b/cypress/e2e/2-advanced-examples/test.cy.js @@ -3,10 +3,9 @@ import * as utils from "../../support/utils"; describe('Create Event Test', () => { let eventID = ""; let beforeEventLength = 0; - const accessToken = 'ya29.a0AfB_byD3M5aMm709yu_Ct_sU2aWKOVkl4hF4FnmdyN3FG8hQg2PtwmQGX0_q4wtfR40DhwvnZ8vUYhDao4DF9dzQPH1fPO20FiDYh3cbLpoxzIRIkF-0FaPgWp_FNUIWTrmWOa0xnhxghtwdPime_lgiphPw89W65XenJ8IaCgYKAS4SARESFQHGX2Mi5i494GxHDU1pr_h9I7iIoQ0174'; beforeEach(() => { - utils.handleCalendarAPIRequest('GET', 'https://www.googleapis.com/calendar/v3/calendars/primary/events', accessToken) + utils.handleCalendarAPIRequest('GET', 'https://www.googleapis.com/calendar/v3/calendars/primary/events', utils.auth) .then((response) => { expect(response.status).to.eq(200); beforeEventLength = response.body.items.length; @@ -29,7 +28,7 @@ describe('Create Event Test', () => { } }; - utils.handleCalendarAPIRequest('POST', 'https://www.googleapis.com/calendar/v3/calendars/primary/events', accessToken, requestBody).then((response) => { + utils.handleCalendarAPIRequest('POST', 'https://www.googleapis.com/calendar/v3/calendars/primary/events', utils.auth, requestBody).then((response) => { expect(response.status).to.equal(200); eventID = response.body.id; expect(eventID).to.be.not.null; @@ -40,7 +39,7 @@ describe('Create Event Test', () => { }); // Check event count - utils.handleCalendarAPIRequest('GET', 'https://www.googleapis.com/calendar/v3/calendars/primary/events', accessToken).then((response) => { + utils.handleCalendarAPIRequest('GET', 'https://www.googleapis.com/calendar/v3/calendars/primary/events', utils.auth).then((response) => { expect(response.status).to.eq(200); afterEventLength = response.body.items.length; expect(afterEventLength).to.eq(beforeEventLength + 1); @@ -51,11 +50,11 @@ describe('Create Event Test', () => { it('Should delete the event', () => { // Send a DELETE request to delete the event let afterEventLength; - utils.handleCalendarAPIRequest('DELETE', `https://www.googleapis.com/calendar/v3/calendars/primary/events/${eventID}`, accessToken).then((response) => { + utils.handleCalendarAPIRequest('DELETE', `https://www.googleapis.com/calendar/v3/calendars/primary/events/${eventID}`, utils.auth).then((response) => { expect(response.status).to.eq(204); }); - utils.handleCalendarAPIRequest('GET', `https://www.googleapis.com/calendar/v3/calendars/primary/events`, accessToken).then((response) => { + utils.handleCalendarAPIRequest('GET', `https://www.googleapis.com/calendar/v3/calendars/primary/events`, utils.auth).then((response) => { expect(response.status).to.eq(200); afterEventLength = response.body.items.length; expect(afterEventLength).to.eq(beforeEventLength - 1); diff --git a/cypress/support/utils.js b/cypress/support/utils.js index 61b1d25..28f88b3 100644 --- a/cypress/support/utils.js +++ b/cypress/support/utils.js @@ -37,4 +37,6 @@ export function getTomorrowTimestamp(hour, minute, timezoneOffset) { const adjustedDate = new Date(tomorrowDate.getTime() - (timezoneOffset * 60000)); return adjustedDate.toISOString().slice(0, -5) + "+05:30"; -} \ No newline at end of file +} + +export let auth = "ya29.a0AfB_byD0J8Ca2I9gDHRtrZzFnJW5hlQcpUBx63KlYJR7h50MLC0qwTTalqk_Tep8lX3HNv42IA-gezk9OCXBcaOfF0vRO3UOREhMvWIK0pv1LApAP1hPFgp02a4D0Dul2QT2EE8CN-_lEeHqhbHtpgDsPFT7eMOuFLfy4c0aCgYKARoSARESFQHGX2MihriChe4R-QeSfjM-bwlarQ0174"; \ No newline at end of file