Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress caching #368

Merged
merged 39 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1248c2b
Testing NextJS Cache
xannyxs Jan 29, 2024
f9959d3
Added a `cache` to the testing envirment
xannyxs Jan 29, 2024
7461450
Update test.yml
xannyxs Jan 29, 2024
89a5898
Added a `push` section
xannyxs Jan 29, 2024
9cc7499
Merge branch 'develop' into vercelCache
xannyxs Jan 29, 2024
e48802b
Update test.yml
xannyxs Jan 29, 2024
568577b
Update test.yml
xannyxs Jan 29, 2024
1f4aa15
Adding extra that should fail if there is no cahce-key
xannyxs Jan 29, 2024
53101c2
Rewrote the file
xannyxs Jan 29, 2024
adf92ed
Update test.yml
xannyxs Jan 29, 2024
893d309
Update test.yml
xannyxs Jan 29, 2024
e16245c
Update test.yml
xannyxs Jan 29, 2024
7654662
Update test.yml
xannyxs Jan 29, 2024
130ea39
Update test.yml
xannyxs Jan 29, 2024
fdc3232
Update test.yml
xannyxs Jan 29, 2024
59241cb
Merge branch 'develop' into vercelCache
xannyxs Jan 29, 2024
6bbfb67
Update test.yml
xannyxs Jan 29, 2024
65b7455
Update test.yml
xannyxs Jan 29, 2024
19bf7af
Update test.yml
xannyxs Jan 30, 2024
b824484
Merge branch 'develop' into vercelCache
xannyxs Jan 30, 2024
da05612
Hmmm please work
xannyxs Jan 30, 2024
7c138fb
Update test.yml
xannyxs Jan 30, 2024
43e970d
Corrected the path
xannyxs Jan 30, 2024
cf9833e
Create build_server.yml
xannyxs Jan 30, 2024
fc9fcbe
Update test.yml
xannyxs Jan 30, 2024
32b917d
Support file not needed
xannyxs Jan 30, 2024
673b660
Changed working directory
xannyxs Jan 30, 2024
0471b79
Update test.yml
xannyxs Jan 30, 2024
18cd3b7
Update test.yml
xannyxs Jan 30, 2024
64f6186
Update test.yml
xannyxs Jan 30, 2024
acb9b24
Do not record vids
xannyxs Jan 30, 2024
fc34221
Added mobile testing
xannyxs Jan 30, 2024
1c3a3b4
Update test.yml
xannyxs Jan 30, 2024
6542f5e
Update test.yml
xannyxs Jan 30, 2024
02936a0
Please work
xannyxs Jan 30, 2024
0627403
Added firefox tests
xannyxs Jan 30, 2024
6892fc0
Waiting until API Call is finished
xannyxs Jan 30, 2024
5903e5d
Inception now works correctly
xannyxs Jan 30, 2024
5bd914b
Adding a few configs
xannyxs Jan 30, 2024
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
30 changes: 30 additions & 0 deletions .github/workflows/build_server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build server

