Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint the test directory #909

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"deploy": ". ./.env.production && sed -i -e \"s|<host>|$VITE_API_GATEWAY_URL|g\" public/openapi.yaml && npm run build && sed -i -e \"s|$VITE_API_GATEWAY_URL|<host>|g\" public/openapi.yaml && firebase deploy --project=production",
"deploy:test": "npm run build:test && firebase deploy --project=development",
"deploy:feature_branch": "npm run build && firebase hosting:channel:deploy --project=production $npm_config_name",
"lint": "eslint ./src ./functions ./extras --ext .js,.vue,.gs",
"lint:fix": "eslint ./src ./functions ./extras --ext .js,.vue,.gs --fix",
"lint": "eslint ./src ./functions ./extras ./tests --ext .js,.vue,.gs",
"lint:fix": "eslint ./src ./functions ./extras ./tests --ext .js,.vue,.gs --fix",
"lint:style": "stylelint 'src/**/*.scss' 'src/**/*.vue'",
"lint:style:fix": "stylelint 'src/**/*.scss' 'src/**/*.vue' --fix",
"export_mock_data": "firebase emulators:export ./mock_data"
Expand Down
5 changes: 4 additions & 1 deletion tests/e2e/specs/01 Login/01 login_error_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ describe('Login error', () => {
cy.visit('/').wait(500);

cy.get('body').then(($body) => {
if ($body.text().includes('Test Admin') || $body.text().includes(Cypress.env('VITE_TESTUSER_USER'))) {
if (
$body.text().includes('Test Admin') ||
$body.text().includes(Cypress.env('VITE_TESTUSER_USER'))
) {
cy.signOut();
}
});
Expand Down
5 changes: 4 additions & 1 deletion tests/e2e/specs/01 Login/02 login_admin_user_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ describe('Test Admin Login', () => {
cy.visit('/').wait(2000);

cy.get('body').then(($body) => {
if ($body.text().includes('Test Admin') || $body.text().includes(Cypress.env('VITE_TESTUSER_USER'))) {
if (
$body.text().includes('Test Admin') ||
$body.text().includes(Cypress.env('VITE_TESTUSER_USER'))
) {
cy.signOut();
}
});
Expand Down
15 changes: 12 additions & 3 deletions tests/e2e/specs/03 Request access/01 Request_access_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ describe('Request access', () => {
cy.visit('/').wait(2000);

cy.get('body').then(($body) => {
if ($body.text().includes('Test Admin') || $body.text().includes(Cypress.env('VITE_TESTUSER_USER'))) {
if (
$body.text().includes('Test Admin') ||
$body.text().includes(Cypress.env('VITE_TESTUSER_USER'))
) {
cy.signOut();
}
});
Expand Down Expand Up @@ -48,7 +51,10 @@ describe('Request access', () => {
cy.get('[data-cy="request-accept"]').click();
});

cy.get('.toasted').should('contain', i18n.t('toaster.request.accepted', { user: '[email protected]' }));
cy.get('.toasted').should(
'contain',
i18n.t('toaster.request.accepted', { user: '[email protected]' })
);

cy.get('.access-requests__item')
.eq(0)
Expand All @@ -57,6 +63,9 @@ describe('Request access', () => {
cy.get('[data-cy="request-reject"]').click();
});

cy.get('.toasted').should('contain', i18n.t('toaster.request.rejected', { user: '[email protected]' }));
cy.get('.toasted').should(
'contain',
i18n.t('toaster.request.rejected', { user: '[email protected]' })
);
});
});
21 changes: 16 additions & 5 deletions tests/e2e/specs/10 Organization/organization_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ describe('Create department', () => {

cy.get('.title-1').should('contain', testOrganization.name);
cy.get('.team__list').should('be.empty');
cy.get('[data-cy="mission_statement"]').should('contain', testOrganization.mission_statement);
cy.get('[data-cy="mission_statement"]').should(
'contain',
testOrganization.mission_statement
);
cy.get('[data-cy="objectives_list"] .title').should('contain', '(0)');
});
});
Expand Down Expand Up @@ -45,7 +48,9 @@ describe('Create data for organization', () => {

cy.get('[data-cy="objective_name_field"]').clear().type(testObjective.name);

cy.get('[data-cy="objective_description_field"]').clear().type(testObjective.description);
cy.get('[data-cy="objective_description_field"]')
.clear()
.type(testObjective.description);

cy.get('[data-cy="save_objective_button"]').click();
});
Expand All @@ -55,11 +60,17 @@ describe('Create data for organization', () => {

cy.get('[data-cy="keyResult_name_field"]').clear().type(testKeyResult.name);

cy.get('[data-cy="keyResult_longdescription_field"]').clear().type(testKeyResult.longDescription);
cy.get('[data-cy="keyResult_longdescription_field"]')
.clear()
.type(testKeyResult.longDescription);

cy.get('[data-cy="keyResult_startvalue_field"]').clear().type(testKeyResult.startValue);
cy.get('[data-cy="keyResult_startvalue_field"]')
.clear()
.type(testKeyResult.startValue);

cy.get('[data-cy="keyResult_targetvalue_field"]').clear().type(testKeyResult.targetValue);
cy.get('[data-cy="keyResult_targetvalue_field"]')
.clear()
.type(testKeyResult.targetValue);

cy.get('[data-cy="keyResult_unit_field"]').clear().type(testKeyResult.unit);

Expand Down
34 changes: 26 additions & 8 deletions tests/e2e/specs/20 Department/department_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ describe('Create department', () => {

cy.get('.title-1').should('contain', testDepartment.name);
cy.get('.team__list').should('be.empty');
cy.get('[data-cy="mission_statement"]').should('contain', testDepartment.mission_statement);
cy.get('[data-cy="mission_statement"]').should(
'contain',
testDepartment.mission_statement
);
cy.get('[data-cy="objectives_list"] .title').should('contain', '(0)');
});
});
Expand All @@ -43,7 +46,9 @@ describe('Create data for department', () => {

cy.get('[data-cy="objective_name_field"]').clear().type(testObjective.name);

cy.get('[data-cy="objective_description_field"]').clear().type(testObjective.description);
cy.get('[data-cy="objective_description_field"]')
.clear()
.type(testObjective.description);

cy.get('[data-cy="save_objective_button"]').click();
});
Expand All @@ -53,11 +58,17 @@ describe('Create data for department', () => {

cy.get('[data-cy="keyResult_name_field"]').clear().type(testKeyResult.name);

cy.get('[data-cy="keyResult_longdescription_field"]').clear().type(testKeyResult.longDescription);
cy.get('[data-cy="keyResult_longdescription_field"]')
.clear()
.type(testKeyResult.longDescription);

cy.get('[data-cy="keyResult_startvalue_field"]').clear().type(testKeyResult.startValue);
cy.get('[data-cy="keyResult_startvalue_field"]')
.clear()
.type(testKeyResult.startValue);

cy.get('[data-cy="keyResult_targetvalue_field"]').clear().type(testKeyResult.targetValue);
cy.get('[data-cy="keyResult_targetvalue_field"]')
.clear()
.type(testKeyResult.targetValue);

cy.get('[data-cy="keyResult_unit_field"]').clear().type(testKeyResult.unit);

Expand Down Expand Up @@ -119,19 +130,26 @@ describe('Create progress for key result', () => {

cy.get('svg text.percent').should('contain', '50%');

cy.get('[data-cy="objectives_list"]').should('contain', '(50%)').should('contain', testObjective.description);
cy.get('[data-cy="objectives_list"]')
.should('contain', '(50%)')
.should('contain', testObjective.description);

cy.get('.progress__current-value').should('contain', testKeyResult.progressValue);
});

it('Updates progress from product page (inline)', () => {
cy.get('button.keyResult__toggle').click();

cy.get('.keyResult__edit input').clear().type(`${testKeyResult.targetValue} {enter}`).wait(2500);
cy.get('.keyResult__edit input')
.clear()
.type(`${testKeyResult.targetValue} {enter}`)
.wait(2500);

cy.get('svg text.percent').should('contain', '100%');

cy.get('[data-cy="objectives_list"]').should('contain', '(100%)').should('contain', testObjective.description);
cy.get('[data-cy="objectives_list"]')
.should('contain', '(100%)')
.should('contain', testObjective.description);

cy.get('.progress__bar').should('have.class', 'completed');
});
Expand Down
8 changes: 6 additions & 2 deletions tests/e2e/specs/30 Product/02 objectives.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ describe('Create objectives', () => {
if (!$body.text().includes(testPeriod.name)) {
cy.log('Period exists');
} else {
cy.visit(`/product/${testProducts[0].slug}/edit/objectives-key-results`).wait(1000);
cy.visit(`/product/${testProducts[0].slug}/edit/objectives-key-results`).wait(
1000
);
cy.createPeriod();
}
});
Expand All @@ -48,7 +50,9 @@ describe('Create objectives', () => {
if (!$body.text().includes(testPeriod.name)) {
cy.log('Period exists');
} else {
cy.visit(`/product/${testProducts[1].slug}/edit/objectives-key-results`).wait(1000);
cy.visit(`/product/${testProducts[1].slug}/edit/objectives-key-results`).wait(
1000
);
cy.createPeriod();
}
});
Expand Down
5 changes: 4 additions & 1 deletion tests/e2e/specs/40 Whitelist user/01 whitelist.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ describe('Whitelist user', () => {
});

it('Finds the test user with search', () => {
cy.get('[data-cy="user_search_field"]').clear().type(Cypress.env('VITE_TESTUSER_USER')).wait(100);
cy.get('[data-cy="user_search_field"]')
.clear()
.type(Cypress.env('VITE_TESTUSER_USER'))
.wait(100);

cy.get('.whitelist__body').should('contain', Cypress.env('VITE_TESTUSER_USER'));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ describe('Verifies restrictions for test user', () => {
});

it('Logs in as test user', () => {
cy.get('input[type="password"]').type(
Cypress.env('VITE_TESTUSER_PASSWORD')
);
cy.get('input[type="password"]').type(Cypress.env('VITE_TESTUSER_PASSWORD'));
cy.get('form').submit();
cy.wait(1000);

Expand Down Expand Up @@ -60,10 +58,7 @@ describe('Verifies restrictions for test user', () => {
it('Allows test user to edit Product One', () => {
cy.get('[data-cy="edit_object_link"]').click().wait(500);

cy.get('[data-cy="product_name_field"]').should(
'have.value',
testProducts[0].name
);
cy.get('[data-cy="product_name_field"]').should('have.value', testProducts[0].name);

cy.get('[data-cy="product_mission_statement_field"]')
.clear()
Expand Down
6 changes: 5 additions & 1 deletion tests/e2e/support/createObjective.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { testObjective, testPeriod } from '../config';
Cypress.Commands.add('createObjective', () => {
cy.get('[data-cy="add_objective"]').click().wait(500);

cy.get('[data-cy="period_selector"]').click().type(testPeriod.name).get('.vs__dropdown-menu > li').click();
cy.get('[data-cy="period_selector"]')
.click()
.type(testPeriod.name)
.get('.vs__dropdown-menu > li')
.click();

cy.get('[data-cy="objective_title_field"]').clear().type(testObjective.name);

Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/support/createOrg.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Cypress.Commands.add('createTestOrg', () => {

cy.get('[data-cy="org-name"]').clear().type(testOrganization.name);

cy.get('[data-cy="org-missionStatement"]').clear().type(testOrganization.mission_statement);
cy.get('[data-cy="org-missionStatement"]')
.clear()
.type(testOrganization.mission_statement);

cy.get('[data-cy="btn-createOrg"]').click();

Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/support/createProduct.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Cypress.Commands.add('createProduct', (productIndex) => {

cy.get('[data-cy="product_name_field"]').clear().type(testProducts[productIndex].name);

cy.get('[data-cy="product_mission_statement_field"]').clear().type(testProducts[productIndex].mission_statement);
cy.get('[data-cy="product_mission_statement_field"]')
.clear()
.type(testProducts[productIndex].mission_statement);

cy.get('[data-cy="save_product_button"]').click();
});
8 changes: 6 additions & 2 deletions tests/e2e/support/createTestDepartment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ Cypress.Commands.add('createTestDepartment', () => {

cy.get('[data-cy="dep-name"]').clear().type(testDepartment.name);

cy.get('[data-cy="dep-missionStatement"]').clear().type(testDepartment.mission_statement);
cy.get('[data-cy="dep-missionStatement"]')
.clear()
.type(testDepartment.mission_statement);

cy.get('[data-cy="dep-parentOrg"]').select(testDepartment.parentOrg).should('have.value', testDepartment.parentOrg);
cy.get('[data-cy="dep-parentOrg"]')
.select(testDepartment.parentOrg)
.should('have.value', testDepartment.parentOrg);

cy.get('[data-cy="btn-createDep"]').click();
});
10 changes: 8 additions & 2 deletions tests/e2e/support/deleteProduct.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ Cypress.Commands.add('deleteProduct', (productIndex) => {

cy.get('.miller__col__item').contains(testDepartment.name).click().wait(500);

cy.get('.miller__col__item').contains(testProducts[productIndex].name).click().wait(500);
cy.get('.miller__col__item')
.contains(testProducts[productIndex].name)
.click()
.wait(500);

cy.get('[data-cy="delete_product_button"]').click().wait(100);

cy.get('.toggle').click().wait(500);

cy.get('.miller__col__item').contains(testDepartment.name).click().wait(750);

cy.get('.miller__col__item').contains(testProducts[productIndex].name).click().wait(750);
cy.get('.miller__col__item')
.contains(testProducts[productIndex].name)
.click()
.wait(750);

cy.get('[data-cy="permanently-delete-object"]').click();
});
Loading