Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e0c852b
ILEX-119 tests set up
SimaoBolota-MetaCell May 15, 2025
c0e9d9c
ILEX-119 search test
SimaoBolota-MetaCell May 20, 2025
fef9afd
ILEX-119 userInfo test added
SimaoBolota-MetaCell May 22, 2025
eea3bcd
ILEX-119 org test + pipeline attempt
SimaoBolota-MetaCell May 22, 2025
df2bf15
ILEX-119 add tests to pipeline
SimaoBolota-MetaCell May 23, 2025
39d4666
ILEX-119 add tests to pipeline
SimaoBolota-MetaCell May 23, 2025
6948e19
ILEX-119 add tests to pipeline
SimaoBolota-MetaCell May 23, 2025
dcfa05a
ILEX-119 add tests to pipeline
SimaoBolota-MetaCell May 23, 2025
aa2c62e
ILEX-119 add tests to pipeline
SimaoBolota-MetaCell May 23, 2025
ed066cf
Merge remote-tracking branch 'origin/devel' into test/ILEX-119
SimaoBolota-MetaCell May 23, 2025
688ca18
ILEX-119 pull latest + dockerfile change
SimaoBolota-MetaCell May 23, 2025
b732fd2
Merge remote-tracking branch 'origin/devel' into test/ILEX-119
SimaoBolota-MetaCell May 23, 2025
a456181
ILEX-119 yaml update
SimaoBolota-MetaCell May 23, 2025
8d23f11
ILEX-119
SimaoBolota-MetaCell May 23, 2025
81fde44
ILEX-119 different approach
SimaoBolota-MetaCell May 23, 2025
f689584
Adding package-lock.json
SimaoBolota-MetaCell May 29, 2025
8cf0019
fix docker
SimaoBolota-MetaCell May 29, 2025
f7a171c
debug info
SimaoBolota-MetaCell May 29, 2025
ddcd9be
debug info
SimaoBolota-MetaCell May 29, 2025
6018c12
debug info
SimaoBolota-MetaCell May 29, 2025
84c31c5
working directory fix
SimaoBolota-MetaCell May 29, 2025
d152e50
install errors
SimaoBolota-MetaCell May 29, 2025
4ea3e34
install errors
SimaoBolota-MetaCell May 29, 2025
e2cb440
lint issues
SimaoBolota-MetaCell May 29, 2025
6a6c29b
lint issues
SimaoBolota-MetaCell May 29, 2025
06a1f1b
lint issues
SimaoBolota-MetaCell May 29, 2025
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
6 changes: 6 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ module.exports = {
{ allowConstantExport: true },
],
},
overrides: [
{
files: ['test/**/*.js'],
env: { jest: true, node: true, commonjs: true },
},
],
}
33 changes: 33 additions & 0 deletions deploy/codefresh/codefresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ stages:
- "clone"
- "build"
- "deploy"
- "e2e_test"

steps:
clone:
stage: "clone"
title: "Cloning interlex"
type: "git-clone"
repo: "metacell/interlex"
revision: "${{CF_BRANCH}}"

build:
stage: "build"
title: "Building interlex"
Expand All @@ -23,6 +26,7 @@ steps:
build_arguments:
- VITE_API_URL=${{VITE_API_URL}}
- VITE_SCICRUNCH_API_KEY=${{VITE_SCICRUNCH_API_KEY}}

deploy:
stage: "deploy"
title: "Deploying interlex"
Expand All @@ -35,3 +39,32 @@ steps:
environment:
- KUBECONTEXT=${{CLUSTER_NAME}}
- KUBERNETES_NAMESPACE=${{NAMESPACE}}
test_build:
stage: "e2e_test"
type: build
title: Building ILEX test image
image_name: ilex-test
dockerfile: ./interlex/test/Dockerfile.testing
working_directory: .
buildkit: true
registry: ${{CODEFRESH_REGISTRY}}
e2e_test:
type: composition
title: Running E2E Tests
stage: e2e_test
working_directory: ./interlex/test
composition:
version: '2'
services:
app:
image: '${{build}}'
composition_candidates:
test:
image: '${{test_build}}'
links:
- app
working_dir: /home/pptruser/test
environment:
- TEST_USERNAME=${{TEST_USERNAME}}
- TEST_PASSWORD=${{TEST_PASSWORD}}
command: bash -c 'npm test create && npm test userInfo && npm test searchInfo'
37 changes: 37 additions & 0 deletions test/Dockerfile.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM node:20

