Skip to content

Commit

Permalink
Folders, GitHub deploy and OAuth & UI refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola authored Aug 16, 2022
2 parents d87237d + 52253a8 commit 66f022f
Show file tree
Hide file tree
Showing 65 changed files with 3,685 additions and 1,838 deletions.
8 changes: 7 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ README.md
# Node
node_modules/
tests/
cypress/
cypress.config.ts

# IPC
repositories/

# Build
dist/
build/
.next/

# Infra
*Dockerfile*
Expand Down
8 changes: 7 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
NEXT_PUBLIC_ALEPH_CHANNEL=TEST
NEXT_PUBLIC_ALEPH_CHANNEL=TEST

NEXT_PUBLIC_GITCLONE_DIR=repositories
NEXT_PUBLIC_GITHUB_CLIENT_ID="your OAuth client id"
NEXT_PUBLIC_GITHUB_CLIENT_SECRET="your OAuth client secret"
NEXTAUTH_URL=http://localhost:8080
NEXTAUTH_SECRET="secret"
2 changes: 1 addition & 1 deletion .github/workflows/end-to-end-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Run cypress
uses: cypress-io/github-action@v4
with:
start: docker run -p 8080:80 ipc:latest
start: docker run -p 8080:8080 ipc:latest
wait-on: "http://localhost:8080"

- name: Get screenshots
Expand Down
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ cypress/downloads

# next.js
/.next/
/build/

# production
/build
out/

# misc
.DS_Store
Expand All @@ -38,5 +35,5 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*


repositories/**/*
.metamask
42 changes: 18 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
###
# Builder image
###
FROM node:16.5-alpine AS builder
FROM node:16-alpine

WORKDIR /app

# Install dependencies
COPY package.json .
COPY yarn.lock .

# Install dependencies
RUN yarn install
RUN yarn --frozen-lockfile;

# Copy source (see .dockerignore)
COPY . .

# Add env variable
# Add env variables
ENV NEXT_PUBLIC_ALEPH_CHANNEL=TEST
ENV NEXTAUTH_URL="http://localhost:8080"
ENV NEXTAUTH_SECRET = $(openssl rand -base64 32)
ENV NEXT_PUBLIC_GITCLONE_DIR="repositories"
ENV NEXT_PUBLIC_GITHUB_CLIENT_ID="your OAuth client id"
ENV NEXT_PUBLIC_GITHUB_CLIENT_SECRET="your OAuth client secret"

# Build source
RUN yarn run build
RUN yarn build

###
# Production image
###
FROM nginx:1.21.6-alpine as app

WORKDIR /app
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
RUN mv next.config.js .next/standalone/
RUN mv public .next/standalone/
RUN mv .next/static .next/standalone/.next/

# Copy code
COPY --from=builder /app/build /usr/share/nginx/html
WORKDIR /app/.next/standalone

# Copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 8080

# Expose PORT
EXPOSE 80
ENV PORT 8080

# Prefix commands and start production
ENTRYPOINT ["nginx", "-g", "daemon off;"]
CMD ["node", "server.js"]
25 changes: 8 additions & 17 deletions cypress/e2e/features/files.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,34 @@ describe('Create account for File tests', () => {

describe('Upload a file modal in Dashboard', () => {
const fixtureFile = 'upload_test_file.txt';
const emptyFixtureFile = 'upload_empty_file.txt';

beforeEach(() => {
cy.visit('/login');
cy.get('#ipc-login-text-area').click().type(dashboardSpecMnemonic);
cy.get('#ipc-login-credentials-button').click();
cy.get('#ipc-dashboard-drawer-button').click({ force: true });
cy.get('#ipc-upload-button').click();
cy.get('.ipc-new-elem-button').click();
cy.get('#ipc-upload-button').click({ force: true });
});

it('Good number of buttons after upload', () => {
cy.get('#ipc-dashboard-upload-file').attachFile(fixtureFile);
cy.get('#ipc-dashboard-upload-file-modal-button').click();
cy.wait(2000);
cy.get('button').should('have.length', 12);
cy.get('button').should('have.length', 13);
});

it('Good number of buttons after closing modal', () => {
cy.get('#ipc-modal-close-button').click();
cy.get('button').should('have.length', 12);
});
});

describe('Upload an empty file in Dashboard', () => {
const fixtureFile = 'upload_empty_file.txt';

beforeEach(() => {
cy.visit('/login');
cy.get('#ipc-login-text-area').click().type(dashboardSpecMnemonic);
cy.get('#ipc-login-credentials-button').click();
cy.get('#ipc-dashboard-drawer-button').click({ force: true });
cy.get('#ipc-upload-button').click();
cy.get('button').should('have.length', 18);
});

it('Good number of buttons after failed upload', () => {
cy.get('#ipc-dashboard-upload-file').attachFile(fixtureFile, { allowEmpty: true });
cy.get('#ipc-dashboard-upload-file').attachFile(emptyFixtureFile, { allowEmpty: true });
cy.get('#ipc-dashboard-upload-file-modal-button').click();
cy.wait(2000);
cy.get('button').should('have.length', 12);
cy.get('button').should('have.length', 20);
});
});

Expand All @@ -61,6 +51,7 @@ describe('Download a file in Dashboard', () => {
cy.visit('/login');
cy.get('#ipc-login-text-area').click().type(dashboardSpecMnemonic);
cy.get('#ipc-login-credentials-button').click();
cy.get('.ipc-file-popover-button').click();
cy.get('#ipc-dashboard-download-button').click();
});

Expand Down
11 changes: 6 additions & 5 deletions cypress/e2e/features/programs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,27 @@ describe('Create account for Dashboard tests', () => {
});
});

