Skip to content

Commit

Permalink
1)Update cypress to latest version to support execution on latest chr…
Browse files Browse the repository at this point in the history
…ome and edge browser (#988)

1)Update cypress to latest version to support execution on latest chrome and edge browser (#988)
2)Update cypress tests to latest changes in aps portal and gwa cli
3)Update cypress tests to latest methods in latest cypress version to clear cookies and session storage

Co-authored-by: Niraj Patel <niraj.patel@gov.bc.ca>
  • Loading branch information
ikethecoder and nirajCITZ committed Feb 14, 2024
1 parent 65474bd commit 2282d60
Show file tree
Hide file tree
Showing 52 changed files with 306 additions and 398 deletions.
48 changes: 24 additions & 24 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,30 @@ services:
- ./local/feeder-init:/tmp
networks:
- aps-net
cypress:
image: aps-cypress-e2e:latest
container_name: cypress-e2e
entrypoint: sh -c "chmod +x /tmp/entrypoint.sh && /tmp/entrypoint.sh"
environment:
- CYPRESS_RECORD_KEY=${CY_RECORD_KEY}
- CYPRESS_PROJECT_ID=${CY_PROJECT_ID}
- RUN_ENV=${CY_EXECUTION_ENV}
- COMMIT_INFO_BRANCH=${CY_COMMIT_BRANCH}
- COMMIT_INFO_SHA=${CY_COMMIT_SHA}
- COMMIT_INFO_AUTHOR=${CY_COMMIT_AUTHOR}
- COMMIT_INFO_MESSAGE=${CY_COMMIT_MESSAGE}
- COMMIT_INFO_REMOTE=${CY_REPO_URL}
- COMMIT_INFO_EMAIL=${CY_COMMIT_AUTHOR_EMAIL}
depends_on:
- feeder-seeding
build:
context: ./e2e
dockerfile: Dockerfile
volumes:
- ./e2e/coverage:/e2e/coverage
- ./e2e/results:/e2e/results
networks:
- aps-net
# cypress:
# image: aps-cypress-e2e:latest
# container_name: cypress-e2e
# entrypoint: sh -c "chmod +x /tmp/entrypoint.sh && /tmp/entrypoint.sh"
# environment:
# - CYPRESS_RECORD_KEY=${CY_RECORD_KEY}
# - CYPRESS_PROJECT_ID=${CY_PROJECT_ID}
# - RUN_ENV=${CY_EXECUTION_ENV}
# - COMMIT_INFO_BRANCH=${CY_COMMIT_BRANCH}
# - COMMIT_INFO_SHA=${CY_COMMIT_SHA}
# - COMMIT_INFO_AUTHOR=${CY_COMMIT_AUTHOR}
# - COMMIT_INFO_MESSAGE=${CY_COMMIT_MESSAGE}
# - COMMIT_INFO_REMOTE=${CY_REPO_URL}
# - COMMIT_INFO_EMAIL=${CY_COMMIT_AUTHOR_EMAIL}
# depends_on:
# - feeder-seeding
# build:
# context: ./e2e
# dockerfile: Dockerfile
# volumes:
# - ./e2e/coverage:/e2e/coverage
# - ./e2e/results:/e2e/results
# networks:
# - aps-net
kong-db:
image: postgres:12.8
container_name: kong-db
Expand Down
2 changes: 1 addition & 1 deletion e2e/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ COPY package.json /e2e
COPY package-lock.json /e2e
COPY *.yml /e2e
COPY entrypoint.sh /tmp
COPY gwa /usr/local/bin
# COPY gwa /usr/local/bin
ADD cypress /e2e/cypress