WORKDIR /home/pptruser/test

COPY interlex/test/package.json .
COPY interlex/test/package-lock.json .

RUN apt-get update && apt-get install -y \
wget \
ca-certificates \
fonts-liberation \
libappindicator3-1 \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libcups2 \
libdbus-1-3 \
libdrm2 \
libgbm1 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libx11-xcb1 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
xdg-utils \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*

RUN npm ci

COPY . .

USER node


163 changes: 163 additions & 0 deletions test/createOrganization.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
//IMPORTS:
const puppeteer = require("puppeteer");

// INFO
const USERNAME = process.env.TEST_USERNAME
const PASSWORD = process.env.TEST_PASSWORD
const baseURL = process.env.DOMAIN || 'https://interlex.dev.metacell.us/'

const ORGANIZATION_TEXT = [`If you would like to create a new organization please contact support@interlex.org with "new organization request" as the subject. Please include the name of the organization that you would like to create, a brief explaination of what it will be used for, and the interlex username associated with the email you are sending from which will become the owner of the new organization.`]

//TESTS:

jest.setTimeout(60000);
let page;
let browser;


describe('Smoke Tests', () => {

beforeAll(async () => {

browser = await puppeteer.launch({
args: [
'--no-sandbox', '--disable-setuid-sandbox', '--bail',
],
headless: 'new',
// headless: false,
defaultViewport: {
width: 1600,
height: 1000,
},
// slowMo: 30
});


page = await browser.newPage();
await console.log(
"Checking page",
baseURL
);
await console.log('Starting tests ...')

await page.goto(baseURL, { waitUntil: 'domcontentloaded' });
const pageTitle = await page.title();
console.log(pageTitle);
expect(pageTitle).toBe('Interlex')
});

afterAll(async () => {

await browser.close()
})

describe('Login', () => {

it('Home Page check', async () => {
console.log('Going to the homepage ...')
await page.waitForSelector('a[href="/"]', { timeout: 1000 });
await page.waitForSelector('.MuiAutocomplete-root', { timeout: 1000 });
console.log('Homepage found')

});

it('Login using ORCid', async () => {
console.log('Logging in ...');
console.log('Testing user: ' + USERNAME)
await page.evaluate(() => {
const buttons = Array.from(document.querySelectorAll('button'));
const loginButton = buttons.find(btn => btn.innerText === 'Log in');
if (loginButton) loginButton.click();
else throw new Error("Log In button not found");
});

await page.waitForSelector('h4.MuiTypography-root.MuiTypography-h4', { timeout: 1000 });
await page.waitForSelector('div:has(input[name="username"])', { timeout: 1000 });


// Store the pages before clicking
const pagesBefore = await browser.pages();

// Click the "Sign in with ORCID" button
await page.evaluate(() => {
const btns = Array.from(document.querySelectorAll('button'));
const orcidloginbtn = btns.find(btn => btn.innerText === 'Sign in with ORCID');
if (orcidloginbtn) orcidloginbtn.click();
else throw new Error("Sign in with ORCID button not found");
});

// Wait for the new page to open
let orcidPage;
await browser.waitForTarget(
target => target.url().includes('orcid.org'),
{ timeout: 5000 }
);
const pagesAfter = await browser.pages();
orcidPage = pagesAfter.find(p => !pagesBefore.includes(p));

// Wait for the ORCID page to load
await orcidPage.bringToFront();
await orcidPage.waitForNavigation({ waitUntil: 'domcontentloaded' });

// Now interact with the ORCID page
await orcidPage.waitForSelector('#onetrust-accept-btn-handler', { timeout: 1000 });
await orcidPage.click('#onetrust-accept-btn-handler');
await orcidPage.waitForSelector('#username-input', { timeout: 1000 });
await orcidPage.type('#username-input', USERNAME);
await orcidPage.waitForSelector('#password', { timeout: 1000 });
await orcidPage.type('#password', PASSWORD);
await orcidPage.waitForSelector('#signin-button');
await orcidPage.click('#signin-button');

await new Promise(resolve => orcidPage.once('close', resolve));
await page.waitForSelector('.MuiAvatar-root.MuiAvatar-circular.MuiAvatar-colorDefault', { timeout: 1000 });
await new Promise(resolve => setTimeout(resolve, 1000));
console.log('Logged In');
});
})

describe('Create Organization', () => {

it('Organizations page', async () => {
console.log('Checking organizations page ...')

await page.waitForSelector('.MuiButtonBase-root.MuiButton-root.MuiButton-outlined.MuiButton-outlinedPrimary.MuiButton-sizeMedium.MuiButton-outlinedSizeMedium.MuiButton-colorPrimary.MuiButton-disableElevation.MuiButton-root.MuiButton-outlined.MuiButton-outlinedPrimary.MuiButton-sizeMedium.MuiButton-outlinedSizeMedium.MuiButton-colorPrimary.MuiButton-disableElevation', { timeout: 1000 });
await page.click('.MuiButtonBase-root.MuiButton-root.MuiButton-outlined.MuiButton-outlinedPrimary.MuiButton-sizeMedium.MuiButton-outlinedSizeMedium.MuiButton-colorPrimary.MuiButton-disableElevation.MuiButton-root.MuiButton-outlined.MuiButton-outlinedPrimary.MuiButton-sizeMedium.MuiButton-outlinedSizeMedium.MuiButton-colorPrimary.MuiButton-disableElevation');
await page.waitForSelector('.MuiPaper-elevation ul.MuiList-padding', { timeout: 1000 });
await page.waitForSelector('.MuiPaper-elevation ul.MuiList-padding li', { timeout: 1000 });

await page.evaluate(() => {
const listbtns = Array.from(document.querySelectorAll('.MuiPaper-elevation ul.MuiList-padding li div'));
const orgbtn = listbtns.find(listbtn => listbtn.innerText === 'Organizations');
if (orgbtn) orgbtn.click();
else throw new Error("Organizations button not found");
});
// await page.waitForSelector('span[role="progressbar"]', { timeout: 2000, hidden: false });
// await page.waitForSelector('span[role="progressbar"]', { timeout: 2000, hidden: true });

await page.waitForSelector('button.MuiButtonBase-root.MuiButton-root.MuiButton-text.MuiButton-textPrimary.MuiButton-sizeMedium.MuiButton-textSizeMedium.MuiButton-colorPrimary.MuiButton-disableElevation', { timeout: 2000 });
await new Promise(resolve => setTimeout(resolve, 1000));
})
it('Create org', async () => {
await page.waitForSelector('button.MuiButtonBase-root.MuiButton-root.MuiButton-text.MuiButton-textPrimary.MuiButton-sizeMedium.MuiButton-textSizeMedium.MuiButton-colorPrimary.MuiButton-disableElevation', { timeout: 2000 });
await page.evaluate(() => {
const btn = Array.from(document.querySelectorAll('button.MuiButtonBase-root.MuiButton-root.MuiButton-text.MuiButton-textPrimary.MuiButton-sizeMedium.MuiButton-textSizeMedium.MuiButton-colorPrimary.MuiButton-disableElevation'))
.find(btn => btn.innerText.trim() === 'Create a new organization');
if (btn) btn.click();
else throw new Error('Create new organization button not found');
});
await page.waitForSelector('div[aria-describedby="alert-dialog-description"]', { timeout: 3000 });
await page.waitForSelector('div[aria-describedby="alert-dialog-description"] > div', { timeout: 2000 });

const popupText = await page.evaluate(() => {
return Array.from(
document.querySelectorAll('div[aria-describedby="alert-dialog-description"] > div')
).map(el => el.innerText.trim());
});

ORGANIZATION_TEXT.forEach(txt => {
expect(popupText.some(text => text.includes(txt))).toBe(true);
});
})
})
})
Loading