Skip to content

feat: updating github action test to launch elk #236

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

Open
wants to merge 6 commits into
base: feat/clevercloud
Choose a base branch
from
Open
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
36 changes: 28 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ jobs:
ports:
- 8025:8025
- 1025:1025
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.12.1
env:
ELASTIC_PASSWORD: ${{ secrets.ES_ADDON_PASSWORD }}
ports:
- 9200:9200
options: >-
--health-cmd="curl -s --insecure https://localhost:9200/_cluster/health || exit 1"
--health-interval=30s
--health-timeout=10s
--health-retries=5

steps:
# 1. Checkout du code
Expand All @@ -46,36 +57,42 @@ jobs:
webapp-backoffice/yarn.lock
webapp-form/yarn.lock

# 4. Installer les dépendances et générer le client Prisma pour `webapp-backoffice`
#4 Configurer l'environnement ElasticSearch
- name: Configure Elasticsearch environment
run: |
echo "ES_ADDON_URI=${{ secrets.ES_ADDON_URI }}" >> webapp-backoffice/.env
echo "ES_ADDON_USER=${{ secrets.ES_ADDON_USER }}" >> webapp-backoffice/.env
echo "ES_ADDON_PASSWORD=${{ secrets.ES_ADDON_PASSWORD }}" >> webapp-backoffice/.env
# 5. Installer les dépendances et générer le client Prisma pour `webapp-backoffice`
- name: Install dependencies and generate Prisma client for webapp-backoffice
run: |
cd webapp-backoffice
yarn install
npx prisma generate
npx prisma migrate reset --force

# 5. Installer les dépendances et générer le client Prisma pour `webapp-form`
# 6. Installer les dépendances et générer le client Prisma pour `webapp-form`
- name: Install dependencies and generate Prisma client for webapp-form
run: |
cd webapp-form
yarn install
npx prisma generate

# 6. Construire `webapp-backoffice`
# 7. Construire `webapp-backoffice`
- name: Build webapp-backoffice
run: |
cd webapp-backoffice
yarn build
nohup yarn start &

# 7. Construire `webapp-form`
# 8. Construire `webapp-form`
- name: Build webapp-form
run: |
cd webapp-form
yarn build
nohup yarn startB &

# 8. Attendre que les services soient prêts
# 9. Attendre que les services soient prêts
- name: Wait for services to be ready
run: |
echo "Waiting for webapp-backoffice to be ready..."
Expand All @@ -87,16 +104,19 @@ jobs:
echo "Waiting for MailHog to be ready..."
until curl -s http://localhost:8025 > /dev/null; do echo "Waiting for MailHog..."; sleep 5; done

# 9. Exécuter les tests Cypress pour `webapp-backoffice`
echo "Waiting for Elasticsearch to be ready..."
until curl -s --insecure https://localhost:9200/_cluster/health > /dev/null; do echo "Waiting for Elasticsearch..."; sleep 5; done

# 10. Exécuter les tests Cypress pour `webapp-backoffice`
- name: Run Cypress tests for webapp-backoffice
working-directory: ./webapp-backoffice
run: npx cypress run --spec "cypress/e2e/jdma/launcher.cy.js" --headed --browser chrome

# 10. Vérifier si MailHog reçoit les emails
# 11. Vérifier si MailHog reçoit les emails
- name: Check MailHog for received emails
run: curl http://localhost:8025/api/v2/messages

# 11. Arrêter les applications démarrées
# 12. Arrêter les applications démarrées
- name: Stop applications
run: |
pkill -f "yarn start" || true
Expand Down
35 changes: 35 additions & 0 deletions docker-compose.tests.macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,40 @@ services:
timeout: 10s
networks:
- jdma-network
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.12.1
platform: linux/arm64
environment:
- discovery.type=single-node
- xpack.security.enabled=true
- ELASTIC_PASSWORD=ES_ADDON_PASSWORD
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ports:
- "9200:9200"
volumes:
- elasticsearch_data:/usr/share/elasticsearch/data
networks:
- jdma-network
healthcheck:
test: ["CMD-SHELL", "curl -s http://localhost:9200 >/dev/null || exit 1"]
interval: 10s
timeout: 10s
retries: 3

kibana:
image: docker.elastic.co/kibana/kibana:8.12.1
platform: linux/arm64
environment:
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
- ELASTICSEARCH_USERNAME=elastic
- ELASTICSEARCH_PASSWORD=ES_ADDON_PASSWORD
ports:
- "5601:5601"
depends_on:
elasticsearch:
condition: service_healthy
networks:
- jdma-network

db:
image: postgres:16-alpine
Expand Down Expand Up @@ -110,6 +144,7 @@ services:

volumes:
pg_data:
elasticsearch_data:

