From 7c71ca67592c09e9ae8f6fa1c4c83342ec839580 Mon Sep 17 00:00:00 2001 From: sopa301 <96387349+sopa301@users.noreply.github.com> Date: Thu, 22 Feb 2024 20:44:24 +0800 Subject: [PATCH 1/9] Add tests for segment css --- .../codeView/codeView_codeHighlighting.cy.js | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js diff --git a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js new file mode 100644 index 0000000000..74fddf162e --- /dev/null +++ b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js @@ -0,0 +1,67 @@ +// Assumes: RepoSense repo from 03/05/2018 to current date +describe('code highlighting works properly', () => { + it('should highlight code when there is a single author', () => { + // open the code panel + cy.get('.icon-button.fa-code') + .should('be.visible') + .first() + .click(); + + cy.get('#tab-authorship .files', { timeout: 90000 }) + .should('be.visible'); + + cy.get('.hljs-comment').contains('* Represents a Git Author.') + .parent() // .line-content + .parent() // .code + .should('have.css', 'background-color', 'rgb(230, 255, 237)'); // #e6ffed + }); + + it('should highlight code when multiple authors are merged in a repo group', () => { + cy.get('div.mui-select.grouping > select:visible') + .select('groupByRepos'); + + cy.get('#summary label.merge-group > input:visible') + .should('be.visible') + .check() + .should('be.checked'); + + // open the code panel + cy.get('.icon-button.fa-code') + .should('be.visible') + .first() + .click(); + + cy.get('#tab-authorship .files', { timeout: 90000 }) + .should('be.visible'); + + cy.get('.hljs-comment').contains('* MUI Colors module') // eugenepeh + .parent() // .line-content + .parent() // .code + .should('have.css', 'background-color') + .and('not.eq', 'rgb(255, 255, 255)') // #ffffff + .then((color) => { + cy.get('.line-content').contains(`'red': (`) // jamessspanggg + .parent() // .code + .should('have.css', 'background-color') + .and('not.eq', color) + .and('not.eq', 'rgb(255, 255, 255)') + }); + }); + + it('should not highlight non-attributed lines', () => { + // open the code panel + cy.get('.icon-button.fa-code') + .should('be.visible') + .first() + .click(); + + cy.get('#tab-authorship .files', { timeout: 90000 }) + .should('be.visible'); + + cy.get('.hljs-title').contains('Author') + .parent() // .hljs-class + .parent() // .line-content + .parent() // .code + .should('have.css', 'background-color', 'rgb(255, 255, 255)'); // #ffffff + }); +}); \ No newline at end of file From 87e0304c01576e9303a1bd8bc2bce0f9d71a5964 Mon Sep 17 00:00:00 2001 From: sopa301 <96387349+sopa301@users.noreply.github.com> Date: Thu, 22 Feb 2024 20:57:47 +0800 Subject: [PATCH 2/9] Fix style --- .../cypress/tests/codeView/codeView_codeHighlighting.cy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js index 74fddf162e..72613a6030 100644 --- a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js +++ b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js @@ -9,7 +9,7 @@ describe('code highlighting works properly', () => { cy.get('#tab-authorship .files', { timeout: 90000 }) .should('be.visible'); - + cy.get('.hljs-comment').contains('* Represents a Git Author.') .parent() // .line-content .parent() // .code @@ -57,11 +57,11 @@ describe('code highlighting works properly', () => { cy.get('#tab-authorship .files', { timeout: 90000 }) .should('be.visible'); - + cy.get('.hljs-title').contains('Author') .parent() // .hljs-class .parent() // .line-content .parent() // .code .should('have.css', 'background-color', 'rgb(255, 255, 255)'); // #ffffff }); -}); \ No newline at end of file +}); From 3fa0676fa5fcfcaf405349d2304afc8596cfefba Mon Sep 17 00:00:00 2001 From: sopa301 <96387349+sopa301@users.noreply.github.com> Date: Thu, 22 Feb 2024 21:10:26 +0800 Subject: [PATCH 3/9] Fix style --- .../cypress/tests/codeView/codeView_codeHighlighting.cy.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js index 72613a6030..dc6772ce09 100644 --- a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js +++ b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js @@ -40,11 +40,12 @@ describe('code highlighting works properly', () => { .should('have.css', 'background-color') .and('not.eq', 'rgb(255, 255, 255)') // #ffffff .then((color) => { - cy.get('.line-content').contains(`'red': (`) // jamessspanggg + // eslint-disable-next-line quotes + cy.get('.line-content').contains("'red': (") // jamessspanggg .parent() // .code .should('have.css', 'background-color') .and('not.eq', color) - .and('not.eq', 'rgb(255, 255, 255)') + .and('not.eq', 'rgb(255, 255, 255)'); }); }); From 3fbe48b304598e21dfdee692a2ceb9dd4437cd46 Mon Sep 17 00:00:00 2001 From: sopa301 <96387349+sopa301@users.noreply.github.com> Date: Thu, 22 Feb 2024 23:35:22 +0800 Subject: [PATCH 4/9] Fix date to 2021 --- .../tests/codeView/codeView_codeHighlighting.cy.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js index dc6772ce09..70d8e1465d 100644 --- a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js +++ b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js @@ -1,6 +1,10 @@ -// Assumes: RepoSense repo from 03/05/2018 to current date +// Assumes: RepoSense repo from 03/05/2018 to 01/01/2021 is used describe('code highlighting works properly', () => { it('should highlight code when there is a single author', () => { + // change until date + cy.get('input[name="until"]:visible') + .type('2021-01-01'); + // open the code panel cy.get('.icon-button.fa-code') .should('be.visible') @@ -17,6 +21,10 @@ describe('code highlighting works properly', () => { }); it('should highlight code when multiple authors are merged in a repo group', () => { + // change until date + cy.get('input[name="until"]:visible') + .type('2021-01-01'); + cy.get('div.mui-select.grouping > select:visible') .select('groupByRepos'); @@ -50,6 +58,10 @@ describe('code highlighting works properly', () => { }); it('should not highlight non-attributed lines', () => { + // change until date + cy.get('input[name="until"]:visible') + .type('2021-01-01'); + // open the code panel cy.get('.icon-button.fa-code') .should('be.visible') From 51c2d695042ec245a500672fa7726ef2cdcd37d9 Mon Sep 17 00:00:00 2001 From: sopa301 <96387349+sopa301@users.noreply.github.com> Date: Thu, 22 Feb 2024 23:42:25 +0800 Subject: [PATCH 5/9] Revert changes --- .../tests/codeView/codeView_codeHighlighting.cy.js | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js index 70d8e1465d..dc6772ce09 100644 --- a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js +++ b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js @@ -1,10 +1,6 @@ -// Assumes: RepoSense repo from 03/05/2018 to 01/01/2021 is used +// Assumes: RepoSense repo from 03/05/2018 to current date describe('code highlighting works properly', () => { it('should highlight code when there is a single author', () => { - // change until date - cy.get('input[name="until"]:visible') - .type('2021-01-01'); - // open the code panel cy.get('.icon-button.fa-code') .should('be.visible') @@ -21,10 +17,6 @@ describe('code highlighting works properly', () => { }); it('should highlight code when multiple authors are merged in a repo group', () => { - // change until date - cy.get('input[name="until"]:visible') - .type('2021-01-01'); - cy.get('div.mui-select.grouping > select:visible') .select('groupByRepos'); @@ -58,10 +50,6 @@ describe('code highlighting works properly', () => { }); it('should not highlight non-attributed lines', () => { - // change until date - cy.get('input[name="until"]:visible') - .type('2021-01-01'); - // open the code panel cy.get('.icon-button.fa-code') .should('be.visible') From 1904414b812bde0595c3bef3f6959af7e04812a7 Mon Sep 17 00:00:00 2001 From: sopa301 <96387349+sopa301@users.noreply.github.com> Date: Sun, 3 Mar 2024 22:46:39 +0800 Subject: [PATCH 6/9] Specify correct colours for highlighting test --- .../cypress/tests/codeView/codeView_codeHighlighting.cy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js index dc6772ce09..d2e9b4caed 100644 --- a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js +++ b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js @@ -38,14 +38,14 @@ describe('code highlighting works properly', () => { .parent() // .line-content .parent() // .code .should('have.css', 'background-color') - .and('not.eq', 'rgb(255, 255, 255)') // #ffffff + .and('eq', 'rgb(30, 144, 255)') // #1e90ff .then((color) => { // eslint-disable-next-line quotes cy.get('.line-content').contains("'red': (") // jamessspanggg .parent() // .code .should('have.css', 'background-color') .and('not.eq', color) - .and('not.eq', 'rgb(255, 255, 255)'); + .and('eq', 'rgb(240, 128, 128)'); // #f08080 }); }); From e8f820cd48cb3fd6643672b35fe4f311dd05ad2e Mon Sep 17 00:00:00 2001 From: sopa301 <96387349+sopa301@users.noreply.github.com> Date: Sun, 3 Mar 2024 23:07:42 +0800 Subject: [PATCH 7/9] Add transparency values --- .../tests/codeView/codeView_codeHighlighting.cy.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js index d2e9b4caed..80b4a011ce 100644 --- a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js +++ b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js @@ -37,15 +37,14 @@ describe('code highlighting works properly', () => { cy.get('.hljs-comment').contains('* MUI Colors module') // eugenepeh .parent() // .line-content .parent() // .code - .should('have.css', 'background-color') - .and('eq', 'rgb(30, 144, 255)') // #1e90ff + .should('have.css', 'background-color', 'rgba(30, 144, 255, 0.19)') // #1e90ff, transparencyValue 30 .then((color) => { // eslint-disable-next-line quotes cy.get('.line-content').contains("'red': (") // jamessspanggg .parent() // .code - .should('have.css', 'background-color') - .and('not.eq', color) - .and('eq', 'rgb(240, 128, 128)'); // #f08080 + // #f08080, transparencyValue 30 + .should('have.css', 'background-color', 'rgba(240, 128, 128, 0.19)') + .and('not.eq', color); }); }); From d8d431992e9bfd5b3bbbd8382c252b778ec0ec39 Mon Sep 17 00:00:00 2001 From: sopa301 <96387349+sopa301@users.noreply.github.com> Date: Sat, 16 Mar 2024 18:27:59 +0800 Subject: [PATCH 8/9] Change var name --- .../cypress/tests/codeView/codeView_codeHighlighting.cy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js index 80b4a011ce..38e923fd74 100644 --- a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js +++ b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js @@ -38,13 +38,13 @@ describe('code highlighting works properly', () => { .parent() // .line-content .parent() // .code .should('have.css', 'background-color', 'rgba(30, 144, 255, 0.19)') // #1e90ff, transparencyValue 30 - .then((color) => { + .then((firstAuthorColor) => { // eslint-disable-next-line quotes cy.get('.line-content').contains("'red': (") // jamessspanggg .parent() // .code // #f08080, transparencyValue 30 .should('have.css', 'background-color', 'rgba(240, 128, 128, 0.19)') - .and('not.eq', color); + .and('not.eq', firstAuthorColor); }); }); From b4eaaa368de2cab3d7f40979925a680bb2c19afb Mon Sep 17 00:00:00 2001 From: sopa301 <96387349+sopa301@users.noreply.github.com> Date: Sat, 16 Mar 2024 18:38:59 +0800 Subject: [PATCH 9/9] Fix not visible buttons failing tests --- .../cypress/tests/codeView/codeView_codeHighlighting.cy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js index 38e923fd74..adbd9c338c 100644 --- a/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js +++ b/frontend/cypress/tests/codeView/codeView_codeHighlighting.cy.js @@ -3,7 +3,7 @@ describe('code highlighting works properly', () => { it('should highlight code when there is a single author', () => { // open the code panel cy.get('.icon-button.fa-code') - .should('be.visible') + .should('exist') .first() .click(); @@ -27,7 +27,7 @@ describe('code highlighting works properly', () => { // open the code panel cy.get('.icon-button.fa-code') - .should('be.visible') + .should('exist') .first() .click(); @@ -51,7 +51,7 @@ describe('code highlighting works properly', () => { it('should not highlight non-attributed lines', () => { // open the code panel cy.get('.icon-button.fa-code') - .should('be.visible') + .should('exist') .first() .click();