Skip to content

Commit

Permalink
test(e2e): add coverage for chart of accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Jan 28, 2025
1 parent b598275 commit a34d439
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/cypress/integration/31-chart-of-accounts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
describe('Chart of Accounts', () => {
let user;
let host;

before(() => {
cy.signup().then(u => {
user = u;
cy.createHostOrganization(user.email).then(returnedAccount => {
host = returnedAccount;
cy.visit(`/dashboard/${host.slug}/chart-of-accounts`);
});
});
});

it('should support all chart of accounts operations', () => {
// Create category
cy.contains('button', 'Create category').click();

// Fill form (the form is currently missing validations, see https://github.com/opencollective/opencollective/issues/7809)
// TODO

// Verify category was added
// TODO

// Test filtering by kind
// TODO

// Test filtering by visibility
// TODO

// Test search by code
// TODO

// Test search by name
// TODO

// Test search by friendly name
// TODO

// Test sorting by code
// TODO

// Test sorting by name
// TODO

// Test category deletion
// TODO

// Open and verify drawer
// TODO
});
});
40 changes: 40 additions & 0 deletions test/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,46 @@ Cypress.Commands.add('createProject', ({ userEmail = defaultTestUserEmail, colle
});
});

Cypress.Commands.add('createHostOrganization', (userEmail, variables) => {
return signinRequest({ email: userEmail }, null).then(response => {
const token = getTokenFromRedirectUrl(response.body.redirect);
return graphqlQueryV2(token, {
operationName: 'CreateOrganization',
query: gql`
mutation CreateOrganization($organization: OrganizationCreateInput!, $inviteMembers: [InviteMemberInput!]) {
createOrganization(organization: $organization, inviteMembers: $inviteMembers) {
id
legacyId
slug
}
}
`,
variables: {
...variables,
organization: {
slug: randomSlug(),
description: 'Test Host',
name: 'Test Host',
...variables?.organization,
},
},
}).then(({ body }) => {
const host = body.data.createOrganization;
return graphqlQuery(token, {
operationName: 'ActivateCollectiveAsHost',
query: gqlV1`
mutation ActivateCollectiveAsHost($id: Int!) {
activateCollectiveAsHost(id: $id) {
id
}
}
`,
variables: { id: host.legacyId },
}).then(() => host);
});
});
});

Cypress.Commands.add('graphqlQueryV2', (query, { variables = {}, token = null } = {}) => {
return graphqlQueryV2(token, { query, variables }).then(({ body }) => {
return body.data;
Expand Down

0 comments on commit a34d439

Please sign in to comment.