Merge pull request #20117 from overleaf/jpa-server-pro-test-local

[server-pro] tests: add support for running email tests on Macs

GitOrigin-RevId: 19a206f4ee70d43624094dd8da87091063d631a0
This commit is contained in:
Jakob Ackermann 2024-08-30 14:02:23 +02:00 committed by Copybot
parent 16eb99ee48
commit 3c5bd060f4
6 changed files with 25 additions and 17 deletions

View file

@ -14,7 +14,10 @@ export COMPOSE_PROJECT_NAME ?= test
test-e2e-native: test-e2e-native:
docker compose -f docker-compose.yml -f docker-compose.native.yml up --no-log-prefix sharelatex host-admin -d 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: test-e2e:
docker compose up --no-log-prefix --exit-code-from=e2e e2e docker compose up --no-log-prefix --exit-code-from=e2e e2e

View file

@ -19,3 +19,7 @@ services:
environment: environment:
SAML_BASE_URL_PATH: 'http://localhost:8082/simplesaml/' SAML_BASE_URL_PATH: 'http://localhost:8082/simplesaml/'
SAML_TEST_SP_LOCATION: 'http://localhost/saml/callback' SAML_TEST_SP_LOCATION: 'http://localhost/saml/callback'
mailtrap:
ports:
- 127.0.0.1:8083:80

View file

@ -3,15 +3,14 @@ import { createProject } from './helpers/project'
describe('SAML', () => { describe('SAML', () => {
if (isExcludedBySharding('PRO_CUSTOM_1')) return if (isExcludedBySharding('PRO_CUSTOM_1')) return
const overleafPublicHost = Cypress.env('OVERLEAF_PUBLIC_HOST') || 'sharelatex' const samlURL = Cypress.env('SAML_URL') || 'http://saml'
const samlPublicHost = Cypress.env('SAML_PUBLIC_HOST') || 'saml'
startWith({ startWith({
pro: true, pro: true,
vars: { vars: {
EXTERNAL_AUTH: 'saml', EXTERNAL_AUTH: 'saml',
OVERLEAF_SAML_ENTRYPOINT: `http://${samlPublicHost}/simplesaml/saml2/idp/SSOService.php`, OVERLEAF_SAML_ENTRYPOINT: `${samlURL}/simplesaml/saml2/idp/SSOService.php`,
OVERLEAF_SAML_CALLBACK_URL: `http://${overleafPublicHost}/saml/callback`, OVERLEAF_SAML_CALLBACK_URL: `${Cypress.config().baseUrl}/saml/callback`,
OVERLEAF_SAML_ISSUER: 'sharelatex-test-saml', OVERLEAF_SAML_ISSUER: 'sharelatex-test-saml',
OVERLEAF_SAML_IDENTITY_SERVICE_NAME: 'SAML Test Server', OVERLEAF_SAML_IDENTITY_SERVICE_NAME: 'SAML Test Server',
OVERLEAF_SAML_EMAIL_FIELD: 'email', OVERLEAF_SAML_EMAIL_FIELD: 'email',
@ -27,7 +26,7 @@ describe('SAML', () => {
cy.visit('/') cy.visit('/')
cy.findByText('Log in with SAML Test Server').click() 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="username"]').type('sally')
cy.get('input[name="password"]').type('sally123') cy.get('input[name="password"]').type('sally123')
cy.get('button[type="submit"]').click() cy.get('button[type="submit"]').click()

View file

@ -20,8 +20,7 @@ describe('git-bridge', function () {
V1_HISTORY_URL: 'http://sharelatex:3100/api', V1_HISTORY_URL: 'http://sharelatex:3100/api',
} }
const gitBridgePublicHost = const gitBridgePublicHost = new URL(Cypress.config().baseUrl!).host
Cypress.env('GIT_BRIDGE_PUBLIC_HOST') || 'sharelatex'
describe('enabled in Server Pro', function () { describe('enabled in Server Pro', function () {
if (isExcludedBySharding('PRO_CUSTOM_1')) return if (isExcludedBySharding('PRO_CUSTOM_1')) return

View file

@ -12,16 +12,19 @@ export function openEmail<T>(
) { ) {
const runnerS = runner.toString() const runnerS = runner.toString()
cy.origin( cy.origin(
'http://mailtrap', Cypress.env('MAILTRAP_URL') || 'http://mailtrap',
{ args: { args, runnerS, subject } }, { args: { args, runnerS, subject } },
({ args, runnerS, subject }) => { ({ args, runnerS, subject }) => {
cy.visit('/') cy.visit('/')
cy.get('input[name="_user"]').type('mailtrap') cy.get('input[name="_user"]').type('mailtrap')
cy.get('input[name="_pass"]').type('password-for-mailtrap') cy.get('input[name="_pass"]').type('password-for-mailtrap')
cy.get('button[type="submit"]').click() cy.get('button[type="submit"]').click()
cy.log('mailtrap login is flaky in cypress, submit again') cy.url().then(url => {
cy.get('input[name="_pass"]').type('password-for-mailtrap') if (!url.includes('?_task=login')) return
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()
})
// Use force as the subject is partially hidden // Use force as the subject is partially hidden
cy.contains(subject).click({ force: true }) cy.contains(subject).click({ force: true })
cy.log('wait for iframe loading') cy.log('wait for iframe loading')

View file

@ -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[]) { export async function dockerCompose(cmd: string, ...args: string[]) {
return await fetchJSON(`${hostAdminUrl}/docker/compose/${cmd}`, { return await fetchJSON(`${hostAdminURL}/docker/compose/${cmd}`, {
method: 'POST', method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
args, args,
@ -16,7 +16,7 @@ export async function reconfigure({
withDataDir = false, withDataDir = false,
resetData = false, resetData = false,
}): Promise<{ previousConfigServer: string }> { }): Promise<{ previousConfigServer: string }> {
return await fetchJSON(`${hostAdminUrl}/reconfigure`, { return await fetchJSON(`${hostAdminURL}/reconfigure`, {
method: 'POST', method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
pro, pro,
@ -68,7 +68,7 @@ export async function runScript({
script: string script: string
args?: string[] args?: string[]
}) { }) {
return await fetchJSON(`${hostAdminUrl}/run/script`, { return await fetchJSON(`${hostAdminURL}/run/script`, {
method: 'POST', method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
cwd, cwd,
@ -79,7 +79,7 @@ export async function runScript({
} }
export async function getRedisKeys() { export async function getRedisKeys() {
const { stdout } = await fetchJSON(`${hostAdminUrl}/redis/keys`, { const { stdout } = await fetchJSON(`${hostAdminURL}/redis/keys`, {
method: 'GET', method: 'GET',
}) })
return stdout.split('\n') return stdout.split('\n')