diff --git a/server-ce/test/Makefile b/server-ce/test/Makefile index 9e8056e273..a7dca862e4 100644 --- a/server-ce/test/Makefile +++ b/server-ce/test/Makefile @@ -14,7 +14,10 @@ export COMPOSE_PROJECT_NAME ?= test test-e2e-native: docker compose -f docker-compose.yml -f docker-compose.native.yml up --no-log-prefix sharelatex host-admin -d - CYPRESS_ADMIN_CLIENT_URL='http://localhost:8081' CYPRESS_GIT_BRIDGE_PUBLIC_HOST='localhost' CYPRESS_SAML_PUBLIC_HOST='localhost:8082' CYPRESS_OVERLEAF_PUBLIC_HOST='localhost:8082' npm run cypress:open + CYPRESS_HOST_ADMIN_URL='http://localhost:8081' \ + CYPRESS_SAML_URL='http://localhost:8082' \ + CYPRESS_MAILTRAP_URL='http://localhost:8083' \ + npm run cypress:open test-e2e: docker compose up --no-log-prefix --exit-code-from=e2e e2e diff --git a/server-ce/test/docker-compose.native.yml b/server-ce/test/docker-compose.native.yml index 1830ff7e87..c229f6a546 100644 --- a/server-ce/test/docker-compose.native.yml +++ b/server-ce/test/docker-compose.native.yml @@ -19,3 +19,7 @@ services: environment: SAML_BASE_URL_PATH: 'http://localhost:8082/simplesaml/' SAML_TEST_SP_LOCATION: 'http://localhost/saml/callback' + + mailtrap: + ports: + - 127.0.0.1:8083:80 diff --git a/server-ce/test/external-auth.spec.ts b/server-ce/test/external-auth.spec.ts index b05c7f1df0..7e71ab9777 100644 --- a/server-ce/test/external-auth.spec.ts +++ b/server-ce/test/external-auth.spec.ts @@ -3,15 +3,14 @@ import { createProject } from './helpers/project' describe('SAML', () => { if (isExcludedBySharding('PRO_CUSTOM_1')) return - const overleafPublicHost = Cypress.env('OVERLEAF_PUBLIC_HOST') || 'sharelatex' - const samlPublicHost = Cypress.env('SAML_PUBLIC_HOST') || 'saml' + const samlURL = Cypress.env('SAML_URL') || 'http://saml' startWith({ pro: true, vars: { EXTERNAL_AUTH: 'saml', - OVERLEAF_SAML_ENTRYPOINT: `http://${samlPublicHost}/simplesaml/saml2/idp/SSOService.php`, - OVERLEAF_SAML_CALLBACK_URL: `http://${overleafPublicHost}/saml/callback`, + OVERLEAF_SAML_ENTRYPOINT: `${samlURL}/simplesaml/saml2/idp/SSOService.php`, + OVERLEAF_SAML_CALLBACK_URL: `${Cypress.config().baseUrl}/saml/callback`, OVERLEAF_SAML_ISSUER: 'sharelatex-test-saml', OVERLEAF_SAML_IDENTITY_SERVICE_NAME: 'SAML Test Server', OVERLEAF_SAML_EMAIL_FIELD: 'email', @@ -27,7 +26,7 @@ describe('SAML', () => { cy.visit('/') cy.findByText('Log in with SAML Test Server').click() - cy.origin(`http://${samlPublicHost}`, () => { + cy.origin(samlURL, () => { cy.get('input[name="username"]').type('sally') cy.get('input[name="password"]').type('sally123') cy.get('button[type="submit"]').click() diff --git a/server-ce/test/git-bridge.spec.ts b/server-ce/test/git-bridge.spec.ts index 1c6bff4a42..ee2aff41ed 100644 --- a/server-ce/test/git-bridge.spec.ts +++ b/server-ce/test/git-bridge.spec.ts @@ -20,8 +20,7 @@ describe('git-bridge', function () { V1_HISTORY_URL: 'http://sharelatex:3100/api', } - const gitBridgePublicHost = - Cypress.env('GIT_BRIDGE_PUBLIC_HOST') || 'sharelatex' + const gitBridgePublicHost = new URL(Cypress.config().baseUrl!).host describe('enabled in Server Pro', function () { if (isExcludedBySharding('PRO_CUSTOM_1')) return diff --git a/server-ce/test/helpers/email.ts b/server-ce/test/helpers/email.ts index 5ffc9bc7c1..036f746f65 100644 --- a/server-ce/test/helpers/email.ts +++ b/server-ce/test/helpers/email.ts @@ -12,16 +12,19 @@ export function openEmail( ) { const runnerS = runner.toString() cy.origin( - 'http://mailtrap', + Cypress.env('MAILTRAP_URL') || 'http://mailtrap', { args: { args, runnerS, subject } }, ({ args, runnerS, subject }) => { cy.visit('/') cy.get('input[name="_user"]').type('mailtrap') cy.get('input[name="_pass"]').type('password-for-mailtrap') cy.get('button[type="submit"]').click() - cy.log('mailtrap login is flaky in cypress, submit again') - cy.get('input[name="_pass"]').type('password-for-mailtrap') - cy.get('button[type="submit"]').click() + cy.url().then(url => { + if (!url.includes('?_task=login')) return + cy.log('mailtrap login is flaky in cypress, submit again') + cy.get('input[name="_pass"]').type('password-for-mailtrap') + cy.get('button[type="submit"]').click() + }) // Use force as the subject is partially hidden cy.contains(subject).click({ force: true }) cy.log('wait for iframe loading') diff --git a/server-ce/test/helpers/hostAdminClient.ts b/server-ce/test/helpers/hostAdminClient.ts index 1246d5a1e3..cafeaa2db6 100644 --- a/server-ce/test/helpers/hostAdminClient.ts +++ b/server-ce/test/helpers/hostAdminClient.ts @@ -1,7 +1,7 @@ -const hostAdminUrl = Cypress.env('ADMIN_CLIENT_URL') || 'http://host-admin' +const hostAdminURL = Cypress.env('HOST_ADMIN_URL') || 'http://host-admin' export async function dockerCompose(cmd: string, ...args: string[]) { - return await fetchJSON(`${hostAdminUrl}/docker/compose/${cmd}`, { + return await fetchJSON(`${hostAdminURL}/docker/compose/${cmd}`, { method: 'POST', body: JSON.stringify({ args, @@ -16,7 +16,7 @@ export async function reconfigure({ withDataDir = false, resetData = false, }): Promise<{ previousConfigServer: string }> { - return await fetchJSON(`${hostAdminUrl}/reconfigure`, { + return await fetchJSON(`${hostAdminURL}/reconfigure`, { method: 'POST', body: JSON.stringify({ pro, @@ -68,7 +68,7 @@ export async function runScript({ script: string args?: string[] }) { - return await fetchJSON(`${hostAdminUrl}/run/script`, { + return await fetchJSON(`${hostAdminURL}/run/script`, { method: 'POST', body: JSON.stringify({ cwd, @@ -79,7 +79,7 @@ export async function runScript({ } export async function getRedisKeys() { - const { stdout } = await fetchJSON(`${hostAdminUrl}/redis/keys`, { + const { stdout } = await fetchJSON(`${hostAdminURL}/redis/keys`, { method: 'GET', }) return stdout.split('\n')