Skip to content

Commit

Permalink
Try to run e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
UO282476 authored and UO282476 committed May 3, 2023
1 parent afdb2d6 commit 345ee3d
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 167 deletions.
107 changes: 54 additions & 53 deletions .github/workflows/lomap_en1a.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,61 +18,62 @@ jobs:
- run: npm --prefix restapi ci
- run: npm --prefix webapp test --coverage --watchAll
- run: npm --prefix restapi test --coverage --watchAll
#- run: npm --prefix webapp run test:e2e --coverage --watchAll
- run: npm --prefix webapp run test:e2e --coverage --watchAll
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
docker-push-webapp:
name: Push webapp Docker Image to GitHub Packages
runs-on: ubuntu-latest
#needs: [tests]
steps:
- uses: actions/checkout@v3
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
env:
HOST_DOMAIN: ${{ secrets.DEPLOY_HOST_RUBEN }}
API_URI: https://${{ secrets.DEPLOY_HOST_RUBEN }}:5443/api
with:
name: arquisoft/lomap_en1a/webapp
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
registry: ghcr.io
workdir: webapp
buildargs: API_URI, HOST_DOMAIN
docker-push-restapi:
name: Push restapi Docker Image to GitHub Packages
runs-on: ubuntu-latest
#needs: [tests]
steps:
- uses: actions/checkout@v3
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
env:
HOST_DOMAIN: ${{ secrets.DEPLOY_HOST_RUBEN }}
with:
name: arquisoft/lomap_en1a/restapi
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
registry: ghcr.io
workdir: restapi
buildargs: HOST_DOMAIN
deploy:
name: Deploy over SSH
runs-on: ubuntu-latest
needs: [docker-push-restapi,docker-push-webapp]
steps:
- name: Deploy over SSH
uses: fifsky/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST_RUBEN }}
user: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY_RUBEN }}
command: |
wget https://raw.githubusercontent.com/arquisoft/lomap_en1a/deploy-with-https-certificate-3/docker-compose-deploy.yml -O docker-compose.yml
docker-compose stop
docker-compose rm -f
docker-compose pull
docker-compose up -d
# docker-push-webapp:
# name: Push webapp Docker Image to GitHub Packages
# runs-on: ubuntu-latest
# #needs: [tests]
# steps:
# - uses: actions/checkout@v3
# - name: Publish to Registry
# uses: elgohr/Publish-Docker-Github-Action@v5
# env:
# HOST_DOMAIN: ${{ secrets.HOST_NAME }}
# HOST_IP: ${{ secrets.DEPLOY_HOST }}
# with:
# name: arquisoft/lomap_en1a/webapp
# username: ${{ github.actor }}
# password: ${{ secrets.DOCKER_PUSH_TOKEN }}
# registry: ghcr.io
# workdir: webapp
# buildargs: HOST_DOMAIN, HOST_IP
# docker-push-restapi:
# name: Push restapi Docker Image to GitHub Packages
# runs-on: ubuntu-latest
# #needs: [tests]
# steps:
# - uses: actions/checkout@v3
# - name: Publish to Registry
# uses: elgohr/Publish-Docker-Github-Action@v5
# env:
# HOST_DOMAIN: ${{ secrets.HOST_NAME }}
# HOST_IP: ${{ secrets.DEPLOY_HOST }}
# with:
# name: arquisoft/lomap_en1a/restapi
# username: ${{ github.actor }}
# password: ${{ secrets.DOCKER_PUSH_TOKEN }}
# registry: ghcr.io
# workdir: restapi
# buildargs: HOST_DOMAIN, HOST_IP
# deploy:
# name: Deploy over SSH
# runs-on: ubuntu-latest
# needs: [docker-push-restapi,docker-push-webapp]
# steps:
# - name: Deploy over SSH
# uses: fifsky/ssh-action@master
# with:
# host: ${{ secrets.DEPLOY_HOST }}
# user: ${{ secrets.DEPLOY_USER }}
# key: ${{ secrets.DEPLOY_KEY }}
# command: |
# wget https://raw.githubusercontent.com/arquisoft/lomap_en1a/deploy-with-https-certificate-3/docker-compose-deploy.yml -O docker-compose.yml
# docker-compose stop
# docker-compose rm -f
# docker-compose pull
# docker-compose up -d
5 changes: 4 additions & 1 deletion restapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ WORKDIR /app
RUN npm install

