Skip to content

Commit

Permalink
Added Cypress Test For organization page
Browse files Browse the repository at this point in the history
  • Loading branch information
aliraza556 committed Mar 19, 2024
1 parent 5a38c86 commit 66c02da
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 11 deletions.
23 changes: 12 additions & 11 deletions cypress/e2e/24_createOrgPageBounty.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('View Organization Bounties', () => {
const OrgName = 'AliSoftTech';
describe('Create org bounty from Organization Page', () => {
const OrgName = 'Ali SoftDev';

const org: Cypress.Organization = {
loggedInAs: 'alice',
Expand Down Expand Up @@ -45,7 +45,7 @@ describe('View Organization Bounties', () => {
cy.wait(1000);
});

it('should verify bounty tile displays the organization label is clickable and redirects the user to the organizations bounty page.', () => {
it('should verify bounty tile displays the organization label is clickable and redirects the user to the organizations bounty page and create a new bounty', () => {
cy.create_bounty(bounty);
cy.wait(5000);

Expand All @@ -67,14 +67,15 @@ describe('View Organization Bounties', () => {
cy.get('[data-testid="Organization"]').contains(org.name).should('exist').and('be.visible');
cy.wait(1000);

cy.get('body').click(0, 0);
cy.wait(600);
// cy.create_bounty(orgPageBounty);
// cy.wait(5000);
//
// cy.contains(bounty.title).should('exist').and('be.visible');
// cy.wait(5000);
cy.get('[data-testid="close-btn"]').click();
cy.wait(1000);

cy.create_orgBounty(orgPageBounty);
cy.wait(5000);

cy.contains(orgPageBounty.title).should('exist').and('be.visible');
cy.wait(5000);

// cy.logout(org.loggedInAs);
cy.logout(org.loggedInAs);
});
});
1 change: 1 addition & 0 deletions cypress/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ declare namespace Cypress {
login(userAlias: string): void;
logout(userAlias: string): void;
create_bounty(bounty: Bounty, clickMethod?: 'contains' | 'testId'): void;
create_orgBounty(orgBounty: Bounty): void;
lnurl_login(): void;
create_org(Organization: Organization): void;
pay_invoice(details: InvoiceDetail): void;
Expand Down
65 changes: 65 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,71 @@ Cypress.Commands.add('create_bounty', (bounty, clickMethod = 'contains') => {
cy.contains('Finish').click();
});

Cypress.Commands.add('create_orgBounty', (orgBounty) => {
cy.wait(1000);
cy.contains('Post a Bounty').click();
cy.contains('Start').click();

cy.contains('label', 'Bounty Title').type(orgBounty.title);
cy.wait(600);
if (orgBounty.github_issue_url) {
cy.get('[data-testid="Github"]').type(orgBounty.github_issue_url);
}

cy.wait(1000);

if (orgBounty.coding_language && orgBounty.coding_language.length > 0) {
cy.contains('Coding Language').click();

for (let i = 0; i < orgBounty.coding_language.length; i++) {
cy.get('.CheckboxOuter').contains(orgBounty.coding_language[i]).scrollIntoView().click();
}
cy.contains('Coding Language').click();
}

cy.get('[data-testid="Category *"]').click();
cy.get('[data-testid="Category *"]').contains(orgBounty.category).click();

cy.contains('Next').click();

cy.get('.euiTextArea').type(orgBounty.description);
cy.contains('Next').click();

cy.contains('label', 'Price (Sats)').type(orgBounty.amount);

if (orgBounty.estimate_session_length) {
cy.get('[data-testid="Estimate Session Length"]').find('button').click();

cy.get('[data-testid="Estimate Session Length"]')
.contains(orgBounty.estimate_session_length)
.click();
}

if (orgBounty.estimate_completion_date) {
cy.get('.react-datepicker__input-container > .euiDatePicker').click();
cy.get('.react-datepicker__input-container > .euiDatePicker').type('{selectAll}');
cy.wait(100);
cy.get('.react-datepicker__input-container > .euiDatePicker').type(
orgBounty.estimate_completion_date
);
}

if (orgBounty.deliverables) {
cy.get('textarea.inputText').type(orgBounty.deliverables);
}

cy.contains('Next').click();

if (orgBounty.assign) {
cy.get('.SearchInput').type(orgBounty.assign);
cy.wait(1000);
cy.get('.People').contains('Assign').click();
} else {
cy.contains('Decide Later').click();
}

cy.contains('Finish').click();
});
Cypress.Commands.add('lnurl_login', () => {
cy.visit('http://localhost:3007');
cy.contains('Sign in').click();
Expand Down

0 comments on commit 66c02da

Please sign in to comment.