on:
push:
branches: [main]
pull_request:
branches: [develop, main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js 20...
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install yarn...
run: npm install -g yarn

- name: Install dependencies...
run: yarn install
working-directory: packages/new-server

- name: Build server
run: yarn build
working-directory: packages/new-server
6 changes: 1 addition & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: Cypress Tests

on:
pull_request:
branches: [develop]

jobs:
cypress-run:
runs-on: ubuntu-22.04
Expand All @@ -24,4 +20,4 @@ jobs:
with:
build: yarn build
start: yarn start
working-directory: ./packages/app
working-directory: ./packages/app
142 changes: 132 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
install:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -39,30 +39,152 @@ jobs:
if-no-files-found: error
path: packages/app/.next

cypress-run:
runs-on: ubuntu-22.04
chrome-tests:
timeout-minutes: 15
runs-on: ubuntu-latest
needs: install
strategy:
fail-fast: false
matrix:
containers: [1, 2]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download the .next directory
- name: Download the build folders
uses: actions/download-artifact@v4
with:
name: next-artifact
path: packages/app/.next

- name: Install dependencies
run: |
npm install -g yarn
- name: "E2e tests - Chrome"
uses: cypress-io/github-action@v6
with:
build: yarn --cwd packages/app cypress info
start: yarn --cwd packages/app start
wait-on: "http://localhost:3000"
wait-on-timeout: 120
browser: chrome
working-directory: packages/app
env:
NEXT_PUBLIC_STUDIO_API_KEY: ${{ secrets.NEXT_PUBLIC_STUDIO_API_KEY }}
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
SESSION_SECRET: ${{ secrets.SESSION_SECRET }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEBUG: "cypress:server:args"

chrome-mobile-tests:
timeout-minutes: 15
runs-on: ubuntu-latest
needs: install
strategy:
fail-fast: false
matrix:
containers: [1, 2]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download the build folders
uses: actions/download-artifact@v4
with:
name: next-artifact
path: packages/app/.next

- name: "E2e tests - Chrome Mobile"
uses: cypress-io/github-action@v6
with:
build: yarn --cwd packages/app cypress info
start: yarn --cwd packages/app start
wait-on: "http://localhost:3000"
wait-on-timeout: 120
browser: chrome
working-directory: packages/app
config: |
{
"e2e": {
"viewportWidth": 390,
"viewportHeight": 844
}
}
env:
NEXT_PUBLIC_STUDIO_API_KEY: ${{ secrets.NEXT_PUBLIC_STUDIO_API_KEY }}
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
SESSION_SECRET: ${{ secrets.SESSION_SECRET }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEBUG: "cypress:server:args"

- name: Cypress run
firefox-tests:
timeout-minutes: 15
runs-on: ubuntu-latest
needs: install
strategy:
fail-fast: false
matrix:
containers: [1, 2]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download the build folders
uses: actions/download-artifact@v4
with:
name: next-artifact
path: packages/app/.next

- name: "E2e tests - Firefox"
uses: cypress-io/github-action@v6
with:
build: yarn --cwd packages/app cypress info
start: yarn --cwd packages/app start
wait-on: "http://localhost:3000"
wait-on-timeout: 120
browser: firefox
working-directory: packages/app
env:
NEXT_PUBLIC_STUDIO_API_KEY: ${{ secrets.NEXT_PUBLIC_STUDIO_API_KEY }}
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
SESSION_SECRET: ${{ secrets.SESSION_SECRET }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEBUG: "cypress:server:args"

firefox-mobile-tests:
timeout-minutes: 15
runs-on: ubuntu-latest
needs: install
strategy:
fail-fast: false
matrix:
containers: [1, 2]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download the build folders
uses: actions/download-artifact@v4
with:
name: next-artifact
path: packages/app/.next

- name: "E2e tests - Firefox mobile"
uses: cypress-io/github-action@v6
with:
start: yarn start
build: yarn --cwd packages/app cypress info
start: yarn --cwd packages/app start
wait-on: "http://localhost:3000"
wait-on-timeout: 120
browser: chrome
working-directory: ./packages/app
working-directory: packages/app
config: |
{
"e2e": {
"viewportWidth": 375,
"viewportHeight": 667
}
}
env:
NEXT_PUBLIC_STUDIO_API_KEY: ${{ secrets.NEXT_PUBLIC_STUDIO_API_KEY }}
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
SESSION_SECRET: ${{ secrets.SESSION_SECRET }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEBUG: "cypress:server:args"
12 changes: 7 additions & 5 deletions packages/app/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { defineConfig } from "cypress";
import { defineConfig } from 'cypress'

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
defaultCommandTimeout: 6000,
retries: {
runMode: 3,
openMode: 0,
},
}
});
},
})
9 changes: 6 additions & 3 deletions packages/app/cypress/e2e/archive.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('archive page', () => {
)
})

it('can input search query and keep organization name', () => {
it('Can input search query and keep organization name', () => {
cy.visit(
'http://localhost:3000/archive?event=funding_the_commons_berlin_2023'
)
Expand All @@ -68,14 +68,17 @@ describe('archive page', () => {
.should('include', 'event=funding_the_commons_berlin_2023')
})

it('show pagination and can click next page', () => {
it('Show pagination and can click next page', () => {
cy.intercept('GET', '/archive?searchQuery=jonas').as(
'searchForJonas'
)
cy.visit('http://localhost:3000/archive')
cy.get(':nth-child(2) > .flex > .mx-2').should(
'contain',
'1 of 67'
)
cy.viewport(1200, 800)
cy.get(':nth-child(2) > .flex > :nth-child(3)').click()

cy.url().should('include', 'page=2')
cy.get(':nth-child(2) > .flex > .mx-2').should(
'contain',
Expand Down
2 changes: 0 additions & 2 deletions packages/app/cypress/e2e/home.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ describe('Tests for homepage', () => {
})

it('can click description', () => {
cy.viewport(1200, 800)
cy.get(
':nth-child(2) > .min-h-full > .flex-col > [href="/archive?event=ethporto_2023"] > .flex > .text-xs'
).click()
})

it('can click organization name', () => {
cy.viewport(1200, 800)
cy.get(':nth-child(1) > .my-2 > a > .font-semibold').click()
})
})
5 changes: 3 additions & 2 deletions packages/app/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
beforeEach(() => {
cy.viewport(1200, 1000)
})
9 changes: 9 additions & 0 deletions packages/new-server/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
5 changes: 5 additions & 0 deletions packages/new-server/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
37 changes: 37 additions & 0 deletions packages/new-server/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts 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) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
20 changes: 20 additions & 0 deletions packages/new-server/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts 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')