From 54b1af6624893fdd06faa5a162302d40cc0aa6a8 Mon Sep 17 00:00:00 2001 From: Milan Pospisil Date: Tue, 16 Nov 2021 12:38:59 +0100 Subject: [PATCH 1/7] paging, filtering --- test/cypress/integration/collectionsList.js | 72 +++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 test/cypress/integration/collectionsList.js diff --git a/test/cypress/integration/collectionsList.js b/test/cypress/integration/collectionsList.js new file mode 100644 index 0000000000..e3767ed6f7 --- /dev/null +++ b/test/cypress/integration/collectionsList.js @@ -0,0 +1,72 @@ +import { range, sortBy } from 'lodash'; + +describe('Collections list Tests', () => { + var adminUsername = Cypress.env('username'); + var adminPassword = Cypress.env('password'); + let items = []; + + before(() => { + cy.login(adminUsername, adminPassword); + + // insert test data + range(21).forEach((i) => { + let item = { name: 'my_collection' + i }; + items.push(item); + //cy.galaxykit('-i collection upload my_namespace my_collection'+i); + }); + + // load items, some data may be present from previous test, so we must load them, we can not expect + // that only our test data are in database + cy.intercept( + 'GET', + Cypress.env('prefix') + + '_ui/v1/repo/published/?deprecated=false&offset=0&limit=100', + ).as('data'); + cy.visit('/ui/repo/published?page_size=100&view_type=null&page=1'); + + let data = []; + cy.wait('@data').then((res) => { + items = res.response.body.data; + + items.forEach((item) => { + cy.log(item.name); + }); + }); + }); + + beforeEach(() => { + cy.login(adminUsername, adminPassword); + }); + + it('paging is working', () => { + // this page cant sort items, so we can only count them, there should be at least 21 items that we inserted + cy.visit('/ui/repo/published'); + cy.get('.collection-container').get('article').should('have.length', 10); + + cy.get('.cards').get('[aria-label="Go to next page"]:first').click(); + cy.get('.collection-container').get('article').should('have.length', 10); + + cy.get('.cards').get('[aria-label="Go to next page"]:first').click(); + // some remaining data can be there from previous tests + var remaining = items.length - 20; + if (remaining > 10) remaining = 10; + cy.get('.collection-container') + .get('article') + .should('have.length', remaining); + }); + + it('filter is working', () => { + cy.get('.cards') + .get('[aria-label="keywords"]:first') + .type('my_collection0{enter}'); + cy.get('.cards').contains('my_collection0'); + cy.get('.cards').contains('my_collection1').should('not.exist'); + }); + + it('set page size is working', () => { + cy.get('.cards').get('button[aria-label="Items per page"]:first').click(); + cy.get('.cards').get('[data-action="per-page-20"]').click(); + + cy.get('.collection-container').get('article').should('have.length', 20); + }); +}); From bedc4150172ce4af2585434c481f3a876849b983 Mon Sep 17 00:00:00 2001 From: Milan Pospisil Date: Wed, 17 Nov 2021 12:21:04 +0100 Subject: [PATCH 2/7] Card/List switch --- .../card-list-switcher/card-list-switcher.tsx | 32 +++++++++++-------- test/cypress/integration/collectionsList.js | 17 ++++++---- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/components/card-list-switcher/card-list-switcher.tsx b/src/components/card-list-switcher/card-list-switcher.tsx index 2d32c693a6..4340ffd2fa 100644 --- a/src/components/card-list-switcher/card-list-switcher.tsx +++ b/src/components/card-list-switcher/card-list-switcher.tsx @@ -32,20 +32,24 @@ export class CardListSwitcher extends React.Component { return (
- - updateParams(ParamHelper.setParam(params, 'view_type', 'card')) - } - /> - - updateParams(ParamHelper.setParam(params, 'view_type', 'list')) - } - /> + + + updateParams(ParamHelper.setParam(params, 'view_type', 'card')) + } + /> + + + + updateParams(ParamHelper.setParam(params, 'view_type', 'list')) + } + /> +
); } diff --git a/test/cypress/integration/collectionsList.js b/test/cypress/integration/collectionsList.js index e3767ed6f7..eb0539e278 100644 --- a/test/cypress/integration/collectionsList.js +++ b/test/cypress/integration/collectionsList.js @@ -15,8 +15,9 @@ describe('Collections list Tests', () => { //cy.galaxykit('-i collection upload my_namespace my_collection'+i); }); - // load items, some data may be present from previous test, so we must load them, we can not expect - // that only our test data are in database + // load items. Because galaxykit does not support delete collection yet, + // some data may be present from previous test, so we must load them, we can not expect + // that only our test data are in database. cy.intercept( 'GET', Cypress.env('prefix') + @@ -27,20 +28,16 @@ describe('Collections list Tests', () => { let data = []; cy.wait('@data').then((res) => { items = res.response.body.data; - - items.forEach((item) => { - cy.log(item.name); - }); }); }); beforeEach(() => { cy.login(adminUsername, adminPassword); + cy.visit('/ui/repo/published'); }); it('paging is working', () => { // this page cant sort items, so we can only count them, there should be at least 21 items that we inserted - cy.visit('/ui/repo/published'); cy.get('.collection-container').get('article').should('have.length', 10); cy.get('.cards').get('[aria-label="Go to next page"]:first').click(); @@ -69,4 +66,10 @@ describe('Collections list Tests', () => { cy.get('.collection-container').get('article').should('have.length', 20); }); + + it('Cards/List switch is working', () => { + cy.get('[data-cy="view_type_list"] svg').click(); + + cy.get('li[aria-labelledby="simple-item1"').should('have.length', 10); + }); }); From 3195214a54764cd8adf1204eb6bb1b963ea77f6e Mon Sep 17 00:00:00 2001 From: Milan Pospisil Date: Wed, 17 Nov 2021 13:38:58 +0100 Subject: [PATCH 3/7] Forgotten comment --- test/cypress/integration/collectionsList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cypress/integration/collectionsList.js b/test/cypress/integration/collectionsList.js index eb0539e278..fab37f8eda 100644 --- a/test/cypress/integration/collectionsList.js +++ b/test/cypress/integration/collectionsList.js @@ -12,7 +12,7 @@ describe('Collections list Tests', () => { range(21).forEach((i) => { let item = { name: 'my_collection' + i }; items.push(item); - //cy.galaxykit('-i collection upload my_namespace my_collection'+i); + cy.galaxykit('-i collection upload my_namespace my_collection' + i); }); // load items. Because galaxykit does not support delete collection yet, From 5d1a889a8414d69438cced08fae17830d312a370 Mon Sep 17 00:00:00 2001 From: Milan Pospisil Date: Thu, 18 Nov 2021 13:32:01 +0100 Subject: [PATCH 4/7] Rename collectionsList to collections_list --- .../integration/{collectionsList.js => collections_list.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/cypress/integration/{collectionsList.js => collections_list.js} (100%) diff --git a/test/cypress/integration/collectionsList.js b/test/cypress/integration/collections_list.js similarity index 100% rename from test/cypress/integration/collectionsList.js rename to test/cypress/integration/collections_list.js From 512cb91eb82495401d56c852d1563a483cb00966 Mon Sep 17 00:00:00 2001 From: Milan Pospisil Date: Wed, 24 Nov 2021 10:01:58 +0100 Subject: [PATCH 5/7] Fix the expression. --- test/cypress/integration/collections_list.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/cypress/integration/collections_list.js b/test/cypress/integration/collections_list.js index fab37f8eda..0b6762b38a 100644 --- a/test/cypress/integration/collections_list.js +++ b/test/cypress/integration/collections_list.js @@ -9,7 +9,7 @@ describe('Collections list Tests', () => { cy.login(adminUsername, adminPassword); // insert test data - range(21).forEach((i) => { + range(41).forEach((i) => { let item = { name: 'my_collection' + i }; items.push(item); cy.galaxykit('-i collection upload my_namespace my_collection' + i); @@ -45,8 +45,7 @@ describe('Collections list Tests', () => { cy.get('.cards').get('[aria-label="Go to next page"]:first').click(); // some remaining data can be there from previous tests - var remaining = items.length - 20; - if (remaining > 10) remaining = 10; + const remaining = items.length > 30 ? 10 : items.length - 20; cy.get('.collection-container') .get('article') .should('have.length', remaining); From 251d447254d048cfaebf7e5d6d27ab3a911d4aa2 Mon Sep 17 00:00:00 2001 From: Milan Pospisil Date: Wed, 24 Nov 2021 10:15:48 +0100 Subject: [PATCH 6/7] Unused variable --- test/cypress/integration/collections_list.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/cypress/integration/collections_list.js b/test/cypress/integration/collections_list.js index 0b6762b38a..d8a4cb0383 100644 --- a/test/cypress/integration/collections_list.js +++ b/test/cypress/integration/collections_list.js @@ -25,7 +25,6 @@ describe('Collections list Tests', () => { ).as('data'); cy.visit('/ui/repo/published?page_size=100&view_type=null&page=1'); - let data = []; cy.wait('@data').then((res) => { items = res.response.body.data; }); From 85af3172db2bd930e57598ba462ce8ca808e40e5 Mon Sep 17 00:00:00 2001 From: Milan Pospisil Date: Thu, 25 Nov 2021 11:32:32 +0100 Subject: [PATCH 7/7] Fix the insert numbers back --- test/cypress/integration/collections_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cypress/integration/collections_list.js b/test/cypress/integration/collections_list.js index d8a4cb0383..71adf84b3c 100644 --- a/test/cypress/integration/collections_list.js +++ b/test/cypress/integration/collections_list.js @@ -9,7 +9,7 @@ describe('Collections list Tests', () => { cy.login(adminUsername, adminPassword); // insert test data - range(41).forEach((i) => { + range(21).forEach((i) => { let item = { name: 'my_collection' + i }; items.push(item); cy.galaxykit('-i collection upload my_namespace my_collection' + i);