Skip to content

Commit

Permalink
updated nightly.yml; code formattting
Browse files Browse the repository at this point in the history
  • Loading branch information
far11ven committed Sep 2, 2023
1 parent 521ab12 commit 522f679
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 110 deletions.
10 changes: 5 additions & 5 deletions v13/.github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Doc-AI Test Automation (Nightly)
name: Test Execution (Nightly)
on:
workflow_dispatch:
schedule:
# Scheduled to execute at 10:00 PM in UTC which means 12:00 AM in CEST (Day-light Saving)
- cron: 0 9 * * 1,2,3,4,5

env:
ENV_NAME: "stg"
TAGS: "@login"
ENV_NAME: "qa"
TAGS: "@all"

jobs:
nightly_run:
Expand All @@ -30,14 +30,14 @@ jobs:
run: npm install

# Execute automated tests nightly and send execution summary to cypress cloud dashboard
- name: Doc-AI Test Automation Nightly Execution
- name: Test Execution Nightly Execution
id: run_step
uses: cypress-io/[email protected]
continue-on-error: true
with:
install: false
record: true
command: node runner.js cypress run --e2e --env envFile=${{ env.ENV_NAME }},TAGS=${{ env.TAGS }} --record --key ${{ secrets.DOC_AI_TESTING_CYPRESS_RECORD_KEY }} --tag "nightly"
command: node runner.js cypress run --e2e --env envFile=${{ env.ENV_NAME }},TAGS=${{ env.TAGS }} --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --tag "nightly"

# Cypress Test Result Details
- name: Print Cypress Cloud URL
Expand Down
114 changes: 57 additions & 57 deletions v13/cypress/e2e/common/stepDefinitions/API/apiSteps.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';

Given('As a user I want to execute Pokemon GET api for Pokemon {string}', (pokename) => {
cy.request({
method: 'GET',
url: 'https://pokeapi.co/api/v2/pokemon/' + pokename,
headers: {
'Content-Type': 'application/json'
},
failOnStatusCode:false
}).as('get_pokemon_data')
});
Then('Verify {string} response status code is {int}', (requestAliasName, statusCode) => {
cy.get(`${requestAliasName}`).should((response)=> {
expect(response.status).to.eq(statusCode);
})
});

Then('Verify response details for Pokemon {string}', (pokename) => {
cy.get('@get_pokemon_data').then((response)=> {
expect(response.body).to.have.property('abilities');
//Different ways of validating nested properties
//1st Way
expect(response.body).to.have.nested.property('forms[0].name','pikachu');
//2nd Way
expect(response.body.forms[0]).to.have.property('name','pikachu');
//3rd Way
const name = response.body.forms[0].name;
assert.equal(name, pokename.toLowerCase());
expect(response).to.have.property('headers');

})
});

When('I save the user id in Test Store', () => {
cy.get('@get_pokemon_data').then((response)=> {
//save pokemon id
cy.saveState("PokemonData>PokemonID", response.body.id)
})
});

When('I make a GET request on {string} endpoint with the stored id', () => {
cy.getState("PokemonData>PokemonID").then(pokeID => {
cy.request({
method: 'GET',
url: 'https://pokeapi.co/api/v2/pokemon/' + pokeID,
headers: {
'Content-Type': 'application/json'
},
failOnStatusCode:false
}).as('get_pokemon_data_by_id')
})
});
cy.request({
method: 'GET',
url: 'https://pokeapi.co/api/v2/pokemon/' + pokename,
headers: {
'Content-Type': 'application/json'
},
failOnStatusCode: false
}).as('get_pokemon_data')

})

Then('Verify {string} response status code is {int}', (requestAliasName, statusCode) => {
cy.get(`${requestAliasName}`).should((response) => {
expect(response.status).to.eq(statusCode)

})
})

Then('Verify response details for Pokemon {string}', (pokename) => {
cy.get('@get_pokemon_data').then((response) => {

expect(response.body).to.have.property('abilities')
//Different ways of validating nested properties
//1st Way
expect(response.body).to.have.nested.property('forms[0].name', 'pikachu')
//2nd Way
expect(response.body.forms[0]).to.have.property('name', 'pikachu')
//3rd Way
const name = response.body.forms[0].name;
assert.equal(name, pokename.toLowerCase())

expect(response).to.have.property('headers')


})
})

When('I save the user id in Test Store', () => {
cy.get('@get_pokemon_data').then((response) => {
//save pokemon id
cy.saveState("PokemonData>PokemonID", response.body.id)
})

})

