-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upd: Setup cypress with publish data agreement e2e test
Signed-off-by: George J Padayatti <george.padayatti@igrant.io>
- Loading branch information
1 parent
681d5be
commit 2061394
Showing
9 changed files
with
1,589 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineConfig } from "cypress"; | ||
|
||
export default defineConfig({ | ||
projectId: "6iyv1h", | ||
e2e: { | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/// <reference types="cypress" /> | ||
|
||
// Load fixtures | ||
const testDataAsImport = require('../../fixtures/test-data') | ||
const urls = require('../../fixtures/urls') | ||
|
||
|
||
describe('Publish a data agreement', () => { | ||
before(function () { | ||
// Supply fixtures into each test using `this.testData` | ||
cy.fixture('test-data.json').then((testData) => { | ||
this.testData = testData | ||
}); | ||
|
||
const loginToAdminDashboard = () => { | ||
// Visit dashboard login page | ||
cy.visit(urls.baseUrl) | ||
|
||
// Type the username and password | ||
cy.get("#username").type(testDataAsImport.username); | ||
cy.get("#password").type(testDataAsImport.password); | ||
|
||
// Click the login button | ||
cy.get('[data-testid="ArrowCircleRightOutlinedIcon"]').click(); | ||
|
||
// If login is success and redirected to dashboard. | ||
cy.url().should('include', urls.pages.gettingStarted); | ||
cy.get('h6.MuiTypography-h6').contains('Consent Building Block - Admin Dashboard').should('exist'); | ||
} | ||
|
||
cy.session('login', loginToAdminDashboard) | ||
}) | ||
|
||
it('should publish a data agreement', function () { | ||
const { dataAgreement } = this.testData | ||
|
||
// Visit data agreement page | ||
cy.visit(urls.baseUrl + urls.pages.dataAgreements) | ||
|
||
// Click on create data agreement + button | ||
cy.get('[aria-label="Create Data Agreement"]').click(); | ||
|
||
// Fill create data agreement form | ||
// Purpose name | ||
cy.get('[name="Name"]').type(dataAgreement.name); | ||
// Data exchange mode - DUS | ||
cy.get('[aria-labelledby="mui-component-select-AttributeType"]').click(); | ||
cy.get('[data-value="data_using_service"]').click(); | ||
// Purpose description | ||
cy.get('[name="Description"]').type(dataAgreement.description); | ||
// Lawful basis of processing | ||
cy.get('[aria-labelledby="mui-component-select-LawfulBasisOfProcessing"]').click(); | ||
cy.get('[data-value="contract"]').click(); | ||
|
||
// Data attributes | ||
// Attribute 1 | ||
cy.get('[name="dataAttributes.0.attributeName"]').type(dataAgreement.dataAttributes[0].attributeName); | ||
cy.get('[name="dataAttributes.0.attributeDescription"]').type(dataAgreement.dataAttributes[0].attributeDescription); | ||
cy.get('[data-testid="AddCircleOutlineOutlinedIcon"]').eq(-1).click(); | ||
|
||
// Attribute 2 | ||
cy.get('[name="dataAttributes.1.attributeName"]').type(dataAgreement.dataAttributes[1].attributeName); | ||
cy.get('[name="dataAttributes.1.attributeDescription"]').type(dataAgreement.dataAttributes[1].attributeDescription); | ||
|
||
// Publish data agreement | ||
cy.contains('button', 'PUBLISH').click(); | ||
|
||
}) | ||
|
||
after(function () { | ||
// Click the login button | ||
cy.wait(3000); | ||
cy.get('[data-testid="DeleteOutlineOutlinedIcon"]').click(); | ||
cy.get("#username").type("DELETE"); | ||
cy.contains('button', 'DELETE').click(); | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"username": "admin@localretail.com", | ||
"password": "qwerty123", | ||
"dataAgreement": { | ||
"name": "Marketing and campaign", | ||
"description": "Marketing and campaign", | ||
"dataAttributes": [ | ||
{ | ||
"attributeName": "Name", | ||
"attributeDescription": "Name of the individual" | ||
}, | ||
{ | ||
"attributeName": "Age", | ||
"attributeDescription": "Age of the individual" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"baseUrl": "https://dashboard.bb-consent.dev", | ||
"pages": { | ||
"login":"/#/login", | ||
"gettingStarted": "/#/start", | ||
"dataAgreements": "/#/dataagreement" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************** | ||
// This example commands.ts shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) | ||
// | ||
// declare global { | ||
// namespace Cypress { | ||
// interface Chainable { | ||
// login(email: string, password: string): Chainable<void> | ||
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element> | ||
// } | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// *********************************************************** | ||
// This example support/e2e.ts is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
Oops, something went wrong.