Skip to content

Commit

Permalink
chore: fix cypress tests with new ui changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsSmets committed Jan 15, 2024
1 parent 1ab9848 commit a99d336
Show file tree
Hide file tree
Showing 10 changed files with 518 additions and 443 deletions.
66 changes: 39 additions & 27 deletions cypress/e2e/copying.cy.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,51 @@
describe('Tests about copying', function() {
describe("Tests about copying", function () {
beforeEach(() => {
cy.clearDebugStore();
})
});

afterEach(() => {
cy.get('li#testTab').click();
cy.get('#SelectAllButton').click();
cy.get('.row #DeleteSelectedButton').click();
cy.get('#confirmDeletion').click();
cy.get('#debugTab').click();
cy.get("li#testTab").click();
cy.get("#SelectAllButton").click();
cy.get(".row #DeleteSelectedButton").click();
cy.get("#confirmDeletion").click();
cy.get("#debugTab").click();
});

it('Copy report to test tab', () => {
cy.visit('');
cy.get('#testTab').click();
cy.get('#metadataTable tbody', {timeout: 10000}).find('tr').should('not.exist');
it("Copy report to test tab", () => {
cy.visit("");
cy.get("#testTab").click();
cy.get("#metadataTable tbody", { timeout: 10000 })
.find("tr")
.should("not.exist");
cy.createReport();
cy.get('#debugTab').click();
cy.get('#metadataTable tbody', {timeout: 10000}).find('tr').should('not.exist');
cy.get('.row #RefreshButton').click();
cy.get('#metadataTable tbody').find('tr').should('have.length', 1);
cy.get('button[id="SelectAllReportsButton"]').click();
cy.get("#debugTab").click();
cy.get("#metadataTable tbody", { timeout: 10000 })
.find("tr")
.should("not.exist");
cy.get(".row #RefreshButton").click();
cy.get("#metadataTable tbody").find("tr").should("have.length", 1);
cy.get("[data-cy-select-all-reports]").click();
cy.get('button[id="OpenSelectedReportsButton"]').click();
cy.get('#debug-tree .jqx-tree-dropdown-root > li').should('have.length', 1);
cy.get('button#CopyButton').click();
cy.get('li#testTab').click();
cy.get("#debug-tree .jqx-tree-dropdown-root > li").should("have.length", 1);
cy.get("button#CopyButton").click();
cy.get("li#testTab").click();
// We test that the user does not have to refresh here.
cy.get('tbody#testReports').find('tr').should('have.length', 1);
cy.get('tbody#testReports').find('tr').contains('/Simple report').should('have.length', 1);
cy.get('#debugTab').click();
cy.get('#metadataTable tbody', {timeout: 10000}).find('tr').should('have.length', 1);
cy.get('#debug-tree .jqx-tree-dropdown-root > li').should('have.length', 1);
cy.get('li#testTab').click();
cy.get("tbody#testReports").find("tr").should("have.length", 1);
cy.get("tbody#testReports")
.find("tr")
.contains("/Simple report")
.should("have.length", 1);
cy.get("#debugTab").click();
cy.get("#metadataTable tbody", { timeout: 10000 })
.find("tr")
.should("have.length", 1);
cy.get("#debug-tree .jqx-tree-dropdown-root > li").should("have.length", 1);
cy.get("li#testTab").click();
// Do not refresh. The test tab should have saved its state.
cy.get('tbody#testReports').find('tr').should('have.length', 1);
cy.get('tbody#testReports').find('tr').contains('/Simple report').should('have.length', 1);
cy.get("tbody#testReports").find("tr").should("have.length", 1);
cy.get("tbody#testReports")
.find("tr")
.contains("/Simple report")
.should("have.length", 1);
});
});
179 changes: 108 additions & 71 deletions cypress/e2e/debug_aboutOpenedReports.cy.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,56 @@
describe('About opened reports', function() {
describe("About opened reports", function () {
beforeEach(() => {
cy.clearDebugStore();
cy.createReport();
cy.createOtherReport();
cy.visit('')
cy.visit("");
});

it('Close one', function() {
cy.get('button[id="SelectAllReportsButton"]').click();
it("Close one", function () {
cy.get("[data-cy-select-all-reports]").click();
cy.get('button[id="OpenSelectedReportsButton"]').click();
// Each of the two reports has three lines.
cy.get('#debug-tree .jqx-tree-dropdown-root > li').should('have.length', 2);
cy.get('#debug-tree .jqx-tree-dropdown-root > li > div').should('contain', 'Simple report');
cy.get('#debug-tree .jqx-tree-dropdown-root > li > div:contains(Simple report)').first().selectIfNotSelected();
cy.get('#CloseButton').click();
cy.get('#debug-tree .jqx-tree-dropdown-root > li').should('have.length', 1);
cy.get("#debug-tree .jqx-tree-dropdown-root > li").should("have.length", 2);
cy.get("#debug-tree .jqx-tree-dropdown-root > li > div").should(
"contain",
"Simple report"
);
cy.get(
"#debug-tree .jqx-tree-dropdown-root > li > div:contains(Simple report)"
)
.first()
.selectIfNotSelected();
cy.get("#CloseButton").click();
cy.get("#debug-tree .jqx-tree-dropdown-root > li").should("have.length", 1);
// nth-child has an 1-based index
cy.get('#debug-tree .jqx-tree-dropdown-root > li > div').should('have.text', 'Another simple report').click();
cy.get('#CloseButton').click();
cy.get('#debug-tree .jqx-tree-dropdown-root > li').should('have.length', 0);
cy.get("#debug-tree .jqx-tree-dropdown-root > li > div")
.should("have.text", "Another simple report")
.click();
cy.get("#CloseButton").click();
cy.get("#debug-tree .jqx-tree-dropdown-root > li").should("have.length", 0);
});

it('Close all', function() {
cy.get('.table-responsive tbody tr td:contains(Simple report)').first().click();
cy.get('#debug-tree .jqx-tree-dropdown-root > li').should('have.length', 1);
cy.get('.table-responsive tbody tr td:contains("Another simple report")').first().click();
cy.get('#debug-tree .jqx-tree-dropdown-root > li').should('have.length', 2);
it("Close all", function () {
cy.get(".table-responsive tbody tr td:contains(Simple report)")
.first()
.click();
cy.get("#debug-tree .jqx-tree-dropdown-root > li").should("have.length", 1);
cy.get('.table-responsive tbody tr td:contains("Another simple report")')
.first()
.click();
cy.get("#debug-tree .jqx-tree-dropdown-root > li").should("have.length", 2);
// Check sequence of opened reports. We expect "Simple report" first, then "Another simple report".
cy.get('#debug-tree .jqx-tree-dropdown-root li:nth-child(1) > div').should('contain', 'Simple report');
cy.get('#debug-tree .jqx-tree-dropdown-root li:nth-child(2) > div').should('have.text', 'Another simple report');
cy.get("#debug-tree .jqx-tree-dropdown-root li:nth-child(1) > div").should(
"contain",
"Simple report"
);
cy.get("#debug-tree .jqx-tree-dropdown-root li:nth-child(2) > div").should(
"have.text",
"Another simple report"
);
cy.get('button[id="CloseAllButton"]').click();
cy.get('#debug-tree .jqx-tree-dropdown-root > li').should('have.length', 0);
})
cy.get("#debug-tree .jqx-tree-dropdown-root > li").should("have.length", 0);
});

// // TODO: This can not be tested easily atm, since only the css is changed on expand and collapse
// it('Expand and collapse', function() {
Expand Down Expand Up @@ -80,77 +99,95 @@ describe('About opened reports', function() {

function linesFormExpandedNode($lines, evenOrOdd) {
const startIcon = `assets/tree-icons/startpoint-${evenOrOdd}.gif`;
const oddOrEven = (evenOrOdd == 'even') ? 'odd' : 'even';
const oddOrEven = evenOrOdd == "even" ? "odd" : "even";
const endIcon = `assets/tree-icons/endpoint-${oddOrEven}.gif`;
expect($lines).to.have.length(3);
expect($lines.eq(0).children()).to.have.length(2);
expect($lines.eq(0).children().eq(0)).to.have.prop('nodeName', 'SPAN');
expect($lines.eq(0).children().eq(0)).to.have.class('expand-icon');
expect($lines.eq(0).children().eq(0)).to.have.class('fa-minus');
expect($lines.eq(0).children().eq(1)).to.have.prop('nodeName', 'SPAN');
expect($lines.eq(0).children().eq(1)).to.have.class('node-icon');
expect($lines.eq(0).children('img')).to.have.length(0);
expect($lines.eq(0).children().eq(0)).to.have.prop("nodeName", "SPAN");
expect($lines.eq(0).children().eq(0)).to.have.class("expand-icon");
expect($lines.eq(0).children().eq(0)).to.have.class("fa-minus");
expect($lines.eq(0).children().eq(1)).to.have.prop("nodeName", "SPAN");
expect($lines.eq(0).children().eq(1)).to.have.class("node-icon");
expect($lines.eq(0).children("img")).to.have.length(0);
expect($lines.eq(1).children()).to.have.length(4);
expect($lines.eq(1).children().eq(0)).to.have.prop('nodeName', 'SPAN');
expect($lines.eq(1).children().eq(1)).to.have.prop('nodeName', 'SPAN');
expect($lines.eq(1).children().eq(2)).to.have.prop('nodeName', 'SPAN');
expect($lines.eq(1).children().eq(3)).to.have.prop('nodeName', 'IMG');
expect($lines.eq(1).children().eq(0)).to.have.class('indent');
expect($lines.eq(1).children().eq(1)).to.have.class('expand-icon');
expect($lines.eq(1).children().eq(1)).to.have.class('fa-minus');
expect($lines.eq(1).children().eq(2)).to.have.class('node-icon');
expect($lines.eq(1).children().eq(3).attr('src')).to.equal(startIcon);
expect($lines.eq(1).children().eq(0)).to.have.prop("nodeName", "SPAN");
expect($lines.eq(1).children().eq(1)).to.have.prop("nodeName", "SPAN");
expect($lines.eq(1).children().eq(2)).to.have.prop("nodeName", "SPAN");
expect($lines.eq(1).children().eq(3)).to.have.prop("nodeName", "IMG");
expect($lines.eq(1).children().eq(0)).to.have.class("indent");
expect($lines.eq(1).children().eq(1)).to.have.class("expand-icon");
expect($lines.eq(1).children().eq(1)).to.have.class("fa-minus");
expect($lines.eq(1).children().eq(2)).to.have.class("node-icon");
expect($lines.eq(1).children().eq(3).attr("src")).to.equal(startIcon);
expect($lines.eq(2).children()).to.have.length(5);
expect($lines.eq(2).children().eq(0)).to.have.prop('nodeName', 'SPAN');
expect($lines.eq(2).children().eq(1)).to.have.prop('nodeName', 'SPAN');
expect($lines.eq(2).children().eq(2)).to.have.prop('nodeName', 'SPAN');
expect($lines.eq(2).children().eq(3)).to.have.prop('nodeName', 'SPAN');
expect($lines.eq(2).children().eq(4)).to.have.prop('nodeName', 'IMG');
expect($lines.eq(2).children().eq(0)).to.have.class('indent');
expect($lines.eq(2).children().eq(1)).to.have.class('indent');
expect($lines.eq(2).children().eq(2)).to.have.class('glyphicon');
expect($lines.eq(2).children().eq(3)).to.have.class('node-icon');
expect($lines.eq(2).children().eq(4).attr('src')).to.equal(endIcon);
};
expect($lines.eq(2).children().eq(0)).to.have.prop("nodeName", "SPAN");
expect($lines.eq(2).children().eq(1)).to.have.prop("nodeName", "SPAN");
expect($lines.eq(2).children().eq(2)).to.have.prop("nodeName", "SPAN");
expect($lines.eq(2).children().eq(3)).to.have.prop("nodeName", "SPAN");
expect($lines.eq(2).children().eq(4)).to.have.prop("nodeName", "IMG");
expect($lines.eq(2).children().eq(0)).to.have.class("indent");
expect($lines.eq(2).children().eq(1)).to.have.class("indent");
expect($lines.eq(2).children().eq(2)).to.have.class("glyphicon");
expect($lines.eq(2).children().eq(3)).to.have.class("node-icon");
expect($lines.eq(2).children().eq(4).attr("src")).to.equal(endIcon);
}

function linesFormCollapsedNode($lines) {
expect($lines).to.have.length(1);
expect($lines.eq(0).children()).to.have.length(2);
expect($lines.eq(0).children().eq(0)).to.have.prop('nodeName', 'SPAN');
expect($lines.eq(0).children().eq(1)).to.have.prop('nodeName', 'SPAN');
expect($lines.eq(0).children().eq(0)).to.have.class('expand-icon');
expect($lines.eq(0).children().eq(0)).to.have.class('fa-plus');
expect($lines.eq(0).children().eq(1)).to.have.class('node-icon');
expect($lines.eq(0).children().eq(0)).to.have.prop("nodeName", "SPAN");
expect($lines.eq(0).children().eq(1)).to.have.prop("nodeName", "SPAN");
expect($lines.eq(0).children().eq(0)).to.have.class("expand-icon");
expect($lines.eq(0).children().eq(0)).to.have.class("fa-plus");
expect($lines.eq(0).children().eq(1)).to.have.class("node-icon");
}

function checkNodeInfo(name) {
cy.get(`.jqx-tree-dropdown-root > li:contains(${name}):eq(0)`).click();
const startOfReportTag = '<Report';
const wordsInName = name.split(' ');
const quotedWordsInName = wordsInName.map(word => '"' + word + '"');
cy.getShownMonacoModelElement().within(function(shownMonacoElement) {
const startOfReportTag = "<Report";
const wordsInName = name.split(" ");
const quotedWordsInName = wordsInName.map((word) => '"' + word + '"');
cy.getShownMonacoModelElement().within(function (shownMonacoElement) {
cy.wrap(shownMonacoElement).find(`span:contains(${startOfReportTag})`);
cy.wrap(shownMonacoElement).find('span:contains(Name)');
quotedWordsInName.forEach(word => {
cy.wrap(shownMonacoElement).find("span:contains(Name)");
quotedWordsInName.forEach((word) => {
cy.wrap(shownMonacoElement).find(`span:contains(${word})`);
});
});
cy.get('#displayedNodeTable tr:eq(0) td:eq(0)').should('have.text', 'Name');
cy.get('#displayedNodeTable tr:eq(0) td:eq(1)').should('have.text', `${name}`);
cy.get('#displayedNodeTable tr:eq(4) td:eq(0)').should('have.text', 'StorageId');
cy.get('#displayedNodeTable tr:eq(4) td:eq(1)').should('not.be.empty');
cy.get("#displayedNodeTable tr:eq(0) td:eq(0)").should("have.text", "Name");
cy.get("#displayedNodeTable tr:eq(0) td:eq(1)").should(
"have.text",
`${name}`
);
cy.get("#displayedNodeTable tr:eq(4) td:eq(0)").should(
"have.text",
"StorageId"
);
cy.get("#displayedNodeTable tr:eq(4) td:eq(1)").should("not.be.empty");
cy.get(`div.treeview > ul > li:contains(${name}):eq(1)`).click();
const helloWorld = "Hello\xa0World!";
cy.getShownMonacoModelElement().find(`span:contains(${helloWorld})`);
cy.get('#displayedNodeTable tr:eq(0) td:eq(0)').should('have.text', 'Name');
cy.get('#displayedNodeTable tr:eq(0) td:eq(1)').should('have.text', `${name}`);
cy.get('#displayedNodeTable tr:eq(5) td:eq(0)').should('have.text', 'CheckpointUID');
cy.get('#displayedNodeTable tr:eq(5) td:eq(1)').should('not.be.empty');
cy.get("#displayedNodeTable tr:eq(0) td:eq(0)").should("have.text", "Name");
cy.get("#displayedNodeTable tr:eq(0) td:eq(1)").should(
"have.text",
`${name}`
);
cy.get("#displayedNodeTable tr:eq(5) td:eq(0)").should(
"have.text",
"CheckpointUID"
);
cy.get("#displayedNodeTable tr:eq(5) td:eq(1)").should("not.be.empty");
cy.get(`div.treeview > ul > li:contains(${name}):eq(2)`).click();
const goodbyeWorld = "Goodbye\xa0World!";
cy.getShownMonacoModelElement().find(`span:contains(${goodbyeWorld})`);
cy.get('#displayedNodeTable tr:eq(0) td:eq(0)').should('have.text', 'Name');
cy.get('#displayedNodeTable tr:eq(0) td:eq(1)').should('have.text', `${name}`);
cy.get('#displayedNodeTable tr:eq(5) td:eq(0)').should('have.text', 'CheckpointUID');
cy.get('#displayedNodeTable tr:eq(5) td:eq(1)').should('not.be.empty');
cy.get("#displayedNodeTable tr:eq(0) td:eq(0)").should("have.text", "Name");
cy.get("#displayedNodeTable tr:eq(0) td:eq(1)").should(
"have.text",
`${name}`
);
cy.get("#displayedNodeTable tr:eq(5) td:eq(0)").should(
"have.text",
"CheckpointUID"
);
cy.get("#displayedNodeTable tr:eq(5) td:eq(1)").should("not.be.empty");
}
Loading

0 comments on commit a99d336

Please sign in to comment.