RUN npm install
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/pageObjects/apiDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ApiDirectoryPage {
cy.contains('a', product.name, { timeout: 10000 }).should('be.visible');
cy.contains(product.name).click()
if (elevatedAccess) {
cy.contains('For elevated access, please Request Access').should('be.visible');
cy.contains('For elevated access, please request acces').should('be.visible');
}
cy.get(this.rqstAccessBtn).click()
cy.get(this.appSelect).select(app.name)
Expand Down
6 changes: 3 additions & 3 deletions e2e/cypress/support/auth-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ Cypress.Commands.add('resetCredential', (accessRole: string) => {
const login = new LoginPage()
const home = new HomePage()
const na = new NamespaceAccessPage()
cy.deleteAllCookies()
cy.visit('/')
cy.reload()
cy.fixture('apiowner').as('apiowner')
Expand All @@ -117,7 +116,6 @@ Cypress.Commands.add('getUserSessionTokenValue', (namespace: string, isNamespace
const home = new HomePage()
const na = new NamespaceAccessPage()
let userSession: string
cy.deleteAllCookies()
cy.visit('/')
cy.reload()
cy.fixture('apiowner').as('apiowner')
Expand Down Expand Up @@ -201,8 +199,10 @@ Cypress.Commands.add('logout', () => {
cy.log('< Logging out')
cy.getSession().then(() => {
cy.get('@session').then((res: any) => {
cy.visit('/')
cy.wait(3000)
cy.get('[data-testid=auth-menu-user]').click({ force: true })
cy.contains('Logout').click()
cy.get('[data-testid=auth-menu-signout-btn]').click({ force: true })
})
})
cy.log('> Logging out')
Expand Down
4 changes: 1 addition & 3 deletions e2e/cypress/tests/01-api-key/01-create-api.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ describe('Create API Spec', () => {

before(() => {
cy.visit('/')
cy.deleteAllCookies()
cy.reload()
cy.resetState()
cy.deleteAllCookies()
})

beforeEach(() => {
Expand Down Expand Up @@ -180,7 +180,5 @@ it('Verify gwa gateway publish multiple config file', () => {

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})
})
25 changes: 15 additions & 10 deletions e2e/cypress/tests/01-api-key/03-request-access-inactive-env.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ describe('Change an Active environment to Inactive', () => {

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})
})

Expand All @@ -60,13 +58,12 @@ describe('Verify enactive environment in rrequest access pop up', () => {

before(() => {
cy.visit('/')
cy.deleteAllCookies()
cy.reload()
})

beforeEach(() => {
cy.preserveCookies()
cy.fixture('developer').as('developer')
Cypress.session.clearAllSavedSessions()
// cy.visit(login.path)
})

Expand Down Expand Up @@ -96,8 +93,12 @@ describe('Verify enactive environment in rrequest access pop up', () => {

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
// cy.clearLocalStorage({ log: true })
// cy.deleteAllCookies()
// Cypress.session.clearAllSavedSessions()
// cy.clearCookie('_oauth2_proxy')
// cy.clearCookie('keystone.sid')
// debugger
})
})

Expand All @@ -108,9 +109,12 @@ describe('Change an the environment back to active', () => {
const pd = new Products()

before(() => {
debugger
// cy.clearAllSessionStorage({log: true})
cy.visit('/')
cy.deleteAllCookies()
cy.reload()
// cy.deleteAllCookies()
// cy.clearCookies()
// cy.reload()
})

beforeEach(() => {
Expand All @@ -131,6 +135,7 @@ describe('Change an the environment back to active', () => {
})

it('Navigate to Products Page', () => {
debugger
cy.visit(pd.path)
})

Expand All @@ -143,7 +148,7 @@ describe('Change an the environment back to active', () => {

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
// cy.clearLocalStorage({ log: true })
// cy.deleteAllCookies()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('Request Access without colleting credential Spec', () => {

before(() => {
cy.visit('/')
cy.deleteAllCookies()
cy.reload()
})

Expand Down Expand Up @@ -39,7 +38,5 @@ describe('Request Access without colleting credential Spec', () => {

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})
})
2 changes: 0 additions & 2 deletions e2e/cypress/tests/01-api-key/07-approve-pending-rqst.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ describe('Approve Pending Request Spec', () => {
})
after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ describe('Grant appropriate permissions to team members for client credential fl

it('create namespace using gwa cli command', () => {
var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, "");
cy.exec('gwa namespace create --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
cy.exec('gwa namespace create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 5000, failOnNonZeroExit: false }).then((response) => {
debugger
assert.isNotNaN(response.stdout)
namespace = response.stdout
cy.replaceWordInJsonObject('ccplatform', namespace, 'cc-service-gwa.yml')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,5 @@ describe('Generate Authorization Profiles', () => {

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('Access manager approves developer access request for Client ID/Secret

before(() => {
cy.visit('/')
cy.deleteAllCookies()
cy.reload()
})

Expand Down Expand Up @@ -51,8 +50,6 @@ describe('Access manager approves developer access request for Client ID/Secret

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})
})

Expand Down Expand Up @@ -91,7 +88,6 @@ describe('Verify the selected client scoped is displayed in assigned default lis

before(() => {
cy.visit(Cypress.env('KEYCLOAK_URL'))
cy.deleteAllCookies()
cy.reload()
})

Expand Down Expand Up @@ -131,8 +127,6 @@ describe('Verify the selected client scoped is displayed in assigned default lis

after(() => {
cy.keycloakLogout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})

})
Expand All @@ -144,7 +138,6 @@ describe('Deselect the scope from authorization tab', () => {

before(() => {
cy.visit('/')
cy.deleteAllCookies()
cy.reload()
})

Expand Down Expand Up @@ -182,6 +175,9 @@ describe('Deselect the scope from authorization tab', () => {
consumers.saveAppliedConfig()
})
})
after(() => {
cy.logout()
})
})

describe('Verify the selected client scoped is not displayed in assigned default list', () => {
Expand All @@ -193,7 +189,6 @@ describe('Verify the selected client scoped is not displayed in assigned default

before(() => {
cy.visit(Cypress.env('KEYCLOAK_URL'))
cy.deleteAllCookies()
cy.reload()
})

Expand Down Expand Up @@ -233,8 +228,6 @@ describe('Verify the selected client scoped is not displayed in assigned default

after(() => {
cy.keycloakLogout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})

})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('Developer creates an access request for JWT Generated Key Pair authent

before(() => {
cy.visit('/')
cy.deleteAllCookies()
cy.reload()
})

Expand Down Expand Up @@ -53,7 +52,5 @@ describe('Developer creates an access request for JWT Generated Key Pair authent

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('Access manager approves developer access request for JWT - Generated K

before(() => {
cy.visit('/')
cy.deleteAllCookies()
cy.reload()
})

Expand Down Expand Up @@ -45,8 +44,6 @@ describe('Access manager approves developer access request for JWT - Generated K

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('Developer creates an access request for JWKS URL', () => {

before(() => {
cy.visit('/')
cy.deleteAllCookies()
cy.reload()
})

Expand Down Expand Up @@ -80,7 +79,5 @@ describe('Developer creates an access request for JWKS URL', () => {

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe('Access manager approves developer access request for JWKS URL flow', (

before(() => {
cy.visit('/')
cy.deleteAllCookies()
cy.reload()
})

Expand Down Expand Up @@ -46,8 +45,6 @@ describe('Access manager approves developer access request for JWKS URL flow', (

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('Generates public/private key and set public key to access request', ()

before(() => {
cy.visit('/')
cy.deleteAllCookies()
cy.reload()
})

Expand Down Expand Up @@ -71,7 +70,5 @@ describe('Generates public/private key and set public key to access request', ()

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
cy.deleteAllCookies()
})
})
Loading

0 comments on commit 2282d60

Please sign in to comment.