cypress initial

This commit is contained in:
Kalle 2021-02-18 10:12:50 +02:00
parent eb99a06cf9
commit a30dcc394f
9 changed files with 2972 additions and 2 deletions

5
cypress.json Normal file
View File

@ -0,0 +1,5 @@
{
"baseUrl": "http://localhost:3000",
"fixturesFolder": false,
"pluginsFile": false
}

View File

@ -0,0 +1,15 @@
/// <reference types="cypress" />
context("Actions", () => {
// beforeEach(() => {
// cy.visit('/plus/history')
// })
it("show 404 if invalid route ([[...slug]])", () => {
cy.visit("/plus/history/asd", { failOnStatusCode: false });
cy.contains("Not Found");
cy.visit("/plus/history/1/2000/1", { failOnStatusCode: false });
cy.contains("Not Found");
});
});

View File

@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

20
cypress/support/index.js Normal file
View File

@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')

10
cypress/tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress"]
},
"include": [
"**/*.ts"
]
}

2887
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,8 @@
"ex:clean": "cross-env NODE_ENV=development lingui extract --clean",
"compile": "lingui compile",
"restore": "pg_restore -d 'postgresql://sendou@localhost:5432/postgres' --jobs 4 dumped.sql --clean",
"seed": "prisma db seed --preview-feature"
"seed": "prisma db seed --preview-feature",
"cy:open": "cypress open"
},
"dependencies": {
"@chakra-ui/icons": "^1.0.5",
@ -66,6 +67,7 @@
"@types/recharts": "^1.8.19",
"@types/uuid": "^8.3.0",
"cross-env": "^7.0.3",
"cypress": "^6.4.0",
"prettier": "^2.2.1",
"prisma": "^2.16.1",
"ts-node": "^9.1.1",

View File

@ -20,12 +20,18 @@ export const getStaticProps: GetStaticProps<PlusVotingHistoryPageProps> = async
return slug;
}
if (slug.length > 0) {
return [];
}
const mostRecent = await plusService.getMostRecentVotingWithResultsMonth();
return ["1", mostRecent.year, mostRecent.month];
};
const [tier, year, month] = (await getSlug()).map((param) => Number(param));
if (!tier) return { notFound: true };
const summaries = await plusService.getVotingSummariesByMonthAndTier({
tier: tier as any,
year,

View File

@ -6,7 +6,7 @@ export const getPlusStatusesData = (): Prisma.PlusStatusCreateManyInput[] => {
userId: 1,
region: "EU",
membershipTier: 1,
canVouchAgainAfter: new Date("2020-1-1"),
canVouchAgainAfter: new Date(Date.UTC(2020, 1, 1)),
},
{
userId: 2,