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

Pcf editable table e2e #37

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
baseUrl: 'https://bevertest.crm4.dynamics.com',
experimentalModifyObstructiveThirdPartyCode: true,
chromeWebSecurity: false,
defaultCommandTimeout: 20000,
},
});
463 changes: 463 additions & 0 deletions cypress/e2e/editableTable.cy.ts

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions cypress/e2e/editableTableTimeZoneTest.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
describe('Editable Table Time Zone Test', () => {

beforeEach(() => {
cy.fixture('user').then(user => {
cy.login(user.user2.userName, user.user2.password);
});

cy.fixture('record').then(record => {
cy.visitD365Environment(record.appId, record.entityName, record.recordId);
});
cy.wait(3000);
cy.get('[data-id="tablist-tab_2"]').should('be.visible').click();
cy.wait(3000);

});
it(`Should check for dateTime correct convertions`, () => {
cy.fixture('dateTimeData').then(testData => {
testData.user1.forEach((data: DateTimeData) => {
cy.assertFieldValues(data);
});
});
});
});
79 changes: 79 additions & 0 deletions cypress/fixtures/dateTimeData.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"user1":
[
{
"value": "DateTimeUITest1",
"assertions": [
{ "selector": "div[data-automation-key=\"bvr_dtltest\"] input", "index": 0, "value": "22.07.2022" },
{ "selector": "div[data-automation-key=\"bvr_dtltest\"] input", "index": 1, "value": "5:00 AM" },
{ "selector": "div[data-automation-key=\"bvr_dtl2test\"] input", "index": 0, "value": "23.07.2022" },
{ "selector": "div[data-automation-key=\"bvr_dtl2test\"] input", "index": 1, "value": "7:00 AM" }
]
},
{
"value": "DateTimeUITest2",
"assertions": [
{ "selector": "div[data-automation-key=\"bvr_dtltest\"] input", "index": 0, "value": "22.01.2022" },
{ "selector": "div[data-automation-key=\"bvr_dtltest\"] input", "index": 1, "value": "6:00 AM" },
{ "selector": "div[data-automation-key=\"bvr_dtl2test\"] input", "index": 0, "value": "23.01.2022" },
{ "selector": "div[data-automation-key=\"bvr_dtl2test\"] input", "index": 1, "value": "8:00 AM" }
]
},
{
"value": "DateTimeTITest1",
"assertions": [
{ "selector": "div[data-automation-key=\"bvr_dtitest\"] input", "index": 0, "value": "22.07.2022" },
{ "selector": "div[data-automation-key=\"bvr_dtitest\"] input", "index": 1, "value": "1:00 PM" },
{ "selector": "div[data-automation-key=\"bvr_dti2test\"] input", "index": 0, "value": "23.07.2022" },
{ "selector": "div[data-automation-key=\"bvr_dti2test\"] input", "index": 1, "value": "3:00 PM" }
]
},
{
"value": "DateTimeTITest2",
"assertions": [
{ "selector": "div[data-automation-key=\"bvr_dtitest\"] input", "index": 0, "value": "22.01.2022" },
{ "selector": "div[data-automation-key=\"bvr_dtitest\"] input", "index": 1, "value": "1:00 PM" },
{ "selector": "div[data-automation-key=\"bvr_dti2test\"] input", "index": 0, "value": "23.01.2022" },
{ "selector": "div[data-automation-key=\"bvr_dti2test\"] input", "index": 1, "value": "3:00 PM" }
]
}
],
"user2": [
{
"value": "DateTimeUITest1",
"assertions": [
{ "selector": "div[data-automation-key=\"bvr_dtltest\"] input", "index": 0, "value": "07/22/2022" },
{ "selector": "div[data-automation-key=\"bvr_dtltest\"] input", "index": 1, "value": "1:00 PM" },
{ "selector": "div[data-automation-key=\"bvr_dtl2test\"] input", "index": 0, "value": "07/23/2022" },
{ "selector": "div[data-automation-key=\"bvr_dtl2test\"] input", "index": 1, "value": "3:00 PM" }
]
},
{
"value": "DateTimeUITest2",
"assertions": [
{ "selector": "div[data-automation-key=\"bvr_dtltest\"] input", "index": 0, "value": "01/22/2022" },
{ "selector": "div[data-automation-key=\"bvr_dtltest\"] input", "index": 1, "value": "1:00 PM" },
{ "selector": "div[data-automation-key=\"bvr_dtl2test\"] input", "index": 0, "value": "01/23/2022" },
{ "selector": "div[data-automation-key=\"bvr_dtl2test\"] input", "index": 1, "value": "3:00 PM" }
]
},
{
"value": "DateTimeTITest1",
"assertions": [
{ "selector": "div[data-automation-key=\"bvr_dtitest\"] input", "index": 0, "value": "07/22/2022" },
{ "selector": "div[data-automation-key=\"bvr_dtitest\"] input", "index": 1, "value": "1:00 PM" },
{ "selector": "div[data-automation-key=\"bvr_dti2test\"] input", "index": 0, "value": "07/23/2022" },
{ "selector": "div[data-automation-key=\"bvr_dti2test\"] input", "index": 1, "value": "3:00 PM" }
]
},
{
"value": "DateTimeTITest2",
"assertions": [
{ "selector": "div[data-automation-key=\"bvr_dtitest\"] input", "index": 0, "value": "01/22/2022" },
{ "selector": "div[data-automation-key=\"bvr_dtitest\"] input", "index": 1, "value": "1:00 PM" },
{ "selector": "div[data-automation-key=\"bvr_dti2test\"] input", "index": 0, "value": "01/23/2022" },
{ "selector": "div[data-automation-key=\"bvr_dti2test\"] input", "index": 1, "value": "3:00 PM" }
]
}
]
}
5 changes: 5 additions & 0 deletions cypress/fixtures/record.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"appId": "4d1a5ae4-2516-44b4-b71d-ad82c9b55301",
"entityName": "bvr_testeditablegrid",
"recordId": "47F38AAC-FF13-EE11-8F6C-000D3AB3CF74"
}
10 changes: 10 additions & 0 deletions cypress/fixtures/user.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"user1": {
"userName": "USERNAME",
"password": "PASSWORD"
},
"user2": {
"userName": "USERNAME",
"password": "PASSWORD"
}
}
83 changes: 83 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
interface Chainable {
login(username: string, password: string): Chainable<void>;
visitD365Environment(appId: string, entityName: string, recordId: string): Chainable<void>;
assertFieldValues(data: DateTimeData): Chainable<void>;
waitForPseudoElement(): Chainable<void>;
handleSignInIssue(popupElement: string, buttonElement: string): Chainable<void>;
}
}

