From 59977dfa8240ac83d8338792b62065526e4fe6c9 Mon Sep 17 00:00:00 2001 From: Antoine Jaussoin Date: Sun, 26 Feb 2023 09:24:52 +0000 Subject: [PATCH] Fixing e2e and login screen (#481) --- .github/workflows/alpha.yml | 2 +- frontend/src/App.tsx | 27 +++++++------- frontend/src/global/GlobalProvider.tsx | 20 ----------- frontend/src/global/state.ts | 45 ++++++++++++++---------- frontend/src/views/Welcome.tsx | 3 ++ integration/cypress.config.js | 2 +- integration/cypress/e2e/test.cy.js | 12 +++++++ integration/docker-compose.ci.alpha.yml | 2 +- integration/docker-compose.ci.canary.yml | 2 +- integration/docker-compose.ci.master.yml | 2 +- 10 files changed, 59 insertions(+), 58 deletions(-) delete mode 100644 frontend/src/global/GlobalProvider.tsx diff --git a/.github/workflows/alpha.yml b/.github/workflows/alpha.yml index df3f4e4df..6d2ed56f5 100644 --- a/.github/workflows/alpha.yml +++ b/.github/workflows/alpha.yml @@ -2,7 +2,7 @@ name: 'Alpha Build' on: push: - branches: [v5000/twitter] + branches: [v5000/last-updates] jobs: frontend: diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 0dc313f91..066992cfd 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -13,7 +13,6 @@ import { RecoilRoot } from 'recoil'; import { Suspense } from 'react'; import { CodeSplitLoader } from './CodeSplitLoader'; import QuotaManager from './auth/QuotaManager'; -import GlobalProvider from './global/GlobalProvider'; import { ConfirmProvider } from 'material-ui-confirm'; function App() { @@ -39,20 +38,18 @@ function App() { - - - - - - - }> - - - - - - - + + + + + + }> + + + + + + diff --git a/frontend/src/global/GlobalProvider.tsx b/frontend/src/global/GlobalProvider.tsx deleted file mode 100644 index 2626446c9..000000000 --- a/frontend/src/global/GlobalProvider.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { PropsWithChildren, useEffect } from 'react'; -import { fetchBackendCapabilities } from '../api'; -import { useSetRecoilState } from 'recoil'; -import { backendCapabilitiesState } from './state'; - -export default function GlobalProvider({ children }: PropsWithChildren<{}>) { - const setBackendCapabilities = useSetRecoilState(backendCapabilitiesState); - - useEffect(() => { - async function loadGlobal() { - const infos = await fetchBackendCapabilities(); - if (infos) { - setBackendCapabilities(infos); - } - } - loadGlobal(); - }, [setBackendCapabilities]); - - return <>{children}; -} diff --git a/frontend/src/global/state.ts b/frontend/src/global/state.ts index 372f559ff..5dd46765b 100644 --- a/frontend/src/global/state.ts +++ b/frontend/src/global/state.ts @@ -1,23 +1,32 @@ -import { atom } from 'recoil'; +import { selector } from 'recoil'; import { BackendCapabilities } from 'common'; +import { fetchBackendCapabilities } from 'api'; -export const backendCapabilitiesState = atom({ +export const backendCapabilitiesState = selector({ key: 'BACKEND_CAPABILITIES', - default: { - adminEmail: '', - licenced: true, - selfHosted: false, - disableAnonymous: false, - disablePasswords: false, - disablePasswordRegistration: false, - oAuth: { - google: false, - github: false, - twitter: false, - microsoft: false, - slack: false, - okta: false, - }, - emailAvailable: false, + get: async () => { + const data = await fetchBackendCapabilities(); + + if (data) { + return data; + } + + return { + adminEmail: '', + licenced: true, + selfHosted: false, + disableAnonymous: false, + disablePasswords: false, + disablePasswordRegistration: false, + oAuth: { + google: false, + github: false, + twitter: false, + microsoft: false, + slack: false, + okta: false, + }, + emailAvailable: false, + }; }, }); diff --git a/frontend/src/views/Welcome.tsx b/frontend/src/views/Welcome.tsx index 1b3c04e7d..78d78bc06 100644 --- a/frontend/src/views/Welcome.tsx +++ b/frontend/src/views/Welcome.tsx @@ -22,6 +22,9 @@ const Container = styled.div` `; const Title = styled.h1` + margin-left: 40px; + margin-right: 40px; + text-align: center; font-weight: 100; font-size: 4em; @media screen and (max-width: 700px) { diff --git a/integration/cypress.config.js b/integration/cypress.config.js index fa4ef2f1e..916e52efc 100644 --- a/integration/cypress.config.js +++ b/integration/cypress.config.js @@ -2,7 +2,7 @@ const { defineConfig } = require('cypress') module.exports = defineConfig({ env: { - backend_delay: 0, + backend_delay: 2000, }, e2e: { // We've imported your old cypress plugins here. diff --git a/integration/cypress/e2e/test.cy.js b/integration/cypress/e2e/test.cy.js index eea4cf64c..908be29db 100644 --- a/integration/cypress/e2e/test.cy.js +++ b/integration/cypress/e2e/test.cy.js @@ -1,6 +1,8 @@ describe('Home Page', () => { it('Should load correctly', () => { cy.visit('/'); + + cy.wait(+Cypress.env('backend_delay')); cy.get('#content').get('h1').should('contain', 'Welcome!'); }); @@ -39,6 +41,8 @@ describe('Post workflow', () => { // Reload the page cy.reload(); + cy.wait(+Cypress.env('backend_delay')); + // The post should still be there cy.get('#content').should('contain', 'Slava Ukraini!'); }); @@ -46,6 +50,8 @@ describe('Post workflow', () => { it('Should change language and translate the app', () => { cy.visit('/'); + cy.wait(+Cypress.env('backend_delay')); + // Close cookie banner cy.get('.wpcc-btn').click(); @@ -79,6 +85,8 @@ describe('Post workflow', () => { cy.visit('/'); + cy.wait(+Cypress.env('backend_delay')); + // Close cookie banner cy.get('.wpcc-btn').click(); @@ -119,6 +127,8 @@ describe('Post workflow', () => { cy.visit('/'); + cy.wait(+Cypress.env('backend_delay')); + // Close cookie banner cy.get('.wpcc-btn').click(); @@ -136,6 +146,8 @@ describe('Post workflow', () => { // Register get('register-button').click(); + cy.wait(+Cypress.env('backend_delay')); + // Go to the user admin and delete the account get('account-menu').click(); get('account-menu-account').click(); diff --git a/integration/docker-compose.ci.alpha.yml b/integration/docker-compose.ci.alpha.yml index 95c16e1ea..505aea970 100644 --- a/integration/docker-compose.ci.alpha.yml +++ b/integration/docker-compose.ci.alpha.yml @@ -7,7 +7,7 @@ services: - frontend environment: - CYPRESS_baseUrl=http://frontend - - CYPRESS_backend_delay=30000 + - CYPRESS_backend_delay=10000 working_dir: /e2e volumes: - ./:/e2e diff --git a/integration/docker-compose.ci.canary.yml b/integration/docker-compose.ci.canary.yml index 7761dffaa..9779a08a2 100644 --- a/integration/docker-compose.ci.canary.yml +++ b/integration/docker-compose.ci.canary.yml @@ -7,7 +7,7 @@ services: - frontend environment: - CYPRESS_baseUrl=http://frontend - - CYPRESS_backend_delay=30000 + - CYPRESS_backend_delay=10000 working_dir: /e2e volumes: - ./:/e2e diff --git a/integration/docker-compose.ci.master.yml b/integration/docker-compose.ci.master.yml index 702672923..893e8b8fb 100644 --- a/integration/docker-compose.ci.master.yml +++ b/integration/docker-compose.ci.master.yml @@ -7,7 +7,7 @@ services: - frontend environment: - CYPRESS_baseUrl=http://frontend - - CYPRESS_backend_delay=30000 + - CYPRESS_backend_delay=10000 working_dir: /e2e volumes: - ./:/e2e