ARG HOST_DOMAIN="lomapen1a.cloudns.ph"
ENV host=$HOST_DOMAIN
ENV DOMAIN=$HOST_DOMAIN

ARG HOST_IP="localhost"
ENV IP=$HOST_IP

CMD [ "npm", "start" ]
5 changes: 4 additions & 1 deletion restapi/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ api.use(
})
);

const hostName = process.env.DOMAIN;
const hostIp = process.env.IP;

api.use(
cors({
credentials: true,
origin: ["https://20.77.68.160", "https://lomapen1a.cloudns.ph", "https://localhost"],
origin: ["https://" + hostName, "https://" + hostIp, "https://localhost"],
allowedHeaders: ["Content-Type", "Authorization"],
preflightContinue: true,
})
Expand Down
4 changes: 3 additions & 1 deletion restapi/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ const app: Application = express();
const portHttp: number = 5080;
const portHttps: number = 5443;

const hostName = process.env.DOMAIN || "localhost";

app.all('*', function(req, res, next){
if (req.secure) {
return next();
}
res.redirect('https://'+ "lomapen1a.cloudns.ph" + ":" + portHttps + req.url);
res.redirect('https://'+ hostName + ":" + portHttps + req.url);
});

const metricsMiddleware: RequestHandler = promBundle({ includeMethod: true });
Expand Down
7 changes: 4 additions & 3 deletions restapi/src/repositories/pods/PodSessionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export class PodSessionManager {
private handle = configuration.handle;
private port = configuration.port;
private clientName = configuration.clientName;
private host = process.env.DOMAIN || "localhost";

public async login(req: any, res: Response): Promise<void> {
let host: string = "lomapen1a.cloudns.ph";
let host: string = this.host;

let provider = req.params.provider;
Assertion.exists(provider, "A provider must be given.");
Expand All @@ -45,7 +46,7 @@ export class PodSessionManager {
}

public async successfulLogin(req: any, res: Response): Promise<any> {
let host: string = "lomapen1a.cloudns.ph";
let host: string = this.host;

let sessionId = req.session.solidSessionId;

Expand Down Expand Up @@ -83,7 +84,7 @@ export class PodSessionManager {
}

public async isLoggedIn(sessionId: string): Promise<boolean> {
Assertion.exists(sessionId, "The user must be logged in.");
//Assertion.exists(sessionId, "The user must be logged in.");
let isLoggedIn = (await getSessionFromStorage(sessionId))?.info.isLoggedIn;

if (isLoggedIn == undefined) {
Expand Down
8 changes: 4 additions & 4 deletions webapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ WORKDIR /app
#Install the dependencies
RUN npm install

ARG API_URI="http://lomapen1a.cloudns.ph:5443/api"
ENV REACT_APP_API_URI=$API_URI

ARG HOST_DOMAIN="lomapen1a.cloudns.ph"
ENV host=$HOST_DOMAIN
ENV DOMAIN=$HOST_DOMAIN

ARG HOST_IP="localhost"
ENV IP=$HOST_IP

#Create an optimized version of the webapp
RUN npm run build
Expand Down
18 changes: 9 additions & 9 deletions webapp/e2e/steps/friendsmanagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ defineFeature(feature, test => {
page = await browser.newPage();

await page
.goto("http://172.187.193.114:3000", {
.goto("https://localhost:443", {
waitUntil: "networkidle0",
})
.catch(() => { });

// await page.waitForSelector('#details-button')
// await page.click('#details-button')
await page.waitForSelector('#details-button')
await page.click('#details-button')

// await page.waitForSelector('#proceed-link')
// await page.click('#proceed-link')
});
await page.waitForSelector('#proceed-link')
await page.click('#proceed-link')
}, 1000000);

test('The user wants to see the friends management tab', ({ given, when, then }) => {

Expand All @@ -43,8 +43,8 @@ defineFeature(feature, test => {
await expect(page).toClick('a', { text: 'Log in' })
await expect(page).toClick('button', { text: 'Solid Community' })
//Hago submit con el boton de Go
await page.waitForSelector('button[type="submit"]')
await page.click('button[type="submit"]')
// await page.waitForSelector('button[type="submit"]')
// await page.click('button[type="submit"]')


//Espero a que se cargue la pagina de login
Expand All @@ -59,7 +59,7 @@ defineFeature(feature, test => {
await page.waitForSelector('a[href="/map"]')
await page.waitForSelector('img')
//Hago clic en el dropdown de perfil
await page.goto("http://localhost:80/friends")
await page.goto("https://localhost:443/friends")

//Espero a que se cargue la pagina de añadir lugar

Expand Down
16 changes: 8 additions & 8 deletions webapp/e2e/steps/login.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ defineFeature(feature, test => {
page = await browser.newPage();

await page
.goto("http://172.187.193.114:3000", {
.goto("https://localhost:443", {
waitUntil: "networkidle0",
})
.catch(() => { });

// await page.waitForSelector('#details-button')
// await page.click('#details-button')
await page.waitForSelector('#details-button')
await page.click('#details-button')

// await page.waitForSelector('#proceed-link')
// await page.click('#proceed-link')
await page.waitForSelector('#proceed-link')
await page.click('#proceed-link')

// await page.waitForSelector('.btn btn-primary')
// await page.click('.btn btn-primary')
});
}, 1000000);

test('The user is not logged in the site', ({ given, when, then }) => {

Expand All @@ -46,8 +46,8 @@ defineFeature(feature, test => {
await expect(page).toClick('a', { text: 'Log in' })
await expect(page).toClick('button', { text: 'Solid Community' })
//Hago submit con el boton de Go
await page.waitForSelector('button[type="submit"]')
await page.click('button[type="submit"]')
// await page.waitForSelector('button[type="submit"]')
// await page.click('button[type="submit"]')


//Espero a que se cargue la pagina de login
Expand Down
18 changes: 9 additions & 9 deletions webapp/e2e/steps/profile.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ defineFeature(feature, test => {
page = await browser.newPage();

await page
.goto("http://172.187.193.114:3000", {
.goto("https://localhost:443", {
waitUntil: "networkidle0",
})
.catch(() => { });

// await page.waitForSelector('#details-button')
// await page.click('#details-button')
await page.waitForSelector('#details-button')
await page.click('#details-button')

// await page.waitForSelector('#proceed-link')
// await page.click('#proceed-link')
});
await page.waitForSelector('#proceed-link')
await page.click('#proceed-link')
}, 1000000);

test('The user wants to see the profile', ({ given, when, then }) => {

Expand All @@ -43,8 +43,8 @@ defineFeature(feature, test => {
await expect(page).toClick('a', { text: 'Log in' })
await expect(page).toClick('button', { text: 'Solid Community' })
//Hago submit con el boton de Go
await page.waitForSelector('button[type="submit"]')
await page.click('button[type="submit"]')
// await page.waitForSelector('button[type="submit"]')
// await page.click('button[type="submit"]')


//Espero a que se cargue la pagina de login
Expand All @@ -59,7 +59,7 @@ defineFeature(feature, test => {
await page.waitForSelector('a[href="/map"]')
await page.waitForSelector('img')
//Hago clic en el dropdown de perfil
await page.goto("http://localhost:80/profile")
await page.goto("https://localhost:443/profile")

//Espero a que se cargue la pagina de añadir lugar

Expand Down
Loading

0 comments on commit 345ee3d

Please sign in to comment.