describe('Upload a program modal for Dashboard', () => {
describe('Deploy a program modal for Dashboard', () => {
const fixtureFile = 'upload_test_program.zip';

beforeEach(() => {
cy.visit('/login');
cy.get('#ipc-login-text-area').click().type(dashboardSpecMnemonic);
cy.get('#ipc-login-credentials-button').click();
cy.get('#ipc-dashboard-drawer-button').click({ force: true });
cy.get('#ipc-deploy-button').click().wait(2500);
cy.get('.ipc-new-elem-button').click();
cy.get('#ipc-deploy-button').click({ force: true }).wait(2500);
});

it('Good number of buttons after upload', () => {
it('Good number of buttons after deployment', () => {
cy.get('#ipc-dashboard-deploy-program').attachFile(fixtureFile);
cy.get('#ipc-dashboard-deploy-program-modal-button').click();
cy.wait(2000);
cy.get('button').should('have.length', 10);
cy.get('button').should('have.length', 12);
});

it('Good number of buttons after closing modal', () => {
cy.get('#ipc-modal-close-button').click();
cy.get('button').should('have.length', 10);
cy.get('button').should('have.length', 11);
});
});
47 changes: 42 additions & 5 deletions cypress/e2e/front/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ describe('Good front for Dashboard', () => {

it('Good name for upload button', () => {
cy.get('#ipc-dashboard-drawer-button').click({ force: true });
cy.get('.ipc-new-elem-button').click();
cy.get('#ipc-upload-button').should('contain', 'Upload a file');
});

it('Good name for deploy button', () => {
cy.get('#ipc-dashboard-drawer-button').click({ force: true });
cy.get('#ipc-deploy-button').should('contain', 'Deploy a program');
});

it('Good name for create folder button', () => {
cy.get('#ipc-create-folder-button').should('contain', 'Create a folder');
});
});

describe('Good Upload file modal front in Dashboard', () => {
Expand All @@ -39,15 +43,16 @@ describe('Good Upload file modal front in Dashboard', () => {
cy.get('#ipc-login-text-area').click().type(dashboardSpecMnemonic);
cy.get('#ipc-login-credentials-button').click();
cy.get('#ipc-dashboard-drawer-button').click({ force: true });
cy.get('#ipc-upload-button').click();
cy.get('.ipc-new-elem-button').click();
cy.get('#ipc-upload-button').click({ force: true });
});

it('Good header', () => {
cy.get('header').should('contain', 'Upload a file');
});

it('Good number of buttons', () => {
cy.get('button').should('have.length', 10);
cy.get('button').should('have.length', 13);
});

it('Good number of input', () => {
Expand All @@ -69,15 +74,16 @@ describe('Good Deploy program modal front in Dashboard', () => {
cy.get('#ipc-login-text-area').click().type(dashboardSpecMnemonic);
cy.get('#ipc-login-credentials-button').click();
cy.get('#ipc-dashboard-drawer-button').click({ force: true });
cy.get('#ipc-deploy-button').click();
cy.get('.ipc-new-elem-button').click();
cy.get('#ipc-deploy-button').click({ force: true });
});

it('Good header', () => {
cy.get('header').should('contain', 'Deploy a program');
});

it('Good number of buttons', () => {
cy.get('button').should('have.length', 10);
cy.get('button').should('have.length', 13);
});

it('Good number of input', () => {
Expand All @@ -92,3 +98,34 @@ describe('Good Deploy program modal front in Dashboard', () => {
cy.get('#ipc-modal-close-button').should('contain', 'Close');
});
});

describe('Good Create folder modal front in Dashboard', () => {
it('Go to create folder modal into dashboard', () => {
cy.visit('/login');
cy.get('#ipc-login-text-area').click().type(dashboardSpecMnemonic);
cy.get('#ipc-login-credentials-button').click();
cy.get('#ipc-dashboard-drawer-button').click({ force: true });
cy.get('.ipc-new-elem-button').click();
cy.get('#ipc-create-folder-button').click({ force: true });
});

it('Good header', () => {
cy.get('header').should('contain', 'Create a folder');
});

it('Good number of buttons', () => {
cy.get('button').should('have.length', 13);
});

it('Good number of input', () => {
cy.get('input[type=text]').should('have.length', 1);
});

it('Good name for create folder button', () => {
cy.get('#ipc-dashboard-create-folder-modal-button').should('contain', 'Create Folder');
});

it('Good name for close button', () => {
cy.get('#ipc-modal-close-button').should('contain', 'Close');
});
});
4 changes: 2 additions & 2 deletions cypress/e2e/front/home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Signup Button front in Home', () => {
});

it('Good URL redirect for create account button', () => {
cy.get('#ipc-home-create-account-button').click().url().should('eq', 'http://localhost:8080/signup');
cy.get('#ipc-home-create-account-button').click().url().should('eq', `${Cypress.config().baseUrl}/signup`);
});
});

Expand All @@ -40,6 +40,6 @@ describe('Login Button front in Home', () => {
});

it('Good URL redirect for login button', () => {
cy.get('#ipc-home-login-button').click().url().should('eq', 'http://localhost:8080/login');
cy.get('#ipc-home-login-button').click().url().should('eq', `${Cypress.config().baseUrl}/login`);
});
});
6 changes: 3 additions & 3 deletions cypress/e2e/login.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const mnemonic = 'repair nest celery light distance coil giant pyramid poet suit trim fluid';
const mnemonic = 'enlist deny plug hockey sign dirt rebel nothing tobacco dream error fever';

describe('Good front for Login', () => {
it('Go to login', () => {
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('Login with credentials Button for Login', () => {
});

it('Good URL redirect for login button', () => {
cy.get('#ipc-login-credentials-button').click().url().should('eq', 'http://localhost:8080/dashboard');
cy.get('#ipc-login-credentials-button').click().url().should('eq', `${Cypress.config().baseUrl}/dashboard`);
});
});

Expand All @@ -51,6 +51,6 @@ describe('Signup Button for Login', () => {
});

it('Good URL redirect for signup button', () => {
cy.get('#ipc-login-signup-button').click().url().should('eq', 'http://localhost:8080/signup');
cy.get('#ipc-login-signup-button').click().url().should('eq', `${Cypress.config().baseUrl}/signup`);
});
});
4 changes: 2 additions & 2 deletions cypress/e2e/signup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Signup with credentials Button for Signup', () => {
});

it('Good URL redirect for close button', () => {
cy.get('#ipc-modal-close-button').click().url().should('eq', 'http://localhost:8080/dashboard');
cy.get('#ipc-modal-close-button').click().url().should('eq', `${Cypress.config().baseUrl}/dashboard`);
});
});

Expand All @@ -78,6 +78,6 @@ describe('Login Button for Signup', () => {
});

it('Good URL redirect for login button', () => {
cy.get('#ipc-signup-login-button').click().url().should('eq', 'http://localhost:8080/login');
cy.get('#ipc-signup-login-button').click().url().should('eq', `${Cypress.config().baseUrl}/login`);
});
});
3 changes: 2 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
output: 'standalone',
}

module.exports = nextConfig
module.exports = nextConfig;
20 changes: 0 additions & 20 deletions nginx.conf

This file was deleted.

Loading

0 comments on commit 66f022f

Please sign in to comment.