Skip to content

Commit

Permalink
feat/favourite-activity-test-created (#544)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ArthurEncr authored Oct 23, 2023
1 parent cbc72d5 commit 178b2fd
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 2 deletions.
148 changes: 147 additions & 1 deletion frontend/cypress/e2e/smoke-test/dashboard-page.cy.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -13,7 +15,7 @@ describe('Dashboard page test', () => {
dashboardPageData = fData;
});
cy.login();
cy.visit('/dashboard');
cy.visit('/');
cy.url().should('contains', '/dashboard');
});

Expand All @@ -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!");
});
});
3 changes: 2 additions & 1 deletion frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -39,7 +40,7 @@ const root = ReactDOM.createRoot(
root.render(
<AuthProvider>
<React.StrictMode>
<ClassPrefix prefix="bx">
<ClassPrefix prefix={prefix}>
<ThemePreference>
<QueryClientProvider client={queryClient}>
<App />
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/styles/classPrefix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const prefix = 'bx';

export default prefix;

0 comments on commit 178b2fd

Please sign in to comment.