Skip to content

Commit

Permalink
feat: build out tests and stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
rushtong committed Nov 1, 2024
1 parent 5256704 commit 5ac93aa
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 132 deletions.
10 changes: 7 additions & 3 deletions cypress/component/DAC/editDac.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import React from 'react';
import {mount} from 'cypress/react';
import {DAA} from '../../../src/libs/ajax/DAA';
import {DAC} from '../../../src/libs/ajax/DAC';
import {Storage} from '../../../src/libs/storage';
import EditDac from '../../../src/pages/manage_dac/EditDac';
Expand All @@ -18,18 +19,21 @@ const WrappedEditDac = (props) => {
describe('EditDAC Tests', () => {

Cypress._.each([admin, chair], (user) => {
it('Should Load for ' + user.displayName, () => {
cy.viewport(600, 600);
it('Edit DAC page should load for ' + user.displayName, () => {
cy.viewport(600, 800);
cy.stub(Storage, 'getCurrentUser').returns(user);
cy.stub(DAC, 'get').returns(dac);
const props = {match: {params: {dacId: 1}}};
cy.stub(DAA, 'getDaas').returns([]);
const props = {match: {params: {dacId: dac.dacId}}};
mount(WrappedEditDac(props));
cy.contains(dac.name).should('exist');
cy.get('[data-cy="dac_name"]').should('not.be.disabled');
cy.get('[data-cy="dac_description"]').should('not.be.disabled');
cy.get('[data-cy="dac_email"]').should('not.be.disabled');
cy.get('[data-cy="btn_save"]').should('not.be.disabled');
cy.get('[data-cy="btn_cancel"]').should('not.be.disabled');
cy.get('[data-cy="daa_radio"]').should('not.be.disabled');
cy.get('[data-cy="daa_upload_button"]').should('not.be.disabled');
});
});

Expand Down
7 changes: 5 additions & 2 deletions cypress/component/DAC/manageEditDac.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ const WrappedManageEditDac = (props) => {
return <BrowserRouter><ManageEditDac {...props}/></BrowserRouter>;
};

/**
* This manage page is the pre-Data Access Agreement way to edit a DAC and will be removed when DAA work is complete.
*/
describe('ManageEditDAC Tests', () => {

Cypress._.each([admin, chair], (user) => {
it('Should Load for ' + user.displayName, () => {
it('Manage Edit DAC page should load for ' + user.displayName, () => {
cy.viewport(600, 600);
cy.stub(Storage, 'getCurrentUser').returns(user);
cy.stub(DAC, 'get').returns(dac);
const props = {match: {params: {dacId: 1}}};
const props = {match: {params: {dacId: dac.dacId}}};
mount(WrappedManageEditDac(props));
cy.contains(dac.name).should('exist');
cy.get('[data-cy="dac_name"]').should('not.be.disabled');
Expand Down
Loading

0 comments on commit 5ac93aa

Please sign in to comment.