From 178b2fd8e8e146f82d9fb2916654d60b42c9682d Mon Sep 17 00:00:00 2001 From: Arthur Alves <117835311+ArthurEncr@users.noreply.github.com> Date: Mon, 23 Oct 2023 13:38:53 -0300 Subject: [PATCH] feat/favourite-activity-test-created (#544) * feat/favourite-activity-test-created * fix: fixing typo * feat: dashboard test divided into small parts * feat: class prefix created * fix: tests divided into smaller parts * fix: removing delays * fix: changing way to select delect and hightlight button * fix: check if card is gone after delete * fix: fixing name of test --- .../e2e/smoke-test/dashboard-page.cy.ts | 148 +++++++++++++++++- frontend/src/index.tsx | 3 +- frontend/src/styles/classPrefix.ts | 3 + 3 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 frontend/src/styles/classPrefix.ts diff --git a/frontend/cypress/e2e/smoke-test/dashboard-page.cy.ts b/frontend/cypress/e2e/smoke-test/dashboard-page.cy.ts index 054ee30c4..e495dc913 100644 --- a/frontend/cypress/e2e/smoke-test/dashboard-page.cy.ts +++ b/frontend/cypress/e2e/smoke-test/dashboard-page.cy.ts @@ -1,4 +1,6 @@ import { NavigationLabels } from '../../utils/labels'; +import prefix from '../../../src/styles/classPrefix'; +import { HALF_SECOND, ONE_SECOND } from '../../constants'; describe('Dashboard page test', () => { let dashboardPageData: { @@ -13,7 +15,7 @@ describe('Dashboard page test', () => { dashboardPageData = fData; }); cy.login(); - cy.visit('/dashboard'); + cy.visit('/'); cy.url().should('contains', '/dashboard'); }); @@ -29,4 +31,148 @@ describe('Dashboard page test', () => { .find('.recent-activity-subtitle') .should('have.text', dashboardPageData.secondSectionSubtitle); }); + + it('seedlots favourite activity is working properly', () => { + // Navigate to Seedlot page + cy.navigateTo(NavigationLabels.Seedlots); + // Favourite Seedlot page + cy.get('.title-favourite') + .find(`.${prefix}--popover-container`) + .click(); + // Navigate to Dashboard page + cy.navigateTo(NavigationLabels.Dashboard); + // Check if seedlot card is appearing at favourites activities + cy.get('.favourite-activities-cards') + .find('.fav-card-content') + .find('.fav-card-title-large') + .contains('Seedlots') + .click(); + cy.isPageTitle(NavigationLabels.Seedlots); + }); + + it('a class seedlot favourite activity is working properly', () => { + // Navigate to Seedlot page + cy.navigateTo(NavigationLabels.Seedlots); + + // Favourite A class Seedlot page + cy.get('.seedlot-activities-cards') + .find('.std-card-title') + .contains('Register an A class seedlot') + .click(); + cy.get('.title-favourite') + .find(`.${prefix}--popover-container`) + .click(); + + // Navigate to Dashboard page + cy.navigateTo(NavigationLabels.Dashboard); + + // Check if Create A Class Seedlot card is appearing at favourites activities + cy.get('.favourite-activities-cards') + .find('.fav-card-content') + .find('.fav-card-title-large') + .contains('Create A class seedlot') + .click(); + + cy.isPageTitle('Create A class seedlot'); + }); + + it('my Seedlots favourite activity is working properly', () => { + // Navigate to My seedlot page + cy.navigateTo(NavigationLabels.Seedlots); + cy.get('.seedlot-activities-cards') + .find('.std-card-title') + .contains('My seedlots') + .click(); + + // Favourite My Seedlot page + cy.get('.title-favourite') + .find(`.${prefix}--popover-container`) + .click(); + + // Navigate to Dashboard page + cy.navigateTo(NavigationLabels.Dashboard); + + // Check if My Seedlot card is appearing at favourites activities + // and if redirects to the correct page + cy.get('.favourite-activities-cards') + .find('.fav-card-content') + .find('.fav-card-title-large') + .contains('My Seedlots') + .click(); + + cy.isPageTitle('My Seedlots'); + }); + + it('highlight favourite activity is working', () => { + // Highlight Seedlots Card + cy.get('.favourite-activities-cards') + .find('.fav-card-main:first') + .find('.fav-card-overflow') + .click(); + cy.get(`.${prefix}--overflow-menu-options__option-content`) + .contains('Highlight shortcut') + .click(); + + // Check if the Seedlots card is unique and highlighted + cy.get('.fav-card-main-highlighted') + .should('have.length', 1) + .should('contain.text', 'Seedlots'); + + // Highlight Create A Class Seedlot card + cy.get('.favourite-activities-cards') + .find('.fav-card-main:first') + .find('.fav-card-overflow') + .click(); + cy.get(`.${prefix}--overflow-menu-options__option-content`) + .contains('Highlight shortcut') + .click(); + + // Check if the Create A Class Seedlot card is unique and highlighted + cy.get('.fav-card-main-highlighted') + .should('have.length', 1) + .should('contain.text', 'Create A class seedlot'); + }); + + it('check if delete my seedlots favourite card is working', () => { + // Delete My Seedlots card + cy.get('.favourite-activities-cards') + .find('.fav-card-main:first') + .find('.fav-card-overflow') + .click(); + cy.get(`.${prefix}--overflow-menu-options__option-content`) + .contains('Delete shortcut') + .click(); + cy.get('.fav-card-main') + .should('have.length', 1); + }); + + it('check if delete create a class seedlot favourite card is working', () => { + // Delete Create A Class Seedlot card + cy.get('.fav-card-main-highlighted') + .find('.fav-card-overflow') + .click(); + cy.get(`.${prefix}--overflow-menu-options__option-content`) + .contains('Delete shortcut') + .click(); + cy.get('.fav-card-main-highlighted') + .should('have.length', 0); + }); + + it('check if delete seedlots favourite card is working', () => { + // Delete Seedlots card + cy.get('.favourite-activities-cards') + .find('.fav-card-main:first') + .find('.fav-card-overflow') + .click(); + cy.get(`.${prefix}--overflow-menu-options__option-content`) + .contains('Delete shortcut') + .click(); + cy.get('.fav-card-main') + .should('have.length', 0); + }); + + it('check if the empty section is correctly appearing', () => { + cy.get('.empty-section-title') + .should('contain.text', "You don't have any favourites to show yet!"); + }); }); diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index 25bc8a618..d6da46354 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -9,6 +9,7 @@ import { AuthProvider } from './contexts/AuthContext'; import { ThemePreference } from './utils/ThemePreference'; import { env } from './env'; import makeServer from './mock-server/server'; +import prefix from './styles/classPrefix'; const appVersion: string = env.VITE_NRSPARWEBAPP_VERSION || 'dev'; @@ -39,7 +40,7 @@ const root = ReactDOM.createRoot( root.render( - + diff --git a/frontend/src/styles/classPrefix.ts b/frontend/src/styles/classPrefix.ts new file mode 100644 index 000000000..074ac9422 --- /dev/null +++ b/frontend/src/styles/classPrefix.ts @@ -0,0 +1,3 @@ +const prefix = 'bx'; + +export default prefix;