networks:
jdma-network:
Expand Down
6 changes: 4 additions & 2 deletions webapp-backoffice/cypress.env.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
"DB_PORT": 5432,
"DB_USER": "user",
"DB_PASSWORD": "password",
"DB_NAME": "jdma"
}
"DB_NAME": "jdma",
"admin_email": "[email protected]",
"admin_password": "jdma"
}
98 changes: 69 additions & 29 deletions webapp-backoffice/cypress/e2e/jdma/bo/reviewCheck.cy.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,80 @@
const app_url = Cypress.env('app_base_url');
const invitedEmail = Cypress.env('admin_guest_mail_bis');
const userPassword = Cypress.env('user_password');
const invitedEmail = Cypress.env('admin_user_mail');
const userPassword = Cypress.env('admin_user_password');
const productId = 5;

describe('jdma-answer-check', () => {
beforeEach(() => {
cy.visit(app_url);
loginAndNavigate();
});

it('should the test answer exist', () => {
cy.get('header')
.find('.fr-header__tools')
.contains('Connexion / Inscription')
.click();
cy.url().should('eq', app_url + '/login');
cy.wait(5000);

cy.get('input[name="email"]').type(invitedEmail);
cy.get('[class*="LoginForm-button"]')
.contains('Continuer')
.click()
.then(() => {
cy.wait(1000);
cy.get('input[type="password"]').type(userPassword);
});
cy.get('[class*="LoginForm-button"]')
.contains('Confirmer')
.click()
.then(() => {
cy.url().should('eq', app_url + '/administration/dashboard/products');
it('should find a review count start at 1 and get incremented by 1', () => {
cy.get('a[href*="/administration/dashboard/product/5/stats"]')
.find('div.fr-label--info.fr-text--bold')
.then($el => {
const text = $el.text();
const value = parseInt(text);
expect(value).to.be.equal(1);
});
cy.wait(8000);
cy.get('div.fr-label--info.fr-text--bold')
.invoke('text')
.then(text => {
cy.submitCompleteReview().then(() => {
cy.visit(`${app_url}/administration/dashboard/products`);
cy.wait(8000);
cy.get('a[href*="/administration/dashboard/product/5/stats"]')
.find('div.fr-label--info.fr-text--bold')
.then($el => {
const text = $el.text();
const value = parseInt(text);
expect(value).to.be.equal(2);
});
});
});

it('should navigate to the product stats page and verify the review count matching the review count in the dashboard page', () => {
cy.visit(`${app_url}/administration/dashboard/product/5/stats`);
cy.get('div.fr-tile')
.find('h3.fr-tile__title')
.contains('Avis')
.siblings('p')
.then($el => {
const text = $el.text();
const value = parseInt(text);
expect(value).to.not.equal(0);
expect(value).to.be.equal(2);
});
});

it('should navigate to the review page and find the verbatim in the created review', () => {
cy.visit(`${app_url}/administration/dashboard/product/5/reviews`);
cy.get('.fr-btn').contains("Plus d'infos").click();
cy.get('h2')
.contains('Souhaitez-vous nous en dire plus ?')
.next('p')
.should('contain', 'e2e test content');
});
});

function loginAndNavigate() {
cy.visit(app_url);
cy.get('header')
.find('.fr-header__tools')
.contains('Connexion / Inscription')
.click();
cy.url()
.should('eq', app_url + '/login')
.then(() => {
cy.get('input[name="email"]').type(invitedEmail);
cy.get('[class*="LoginForm-button"]')
.contains('Continuer')
.click()
.then(() => {
cy.wait(1000);
cy.get('input[type="password"]').type(userPassword);
});
cy.get('[class*="LoginForm-button"]')
.contains('Confirmer')
.click()
.then(() => {
cy.url().should('eq', app_url + '/administration/dashboard/products');
});
cy.wait(8000);
});
}
32 changes: 17 additions & 15 deletions webapp-backoffice/cypress/e2e/jdma/form/review.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,36 @@ function fillFormStep3() {
.eq(0)
.find('input[type="radio"]')
.eq(0)
.check({ force: true });
.check({ force: true });
cy.get('fieldset')
.eq(1)
.find('input[type="radio"]')
.eq(0)
.check({ force: true });
.check({ force: true });
cy.get('fieldset')
.eq(2)
.find('input[type="radio"]')
.eq(1)
.check({ force: true });
.check({ force: true });
});
}

function fillFormStep4() {
cy.get("[class*='mainTable']").should('be.visible').within(() => {
cy.contains('label', 'Au guichet')
.parents('tr')
.within(() => {
cy.get('input[type="radio"]').eq(4).check({ force: true });
});
cy.get("[class*='mainTable']")
.should('be.visible')
.within(() => {
cy.contains('label', 'Au guichet')
.parents('tr')
.within(() => {
cy.get('input[type="radio"]').eq(4).check({ force: true });
});

cy.contains('label', 'Par téléphone')
.parents('tr')
.within(() => {
cy.get('input[type="radio"]').eq(3).check({ force: true });
});
});
cy.contains('label', 'Par téléphone')
.parents('tr')
.within(() => {
cy.get('input[type="radio"]').eq(3).check({ force: true });
});
});

cy.get('button').contains('Continuer').click();
cy.get('h1').contains('Informations complémentaires').should('exist');
Expand Down
2 changes: 1 addition & 1 deletion webapp-backoffice/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
// }
Loading
Loading