Skip to content

Commit

Permalink
Merge pull request #684 from UTDNebula/develop
Browse files Browse the repository at this point in the history
Sync with main
  • Loading branch information
akevinge authored Sep 26, 2023
2 parents e2aa260 + 5f83c12 commit c80a150
Show file tree
Hide file tree
Showing 25 changed files with 680 additions and 232 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ yarn-error.log*
# See docs/ide-config.md for more information.
.idea
.vs/
.editorconfig

prisma/generated

Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ public

node_modules/
prisma/generated

**/.mypy_cache/
**/venv/
Binary file added cypress/data/dummytranscript.pdf
Binary file not shown.
95 changes: 93 additions & 2 deletions cypress/e2e/create-plan.cy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,56 @@
describe('Plan creation flow', () => {
before('Setup', () => {
beforeEach('Setup', () => {
cy.resetDbAndLogin();
cy.visit('/app/home');
});

const planName = "Mr. Bob's Plan";

it('Create blank plan', () => {
// Open add plan dropdown
cy.task('log', 'Opening blank plan modal...');
cy.dataTestId('add-new-plan-btn').click();
cy.dataTestId('add-blank-plan-btn').click();

// Modal should be visible
cy.dataTestId('create-blank-plan-page').then(($el) => Cypress.dom.isVisible($el));

// Fill out plan creation form
cy.task('log', 'Filling out plan creation form...');
cy.dataTestId('plan-name-input').type(planName);
cy.dataTestId('major-autocomplete').type('Computer');
cy.getDropdownOptions()
.contains('Computer Science')
.then(($el) => {
cy.wrap($el.get(0).innerText).as('major');
$el.click();
});

// Create plan without upload transcript
cy.task('log', 'Creating plan...');
cy.dataTestId('create-plan-btn').click();

// Wait and verify redirect to plan
cy.task('log', 'Verifying redirect...');
cy.url({ timeout: 20000 }).should('include', '/app/plans/');

// Check plan information
cy.task('log', 'Verifying plan information');
cy.get('@major').then((majorAlias) => {
// Check plan title
cy.dataTestId('plan-title')
.then(($el) => $el.text())
.should('eq', planName);

// Check plan major
const major = `${majorAlias}`; // Whack workaround
cy.dataTestId('plan-major')
.then(($el) => $el.text())
.should('eq', major);
});
});

it('Create custom plan', () => {
// Open add plan dropdown
cy.task('log', 'Opening custom plan modal...');
cy.dataTestId('add-new-plan-btn').click();
Expand All @@ -26,9 +70,56 @@ describe('Plan creation flow', () => {
$el.click();
});

// Create plan without upload transcript
// Create plan with uploading transcript
cy.task('log', 'Creating plan...');
cy.dataTestId('next-btn').click();
cy.dataTestId('upload-transcript-btn').click();

cy.get('input[type=file]').selectFile('cypress/data/dummytranscript.pdf', { force: true });
cy.dataTestId('create-plan-btn').click();

// Wait and verify redirect to plan
cy.task('log', 'Verifying redirect...');
cy.url({ timeout: 20000 }).should('include', '/app/plans/');

// Check plan information
cy.task('log', 'Verifying plan information');
cy.get('@major').then((majorAlias) => {
// Check plan title
cy.dataTestId('plan-title')
.then(($el) => $el.text())
.should('eq', planName);

// Check plan major
const major = `${majorAlias}`; // Whack workaround
cy.dataTestId('plan-major')
.then(($el) => $el.text())
.should('eq', major);
});
});

it('Create template plan', () => {
// Open add plan dropdown
cy.task('log', 'Opening template plan modal...');
cy.dataTestId('add-new-plan-btn').click();
cy.dataTestId('add-template-plan-btn').click();

// Modal should be visible
cy.dataTestId('create-template-plan-page').then(($el) => Cypress.dom.isVisible($el));

// Fill out plan creation form
cy.task('log', 'Filling out plan creation form...');
cy.dataTestId('plan-name-input').type(planName);
cy.dataTestId('major-autocomplete').type('Computer');
cy.getDropdownOptions()
.contains('Computer Science')
.then(($el) => {
cy.wrap($el.get(0).innerText).as('major');
$el.click();
});

// Create template plan without upload transcript
cy.task('log', 'Creating plan...');
cy.dataTestId('create-plan-btn').click();

// Wait and verify redirect to plan
Expand Down
84 changes: 55 additions & 29 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,64 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { withSentryConfig } = require('@sentry/nextjs');
const fetch = require('node-fetch');

/* eslint-disable @typescript-eslint/no-var-requires */

const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const checkValidatorAvailability = async () => {
try {
const response = await fetch(`${process.env.NEXT_PUBLIC_VALIDATOR}/health`);
if (response.ok) {
return true;
} else {
return false;
}
} catch (error) {
return false;
}
};

const nextConfig = withBundleAnalyzer({
modularizeImports: {
'@mui/material': {
transform: '@mui/material/{{member}}',
module.exports = async (phase) => {
if (phase === 'phase-development-server') {
const isValidatorReachable = await checkValidatorAvailability();

if (!isValidatorReachable) {
console.error('Start validator server first before running next dev server.');
process.exit(1);
}
}

const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});

const nextConfig = withBundleAnalyzer({
modularizeImports: {
'@mui/material': {
transform: '@mui/material/{{member}}',
},
'@mui/icons-material': {
transform: '@mui/icons-material/{{member}}',
},
},
'@mui/icons-material': {
transform: '@mui/icons-material/{{member}}',
compiler: {
removeConsole: process.env.NODE_ENV === 'production',
},
},
compiler: {
removeConsole: process.env.NODE_ENV === 'production',
},
rewrites: async () => {
return [
{
source: '/',
destination: '/index.html',
},
];
},
});
rewrites: async () => {
return [
{
source: '/',
destination: '/index.html',
},
];
},
});

module.exports = withSentryConfig(
nextConfig,
{ silent: true },
// tunnelRoute set to bypass adblockers.
// See: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-tunneling-to-avoid-ad-blockers.
{ hideSourcemaps: false, tunnelRoute: '/sentry-tunnel' },
);
const sentryConfig = withSentryConfig(
nextConfig,
{ silent: true },
// tunnelRoute set to bypass adblockers.
// See: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-tunneling-to-avoid-ad-blockers.
{ hideSourcemaps: false, tunnelRoute: '/sentry-tunnel' },
);
return sentryConfig;
};
Loading

0 comments on commit c80a150

Please sign in to comment.