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: added e2e tests for get credentials #1585

Merged
merged 88 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
552e964
build : Initial commit for get credential phase 2
BaskarMitrah May 8, 2024
ba795ea
build : --Added the separated components and moved into folder
BaskarMitrah May 10, 2024
d135190
build : --Updated the get crdential external page
BaskarMitrah May 10, 2024
bf902ee
feat: wired up get template by id and install template endpoints (#1577)
deepessh May 15, 2024
098278a
fix: added request access
BaskarMitrah May 15, 2024
c5871a7
integrated request access
deepessh May 16, 2024
07d5c60
build : Fixed design issues & Removed unwanted code
BaskarMitrah May 16, 2024
aa23c65
fix: code improvements
deepessh May 17, 2024
07751e0
build : fixed the design issues and removed the unwanted code
BaskarMitrah May 17, 2024
bb416e8
Revert "build : fixed the design issues and removed the unwanted code"
BaskarMitrah May 17, 2024
de3ae10
build:added some design issue (#1580)
BaskarMitrah May 17, 2024
b5a6e12
fix: incorrect import
deepessh May 20, 2024
943d83b
build: update change organization
BaskarMitrah May 20, 2024
33e3d03
fix: build issue
BaskarMitrah May 20, 2024
452fc1c
Add back in yarn.lock
timkim May 20, 2024
cf0b0b9
Increase cypress timeout
timkim May 20, 2024
60b42b9
Increase cypress timeout again
timkim May 20, 2024
e0aaf36
added hardcoded wiring for generating access token
deepessh May 21, 2024
0bf2dea
build : showed access token and secret key in the card
BaskarMitrah May 22, 2024
e00d2ff
Added optional chaining to the response
BaskarMitrah May 22, 2024
b06bfc8
fix: oauths2s and api key get credential components
deepessh May 22, 2024
e22e257
--Fixed bugs
BaskarMitrah May 23, 2024
bb41a59
fix : reduced code & added tooltip for card
BaskarMitrah May 27, 2024
8d663a3
fix : removed unwanted code
BaskarMitrah May 27, 2024
ec2bad6
feat: bug fix, integrate with TR on stage
deepessh May 28, 2024
579f960
fix: fixes
deepessh May 30, 2024
9c3447f
Bugs/api integration (#1581)
deepessh Jun 5, 2024
80209ca
Merge remote-tracking branch 'origin/main' into get_credential_phase2
deepessh Jun 5, 2024
6d5784c
fix: increase cypress timeout
timkim Jun 5, 2024
6a25dee
fix : Added Scopes & fixed design issues (#1583)
deepessh Jun 6, 2024
6625fbb
feat: integrated the new accounts API, bug fixes
deepessh Jun 6, 2024
96a6a68
fix: code improvements and bug fixes
deepessh Jun 6, 2024
3bcc5b5
Merge remote-tracking branch 'origin/main' into get_credential_phase2
deepessh Jun 6, 2024
6f18f83
removed unnecessary console.log
deepessh Jun 6, 2024
4922ec4
feat: use window.adobeIMS instead of ims from context
deepessh Jun 7, 2024
a0341da
Bugs/remaned components (#1584)
deepessh Jun 7, 2024
0dc303a
test: added e2e tests for get credentials
deepessh Jun 7, 2024
3a0c9ca
test: added console logs
deepessh Jun 7, 2024
6ccd72f
test: run get credentials along with smoke tests
deepessh Jun 7, 2024
b4603fe
test: try running tests on https
deepessh Jun 7, 2024
d4c220b
test: try running tests on https
deepessh Jun 7, 2024
072ddf2
test: added basic login test for get credentials component
deepessh Jun 7, 2024
9fe266c
test: added get_credential_phase2 to pr test branches
deepessh Jun 7, 2024
74120aa
test: try pass env vars to the start command
deepessh Jun 7, 2024
ee04dff
test: force trigger tests
deepessh Jun 7, 2024
170e900
test: revert force trigger
deepessh Jun 7, 2024
58f80d8
fix: env vars
deepessh Jun 7, 2024
ef6709c
test: create env file in git
deepessh Jun 7, 2024
805426a
test: enable running tests for PRs to get_credential_phase2
deepessh Jun 7, 2024
50556f7
--Added the test for the credential for oAuth & APIKey
BaskarMitrah Jun 19, 2024
2a44ade
Migrated the functionalities from commands to get-credentials.cy
BaskarMitrah Jun 25, 2024
fe9759c
--Migrated to commands to functions
BaskarMitrah Jun 26, 2024
de643af
removed unnecessary wait and reorganized code
deepessh Jun 26, 2024
d83ff72
disable videos, increase command timeout
deepessh Jun 26, 2024
dbad584
test improvements
deepessh Jun 27, 2024
0f55ba8
added form submission test
deepessh Jun 27, 2024
0cede9b
comment out get credentials e2e test
deepessh Jun 27, 2024
327163f
do not run e2e tests for get_credential_phase2
deepessh Jun 28, 2024
1c43510
Merge remote-tracking branch 'origin/main' into get_credential_phase2…
deepessh Jul 18, 2024
70c03cb
fix: test
deepessh Jul 18, 2024
9ef90f2
test: enable get creds test, run on self-hosted runner
deepessh Jul 18, 2024
1bc911d
fix: added step to install yarn
deepessh Jul 18, 2024
0285e8d
test: try installing yarn as root
deepessh Jul 19, 2024
627d3a7
fix: run test commands as root
deepessh Jul 19, 2024
231b629
fix: try using npx to run yarn commands
deepessh Jul 19, 2024
ec4458c
fix: run install command as root, upgrade to cypress gh action v6
deepessh Jul 19, 2024
0c2be7b
feat: added step to install latest lts version of node
deepessh Jul 19, 2024
cb16fd0
try print node version
deepessh Jul 19, 2024
55e985e
try adding cache and cache-dependency-path
deepessh Jul 19, 2024
aadec7e
fix: format
deepessh Jul 19, 2024
61e8599
remove caching
deepessh Jul 19, 2024
5a3038e
print node version
deepessh Jul 19, 2024
a09706c
print non-sudo node version
deepessh Jul 19, 2024
19a0653
try installing yarn without sudo
deepessh Jul 19, 2024
01a2399
do not use sudo, enable caching of yarn packages
deepessh Jul 19, 2024
4cd549a
revert to use cypress github action v5
deepessh Jul 19, 2024
a8247a2
try running in docker
deepessh Jul 19, 2024
b23f776
use checkout v4
deepessh Jul 19, 2024
5f1ab0b
debug missing checkout step files
deepessh Jul 19, 2024
6814bcd
add sudo to ls
deepessh Jul 19, 2024
2f5b25e
run id
deepessh Jul 19, 2024
009ea0c
try using user root
deepessh Jul 19, 2024
8403f19
remove sudo
deepessh Jul 19, 2024
4c25c90
remove id
deepessh Jul 19, 2024
c903d03
added custom certs for e2e tests
deepessh Jul 19, 2024
53d2061
remove build step, increase wait timeout
deepessh Jul 19, 2024
4561b50
remove unnecessary code
deepessh Jul 19, 2024
0516699
remove extra file
deepessh Jul 19, 2024
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
26 changes: 20 additions & 6 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,31 @@ on:
- "cypress/**"
jobs:
smoke_tests:
runs-on: ubuntu-latest
container:
image: cypress/browsers:node-20.14.0-chrome-126.0.6478.114-1-ff-127.0.1-edge-126.0.2592.61-1
options: --user root
runs-on: self-hosted
Copy link
Collaborator

Choose a reason for hiding this comment

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

note: For future reference, once IOXTD-2520 (more specifically IOXTD-2789) is completed, we'll have self-hosted runners on Ethos Corp-Connected Clusters so that we can replace use of this "temporary" self-hosted runner (see IOXTD-2788).

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 'Create env file'
run: |
touch ./example/.env
echo GATSBY_IMS_SRC="https://auth-stg1.services.adobe.com/imslib/imslib.min.js" >> ./example/.env
echo GATSBY_IMS_CONFIG='{"client_id": "stage_adobe_io", "scope": "AdobeID,openid,unified_dev_portal,read_organizations,additional_info.projectedProductContext,additional_info.roles,gnav,read_pc.dma_bullseye,creative_sdk,adobeio_api,service_principals.read,service_principals.write,read_client_secret", "environment": "stg1"}' >> ./example/.env
cat ./example/.env

- name: Run Tests
uses: cypress-io/github-action@v5
with:
build: yarn build
start: yarn serve
wait-on: 'http://[::1]:9000'
start: yarn dev:https:ci
wait-on: 'https://localhost.corp.adobe.com:9000'
wait-on-timeout: 150
browser: chrome
config-file: cypress.config.js
spec: cypress/e2e/smoke.cy.js
spec: |
cypress/e2e/smoke.cy.js
cypress/e2e/get-credentials.cy.js
env:
NODE_TLS_REJECT_UNAUTHORIZED: '0'
37 changes: 21 additions & 16 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
viewportHeight: 900,
viewportWidth: 1440,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
baseUrl: 'http://localhost:9000',
specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
},
pageLoadTimeout: 500000,
})
const { defineConfig } = require('cypress')

module.exports = defineConfig({
viewportHeight: 900,
viewportWidth: 1440,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
baseUrl: 'https://localhost.corp.adobe.com:9000',
specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
},
pageLoadTimeout: 500000,
userEmail: 'cypress1@adobe.com',
userPassword: 'ScotchB33r&1234567',
defaultCommandTimeout: 60000,
video: false,
chromeWebSecurity: false
})
162 changes: 162 additions & 0 deletions cypress/e2e/get-credentials.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
const API_KEY = 'apikey';
const OAUTH_S2S = 'oauths2s';

function init(route) {
cy.visit(route).assertRoute(route);
cy.expect('button[data-cy="sign-in-btn"]').to.exist;
cy.get('button[data-cy="sign-in-btn"]').should('be.visible');
cy.get('button[data-cy="sign-in-btn"]').should('be.enabled');
cy.get('button[data-cy="sign-in-btn"]').click();
cy.login();
cy.get('button[data-cy="sign-in-btn"]').should('not.exist');
cy.assertRoute(route + '#');
}

function checkRequestAccessEdgeCase() {
cy.get('button[data-cy="accessDetails-edgeCase-btn"]').should('be.visible').should('be.enabled');
};

function getIframeBody() {
return cy.get('iframe[data-cy="request-access-iframe"]')
.its('0.contentDocument.body').should('not.be.empty')
.then(cy.wrap);
}

function checkRequestAccess() {
cy.get('body').then(($body) => {
// if the request is not already sent, send the request
if ($body.find('[data-cy="request-access-button"]').length > 0) {
cy.get('[data-cy="request-access-button"]').click();
getIframeBody().find('button[data-testid="send-request-button"]').should('exist').click();
getIframeBody().find('button[data-testid="close-button"]').should('exist').click();
}
});
cy.get('button[data-cy="request-info"]').should('be.visible').should('be.enabled').click();
cy.get('body', { timeout: 1000 }).click();
};

function checkReturnFlow(credentialType) {
// verify return flow is visible
cy.get('[data-cy="return-flow"]').should('be.visible');

// verify clicking on create new credential button opens the form
returnToForm();

// verify clicking on cancel button closes the form
cy.get('[data-cy="cancel-new-credential"]').click();
cy.get('[data-cy="return-flow"]').should('be.visible');

// verify clicking on manage projects console button exists
cy.get('[data-cy="manage-projects-console"]').should('exist');

// ensure project picker is visible
cy.get('button[data-cy="projects-picker"]').should('be.visible').should('be.enabled');

// verify all the information is visible based on credential type
checkCredential(credentialType);
};

function checkAPIKey() {
// verify API key is visible
cy.contains('API Key').should('be.visible');

// verify API key copy button is clickable
cy.get('[data-cy="API Key-copyIcon"]').should('be.visible');

// verify allowed domains copy button is clickable
cy.get('[data-cy="Allowed domains-copyIcon"]').should('be.visible');
}

function checkOAuthS2S() {
cy.get('button[data-cy="generate-token"]').should('be.visible').should('be.enabled');
// cy.get('button[data-cy="copy-token"]').should('exist');
cy.get('[data-cy="credentialName-link"]').should('exist');
cy.get('button[data-cy="ClientId-copyIcon"]').should('exist');
cy.get('button[data-cy="retrieve-client-secret"]').should('be.visible').should('be.enabled');
// cy.get('button[data-cy="copy-client-secret"]').should('exist');
cy.get('button[data-cy="Scopes-copyIcon"]').should('exist');
cy.contains('openid, AdobeID, read_organizations, firefly_api, ff_apis').should('exist');
}

function checkCredential(credentialType) {
switch(credentialType) {
case API_KEY:
checkAPIKey();
break;
case OAUTH_S2S:
checkOAuthS2S();
break;
}

cy.get('[data-cy="next-step-button"]').should('exist');
if (credentialType !== API_KEY) {
cy.get('[data-cy="Manage-Dev-Console-link"]').should('exist');
}
};

function addCredential(credentialType) {
const credentialName = `CypressTest${credentialType}${Math.floor(Math.random() * 1000)}`;
cy.get('[data-cy="add-credential-name"]').click().should('have.focus');
cy.get('[data-cy="add-credential-name"]').type(credentialName).should('have.value', credentialName);
if (credentialType === API_KEY) {
cy.get('[data-cy="add-allowed-origins"]').click().should('have.focus');
cy.get('[data-cy="add-allowed-origins"]').type('localhost:9000').should('have.value', 'localhost:9000');
cy.get('[data-cy="download-checkBox"]').check().should('be.checked');
cy.get('[data-cy="select-download-language"]').click();
cy.get('ul li').contains('JavaScript').click();
}
cy.get('[data-cy="terms-condition-link"]').should('be.visible');
cy.get('[data-cy="update-terms-condition"]').check().should('be.checked');
cy.get('[data-cy="create-credential-btn"]').should('be.visible');
cy.get('[data-cy="create-credential-btn"]').should('be.enabled');
cy.get('[data-cy="create-credential-btn"]').click();
if (credentialType === API_KEY) {
cy.get('button[data-cy="restart-download"]').should('be.visible').should('be.enabled').click();
}
checkCredential(credentialType);
cy.get('[data-cy="Restart-new-credential"]').click();
};

function waitForLoader() {
cy.get('div[data-cy="loader"]').should('exist');
cy.get('div[data-cy="loader"]').should('not.exist');

}

function selectOrganization(orgName) {
cy.get('button[data-cy="change-organization-btn"]').should('be.visible').should('be.enabled').click();
cy.get('button[data-cy="organization-picker"]').should('be.visible').should('be.enabled').click();
cy.contains(orgName).should('exist').click();
cy.get('button[data-cy="submit-change-organization"]').should('be.visible').should('be.enabled').click();
waitForLoader();
};

function returnToForm() {
cy.get('[data-cy="create-new-credential"]').should('be.visible');
cy.get('[data-cy="create-new-credential"]').click();
cy.get('[data-cy="credential-form"]').should('be.visible');
}

describe('Get Credentials Test', () => {
it('API Key page loads', () => {
init('/getCredential/');
checkReturnFlow(API_KEY);
selectOrganization('AdobeIOTestingOrg');
checkReturnFlow(API_KEY);
// return to the form
returnToForm();
addCredential(API_KEY);
});

it('OAuth s2s page loads', () => {
init('/get-credential-oauth/');
checkRequestAccessEdgeCase();
selectOrganization('Romans entp org');
checkRequestAccess();
selectOrganization('MAC New Feature Testing');
checkReturnFlow(OAUTH_S2S);
// return to the form
returnToForm();
addCredential(OAUTH_S2S);
});
});
Loading
Loading