interface Assertion {
selector: string;
index: number;
value: string;
}

interface DateTimeData {
value: string;
assertions: Assertion[];
}

Cypress.Commands.add('login', (username, password) => {
cy.session([username, password], () => {
cy.origin(
'https://login.microsoftonline.com/',
{ args: { username, password } },
({ username, password }) => {
Cypress.on('uncaught:exception', () => false);
cy.visit('https://login.microsoftonline.com');
cy.get('[name="loginfmt"]').type(`${username}{enter}`);
cy.get('[name="passwd"]').type(`${password}{enter}`);
cy.get('[type="submit"]').click();
});
});
});

Cypress.Commands.add('visitD365Environment', (appId, entityName, recordId) => {
Cypress.on('uncaught:exception', () => false);
cy.visit(`main.aspx?` +
`appid=${appId}` +
`&pagetype=entityrecord` +
`&etn=${entityName}` +
`&id=${recordId}`);
});

Cypress.Commands.add('assertFieldValues', data => {
cy.get(`div .ms-DetailsRow-fields input[value="${data.value}"]`)
.closest('.ms-DetailsRow-fields')
.then(row => {
data.assertions.forEach(assertion => {
cy.wrap(row)
.find(assertion.selector)
.eq(assertion.index)
.should('have.value', assertion.value);
});
});
});

Cypress.Commands.add('waitForPseudoElement', { prevSubject: 'element' }, element => {
function checkBeforePseudoElement() {
const beforeContent = window.getComputedStyle(element[0], '::before').content;
if (beforeContent === 'none') {
cy.wait(100).then(checkBeforePseudoElement);
}
else {
return;
}
}
checkBeforePseudoElement();
});

Cypress.Commands.add('handleSignInIssue', (popupElement, buttonElement) => {
cy.get('body').then($body => {
if ($body.find(popupElement).length) {
cy.get(buttonElement).click({ force: true });
}
else {
cy.wait(2000);
cy.handleSignInIssue(popupElement, buttonElement);
}
});
});
1 change: 1 addition & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './commands';
Loading