When('I make a GET request on {string} endpoint with the stored id', () => {
cy.getState("PokemonData>PokemonID").then(pokeID => {
cy.request({
method: 'GET',
url: 'https://pokeapi.co/api/v2/pokemon/' + pokeID,
headers: {
'Content-Type': 'application/json'
},
failOnStatusCode: false
}).as('get_pokemon_data_by_id')
})
})
34 changes: 17 additions & 17 deletions v13/cypress/e2e/common/stepDefinitions/DB/dbSteps.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';

Given('I execute select all query on pokemon DB',() => {
cy.task("DATABASE", {
dbConfig: Cypress.env("DB"),
sql: `
Given('I execute select all query on pokemon DB', () => {
cy.task("DATABASE", {
dbConfig: Cypress.env("DB"),
sql: `
select * from pokemon
`
}).then((result) => {
console.log(result.rows)
});
});
}).then((result) => {
console.log(result.rows)
})
})

When('I execute selet query on pokemon DB, where name equals {string}',(pokemonName) => {
cy.task("DATABASE", {
dbConfig: Cypress.env("DB"),
sql: `
When('I execute selet query on pokemon DB, where name equals {string}', (pokemonName) => {
cy.task("DATABASE", {
dbConfig: Cypress.env("DB"),
sql: `
select * from pokemon where Poke_Name = '${pokemonName}'
`
}).then((result) => {
console.log(result.rows[0]);
expect(result.rows[0].Poke_Name).to.have.string(`${pokemonName}`);
});
});
}).then((result) => {
console.log(result.rows[0])
expect(result.rows[0].Poke_Name).to.have.string(`${pokemonName}`)
})
})
45 changes: 18 additions & 27 deletions v13/cypress/e2e/common/stepDefinitions/UI/commonSteps.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,25 @@ import HomePage from '../../pages/HomePage/HomePage';
import ResultPage from '../../pages/ResultPage/ResultPage';
const addContext = require('mochawesome/addContext');

const homePage = new HomePage();
const resultPage = new ResultPage();
const homePage = new HomePage()
const resultPage = new ResultPage()

Given('I open the Google web url', () => {
cy.visit('/');
cy.reportLog("This is Subject");
cy.reportLogKV("This is key!","This is value!");
});

Then(
'I verify title of web page as {string}',
(title) => {
cy.title().should('include', title);
}
);
cy.visit('/')
cy.reportLog("This is Subject")
cy.reportLogKV("This is key!", "This is value!")
})

When(
'I provide search query as {string}',
(query) => {
homePage.clickSearchTxtBox();
homePage.typeInSearchTxtBox(query);
homePage.submitSearchQuery();
}
);
Then('I verify title of web page as {string}', (title) => {
cy.title().should('include', title)
})

Then(
'Verify first search result to match {string} keyword',
(search_keyword) => {
let result = resultPage.verifyFirstResult(search_keyword);
}
);
When('I provide search query as {string}', (query) => {
homePage.clickSearchTxtBox()
homePage.typeInSearchTxtBox(query)
homePage.submitSearchQuery()
})

Then('Verify first search result to match {string} keyword', (search_keyword) => {
let result = resultPage.verifyFirstResult(search_keyword)
})
8 changes: 4 additions & 4 deletions v13/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "cypress-testframework",
"name": "Cypress-TestFramework",
"version": "2.0.0",
"description": "",
"repository": "",
"main": "",
"scripts": {
"cy:test": "cypress run --e2e",
"cy:open": "cypress open --e2e",
"cy:open:qa": "cypress open --e2e --browser chrome --env envFile=qa",
"cy:test:dev": "node runner.js cypress run --env envFile=dev",
"cy:open:qa": "cypress open --e2e --browser chrome --env envFile=qa",
"cy:test:qa": "node runner.js cypress run --env envFile=qa,TAGS=\"@all\"",
"cy:record:qa": "node runner.js cypress run --env envFile=qa,TAGS=\"@all\" --video --record --key 04cca009-ab36-4310-b1fd-4f09a4a1a75d --tag \"release,v1.10\"",
"cy:record:parallel:qa": "node runner.js cypress run --env envFile=qa,TAGS=\"@all\" --record --parallel --key 04cca009-ab36-4310-b1fd-4f09a4a1a75d --tag \"release,v1.10\""
"cy:record:qa": "node runner.js cypress run --env envFile=qa,TAGS=\"@all\" --video --record --key 04cca009-ab36-4310-b1fd-4f09a4a1a75d --tag \"release, pre\"",
"cy:record:parallel:qa": "node runner.js cypress run --env envFile=qa,TAGS=\"@all\" --record --parallel --key 04cca009-ab36-4310-b1fd-4f09a4a1a75d --tag \"release, pre\""
},
"author": "far11ven",
"license": "ISC",
Expand Down

0 comments on commit 522f679

Please sign in to comment.