Skip to content

Commit

Permalink
[EN-4026) chore(forms): implement react hook forms (#140)
Browse files Browse the repository at this point in the history
* [EN-5923] chore(inputs): WIP remove old inputs

* [EN-5923] chore(inputs): removed all old inputs and modified last old creatable select

* [EN-4026] chore(inputs): added react hook forms and started implementing

* [EN-4026] chore(inputs): theoretically finished implements react-hook-form 😇

* [EN-4026] chore(inputs): started watch

* [EN-4026] chore(inputs): typed form schema

* [EN-4026] chore(inputs): put some styles in common

* [EN-4026] chore(inputs): fixed async radio and styles

* [EN-4026] chore(inputs): modified rules and rule manager. Typing

* [EN-4026] chore(inputs): try typing

* [EN-4026] chore(inputs): try typing

* [EN-4026] chore(inputs): came back to first solution

* [EN-4026] chore(inputs): finished mostly all the errors

* [EN-4026] chore(inputs): start testing

* wip

* [EN-4026] chore(inputs): continue testing

* [EN-4026] chore(inputs): continue testing

* [EN-4026] chore(inputs): continue testing

* [EN-4026] chore(inputs): continue testing

* [EN-4026] chore(inputs): continue testing

* [EN-4026] chore(inputs): fixed jest tests and fixed error messages if they are too long

* [EN-4026] chore(inputs): finished tests

* [EN-4026] chore(inputs): finished typing 🚀

* [EN-4026] chore(inputs): updated FooterForm 🚀

* [EN-4026] tests(inputs): fix

* [EN-4026] tests(navigation): added test for main page navigation

* fix(donation link): change donation link

* fix(members): fix call with undefined role in members as admin

* [EN-4026] chore(navigation): pass components using forms in typescript

* pr feedback
  • Loading branch information
emile-bex authored Aug 23, 2023
1 parent ec14579 commit 06d2fb1
Show file tree
Hide file tree
Showing 243 changed files with 8,193 additions and 10,025 deletions.
3 changes: 2 additions & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = defineConfig({
projectId: process.env.CYPRESS_IO_PROJECT_ID,
defaultCommandTimeout: 10000,
pageLoadTimeout: 120000,
scrollBehavior: "center",
env: {
adresseLocauxParis: `${process.env.ADRESSE_LOCAUX_PARIS}`,
},
Expand All @@ -15,5 +16,5 @@ module.exports = defineConfig({
// implement node event listeners here
},
},
retries: 5,
retries: 3,
});
55 changes: 39 additions & 16 deletions cypress/e2e/admin.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,15 @@ describe('Admin', () => {
{
fixture: 'user-admin-candidates-search-res',
}
).as('getExternalCandidates');
).as('getExternalCandidatesJane');

cy.intercept(
'GET',
`/user/search?query=Emile&role=Candidat+externe&organizationId=${entourageOrganizationId}`,
{
fixture: 'user-admin-candidates-search-res',
}
).as('getExternalCandidatesEmile');

cy.intercept('GET', '/organization?limit=50&offset=0&zone[]=LYON', {
fixture: 'organization-search-res',
Expand Down Expand Up @@ -180,7 +188,7 @@ describe('Admin', () => {
.should('be.visible')
.scrollIntoView()
.click()
.find('button')
.find('.option')
.contains('Paris')
.click();

Expand Down Expand Up @@ -213,7 +221,7 @@ describe('Admin', () => {
.should('be.visible')
.scrollIntoView()
.click()
.find('button')
.find('.option')
.contains('Admin')
.click();

Expand All @@ -227,7 +235,7 @@ describe('Admin', () => {
.should('be.visible')
.scrollIntoView()
.click()
.find('button')
.find('.option')
.contains('Candidats')
.click();
});
Expand All @@ -237,7 +245,7 @@ describe('Admin', () => {
.should('be.visible')
.scrollIntoView()
.click()
.find('button')
.find('.option')
.contains('Candidat LKO')
.click();

Expand Down Expand Up @@ -268,7 +276,7 @@ describe('Admin', () => {
.should('be.visible')
.scrollIntoView()
.click()
.find('button')
.find('.option')
.contains('Coach LKO')
.click();

Expand Down Expand Up @@ -299,7 +307,7 @@ describe('Admin', () => {
.should('be.visible')
.scrollIntoView()
.click()
.find('button')
.find('.option')
.contains('Candidat externe')
.click();

Expand Down Expand Up @@ -345,7 +353,7 @@ describe('Admin', () => {
.should('be.visible')
.scrollIntoView()
.click()
.find('button')
.find('.option')
.contains('Coach externe')
.click();

Expand Down Expand Up @@ -373,7 +381,7 @@ describe('Admin', () => {
.scrollIntoView()
.type('Jane');

cy.wait('@getExternalCandidates');
cy.wait('@getExternalCandidatesJane');

cy.get('#form-add-user-userToLinkId')
.find('.Select__menu')
Expand All @@ -382,6 +390,21 @@ describe('Admin', () => {
.find('.Select__option')
.contains('Jane Doe')
.click();

cy.get('#form-add-user-userToLinkId')
.should('be.visible')
.scrollIntoView()
.type('Emile');

cy.wait('@getExternalCandidatesEmile');

cy.get('#form-add-user-userToLinkId')
.find('.Select__menu')
.should('be.visible')
.scrollIntoView()
.find('.Select__option')
.contains('Emile Sf Bex')
.click();
});
});

Expand Down Expand Up @@ -424,7 +447,7 @@ describe('Admin', () => {
.should('be.visible')
.scrollIntoView()
.click()
.find('button')
.find('.option')
.contains('Paris')
.click();

Expand Down Expand Up @@ -466,7 +489,7 @@ describe('Admin', () => {
.should('be.visible')
.scrollIntoView()
.click()
.find('button')
.find('.option')
.contains('Candidat externe')
.click();
});
Expand All @@ -476,7 +499,7 @@ describe('Admin', () => {
.should('be.visible')
.scrollIntoView()
.click()
.find('button')
.find('.option')
.contains('Coach externe')
.click();
});
Expand All @@ -493,10 +516,10 @@ describe('Admin', () => {
});
cy.wait('@organizationListPage');
// test if all organizations are in the table
cy.fixture('organization-search-res').then((organizations) => {
cy.fixture('organization-search-res').then((orgs) => {
cy.get('[data-testid="organization-list"]')
.find('tr')
.should('have.length', organizations.length);
.should('have.length', orgs.length);
});
});

Expand Down Expand Up @@ -529,7 +552,7 @@ describe('Admin', () => {
.should('be.visible')
.scrollIntoView()
.click()
.find('button')
.find('.option')
.contains('Paris')
.click();

Expand Down Expand Up @@ -590,7 +613,7 @@ describe('Admin', () => {
.should('be.visible')
.scrollIntoView()
.click()
.find('button')
.find('.option')
.contains('Lyon')
.click();

Expand Down
88 changes: 51 additions & 37 deletions cypress/e2e/candidat.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ describe('Candidat', () => {

cy.intercept('PUT', '/user/changePwd', {}).as('changePwd');
});

it('should open backoffice public offers', () => {
cy.visit('/backoffice/candidat/offres/public', {
onBeforeLoad: function async(window) {
Expand Down Expand Up @@ -130,31 +129,43 @@ describe('Candidat', () => {
);
});
cy.get('[data-testid="candidat-add-offer-main"]').click();
cy.get('#form-offer-external-title').scrollIntoView().type('test');
cy.get('#form-offer-external-company').scrollIntoView().type('test');
cy.get('#form-offer-external-department-container')
cy.get('#form-add-offer-external-title').scrollIntoView().type('test');
cy.get('#form-add-offer-external-company').scrollIntoView().type('test');

cy.get('#form-add-offer-external-department')
.should('be.visible')
.scrollIntoView()
.type('Par');

cy.get('#form-add-offer-external-department')
.find('.Select__menu')
.should('be.visible')
.scrollIntoView()
.find('.Select__option')
.contains('Paris (75)')
.click();
cy.get(
'#form-offer-external-department-container .options-container .option button'
)
.first()
.click();
cy.get('#form-offer-external-contract-container').scrollIntoView().click();
cy.get(
'#form-offer-external-contract-container .options-container .option button'
)
.first()

cy.get('#form-add-offer-external-contract-container')
.should('be.visible')
.scrollIntoView()
.click()
.find('.option')
.contains('CDI')
.click();
cy.get('#form-offer-external-recruiterFirstName')

cy.get('#form-add-offer-external-recruiterFirstName')
.scrollIntoView()
.type('test');
cy.get('#form-add-offer-external-recruiterName')
.scrollIntoView()
.type('test');
cy.get('#form-offer-external-recruiterName').scrollIntoView().type('test');
cy.get('#form-offer-external-recruiterMail')
cy.get('#form-add-offer-external-recruiterMail')
.scrollIntoView()
.type('[email protected]');
cy.get('#form-offer-external-description').scrollIntoView().type('test');
cy.get('#form-offer-external-link').scrollIntoView().type('test');
cy.get('#form-add-offer-external-description')
.scrollIntoView()
.type('test');
cy.get('#form-add-offer-external-link').scrollIntoView().type('test');
cy.get('button').contains('Envoyer').click();
cy.wait('@postExternal');

Expand All @@ -169,10 +180,10 @@ describe('Candidat', () => {
window.localStorage.setItem('release-version', 'v100');
},
});
cy.get(`[data-testid="test-catchphrase-edit-icon"]`).click({ force: true });
cy.get(`[data-testid="test-catchphrase-edit-icon"]`).click();
const catchPhrase = 'hello my name is Mike';
cy.get('#form-catchphrase-catchphrase').type(catchPhrase);
cy.get(`[data-testid="form-confirm-catchphrase-form"]`).click();
cy.get(`[data-testid="form-confirm-form-catchphrase"]`).click();
cy.get(`[data-testid="cv-edit-catchphrase-content"]`).should(
'contain',
catchPhrase
Expand All @@ -189,33 +200,36 @@ describe('Candidat', () => {
});

// toggle hide CV
cy.get(`[data-testid="test-toggle-hidden"]`).click({ force: true });
cy.get('label[for="ent-toggle-hidden"]').click();
cy.get(`[data-testid="test-confirm-hidden"]`).click();
cy.wait('@putCandidatParams');
cy.get(`[data-testid="test-toggle-hidden"]`).should('be.checked');
cy.get(`[data-testid="test-toggle-hidden"]`)
.click({ force: true })
.should('not.be.checked');
cy.get('label[for="ent-toggle-hidden"]').click();
cy.get(`[data-testid="test-toggle-hidden"]`).should('not.be.checked');

// toggle is employed
cy.get(`[data-testid="test-toggle-employedToggle"]`).click({ force: true });
cy.get('#form-edit-employed-contract').select('alt');
cy.get('label[for="ent-toggle-employedToggle"]').click();

cy.get('#form-edit-employed-contract-container')
.should('be.visible')
.scrollIntoView()
.click()
.find('.option')
.contains('Alternance')
.click();
cy.get('#form-edit-employed-endOfContract').type('2024-03-03');
cy.contains('Valider').click();
cy.wait('@putCandidatParams');
cy.get(`[data-testid="test-toggle-employedToggle"]`).should('be.checked');
cy.get(`[data-testid="test-toggle-employedToggle"]`)
.click({ force: true })
.should('not.be.checked');
cy.get('label[for="ent-toggle-employedToggle"]').click();
cy.get(`[data-testid="test-toggle-employedToggle"]`).should(
'not.be.checked'
);

// change password
cy.get('#form-change-pwd-oldPassword').type('blablabla', { force: true });
cy.get('#form-change-pwd-newPassword').type('Linkedout123!', {
force: true,
});
cy.get('#form-change-pwd-confirmPassword').type('Linkedout123!', {
force: true,
});
cy.get('#form-change-pwd-oldPassword').type('blablabla');
cy.get('#form-change-pwd-newPassword').type('Linkedout123!');
cy.get('#form-change-pwd-confirmPassword').type('Linkedout123!');
cy.contains('Modifier').click();
cy.wait('@changePwd');
});
Expand Down
40 changes: 40 additions & 0 deletions cypress/e2e/nav.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* eslint-disable no-undef */
// unstable test, need to identify the issue

describe('Navigation', () => {
it('opens', () => {
cy.visit('/');
cy.wait(1000);

// cy.visit(Cypress.env('base_url'))
cy.get('header').within(() => {
cy.get('a').contains('Je cherche un emploi').click({ force: true });
cy.wait(1000);
cy.url().should('include', 'travailler');
});

cy.get('header').within(() => {
cy.get('a').contains('Je recrute').click({ force: true });
cy.wait(1000);
cy.url().should('include', 'entreprises');
});

cy.get('header').within(() => {
cy.get('a').contains('Je veux aider').click({ force: true });
cy.wait(1000);
cy.url().should('include', 'aider');
});

cy.get('header').within(() => {
cy.get('a').contains("J'oriente un candidat").click({ force: true });
cy.wait(1000);
cy.url().should('include', 'orienter');
});

cy.get('header').within(() => {
cy.get('button').contains('Découvrir les CV').click({ force: true });
cy.wait(1000);
cy.url().should('include', 'candidats');
});
});
});
29 changes: 0 additions & 29 deletions cypress/e2e/nav.old.js

This file was deleted.

Loading

0 comments on commit 06d2fb1

Please sign in to comment.