Skip to content

Commit 22ec058

Browse files
authored
test: add cypress foundation (sct#2903) [skip ci]
1 parent db898db commit 22ec058

File tree

27 files changed

+848
-17
lines changed

27 files changed

+848
-17
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ public/os_logo_filled.png
2626
public/preview.jpg
2727
snap
2828
stylelint.config.js
29+
cypress

.github/workflows/cypress.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Cypress Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '*'
7+
push:
8+
branches:
9+
- develop
10+
11+
jobs:
12+
cypress-run:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Cypress run
18+
uses: cypress-io/github-action@v4
19+
with:
20+
build: yarn cypress:build
21+
start: yarn start
22+
wait-on: 'http://localhost:5055'
23+
record: true
24+
env:
25+
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
WITH_MIGRATIONS: true
28+
# Fix test titles in cypress dashboard
29+
COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}}
30+
COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha}}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,8 @@ config/db/db.sqlite3-journal
5353

5454
# VS Code
5555
.vscode/launch.json
56+
57+
# Cypress
58+
cypress.env.json
59+
cypress/videos
60+
cypress/screenshots

cypress.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig } from 'cypress';
2+
3+
export default defineConfig({
4+
projectId: 'onnqy3',
5+
e2e: {
6+
baseUrl: 'http://localhost:5055',
7+
experimentalSessionAndOrigin: true,
8+
},
9+
env: {
10+
ADMIN_EMAIL: '[email protected]',
11+
ADMIN_PASSWORD: 'test1234',
12+
USER_EMAIL: '[email protected]',
13+
USER_PASSWORD: 'test1234',
14+
},
15+
});

cypress/config/settings.cypress.json

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
{
2+
"clientId": "6919275e-142a-48d8-be6b-93594cbd4626",
3+
"vapidPrivate": "tmnslaO8ZWN6bNbSEv_rolPeBTlNxOwCCAHrM9oZz3M",
4+
"vapidPublic": "BK_EpP8NDm9waor2zn6_S28o3ZYv4kCkJOfYpO3pt3W6jnPmxrgTLANUBNbbyaNatPnSQ12De9CeqSYQrqWzHTs",
5+
"main": {
6+
"apiKey": "testkey",
7+
"applicationTitle": "Overseerr",
8+
"applicationUrl": "",
9+
"csrfProtection": false,
10+
"cacheImages": false,
11+
"defaultPermissions": 32,
12+
"defaultQuotas": {
13+
"movie": {},
14+
"tv": {}
15+
},
16+
"hideAvailable": false,
17+
"localLogin": true,
18+
"newPlexLogin": true,
19+
"region": "",
20+
"originalLanguage": "",
21+
"trustProxy": false,
22+
"partialRequestsEnabled": true,
23+
"locale": "en"
24+
},
25+
"plex": {
26+
"name": "Seerr",
27+
"ip": "192.168.1.1",
28+
"port": 32400,
29+
"useSsl": false,
30+
"libraries": [
31+
{
32+
"id": "1",
33+
"name": "Movies",
34+
"enabled": true,
35+
"type": "movie"
36+
}
37+
],
38+
"machineId": "test"
39+
},
40+
"tautulli": {},
41+
"radarr": [],
42+
"sonarr": [],
43+
"public": {
44+
"initialized": true
45+
},
46+
"notifications": {
47+
"agents": {
48+
"email": {
49+
"enabled": false,
50+
"options": {
51+
"emailFrom": "",
52+
"smtpHost": "",
53+
"smtpPort": 587,
54+
"secure": false,
55+
"ignoreTls": false,
56+
"requireTls": false,
57+
"allowSelfSigned": false,
58+
"senderName": "Overseerr"
59+
}
60+
},
61+
"discord": {
62+
"enabled": false,
63+
"types": 0,
64+
"options": {
65+
"webhookUrl": "",
66+
"enableMentions": true
67+
}
68+
},
69+
"lunasea": {
70+
"enabled": false,
71+
"types": 0,
72+
"options": {
73+
"webhookUrl": ""
74+
}
75+
},
76+
"slack": {
77+
"enabled": false,
78+
"types": 0,
79+
"options": {
80+
"webhookUrl": ""
81+
}
82+
},
83+
"telegram": {
84+
"enabled": false,
85+
"types": 0,
86+
"options": {
87+
"botAPI": "",
88+
"chatId": "",
89+
"sendSilently": false
90+
}
91+
},
92+
"pushbullet": {
93+
"enabled": false,
94+
"types": 0,
95+
"options": {
96+
"accessToken": ""
97+
}
98+
},
99+
"pushover": {
100+
"enabled": false,
101+
"types": 0,
102+
"options": {
103+
"accessToken": "",
104+
"userToken": ""
105+
}
106+
},
107+
"webhook": {
108+
"enabled": false,
109+
"types": 0,
110+
"options": {
111+
"webhookUrl": "",
112+
"jsonPayload": "IntcbiAgICBcIm5vdGlmaWNhdGlvbl90eXBlXCI6IFwie3tub3RpZmljYXRpb25fdHlwZX19XCIsXG4gICAgXCJldmVudFwiOiBcInt7ZXZlbnR9fVwiLFxuICAgIFwic3ViamVjdFwiOiBcInt7c3ViamVjdH19XCIsXG4gICAgXCJtZXNzYWdlXCI6IFwie3ttZXNzYWdlfX1cIixcbiAgICBcImltYWdlXCI6IFwie3tpbWFnZX19XCIsXG4gICAgXCJ7e21lZGlhfX1cIjoge1xuICAgICAgICBcIm1lZGlhX3R5cGVcIjogXCJ7e21lZGlhX3R5cGV9fVwiLFxuICAgICAgICBcInRtZGJJZFwiOiBcInt7bWVkaWFfdG1kYmlkfX1cIixcbiAgICAgICAgXCJ0dmRiSWRcIjogXCJ7e21lZGlhX3R2ZGJpZH19XCIsXG4gICAgICAgIFwic3RhdHVzXCI6IFwie3ttZWRpYV9zdGF0dXN9fVwiLFxuICAgICAgICBcInN0YXR1czRrXCI6IFwie3ttZWRpYV9zdGF0dXM0a319XCJcbiAgICB9LFxuICAgIFwie3tyZXF1ZXN0fX1cIjoge1xuICAgICAgICBcInJlcXVlc3RfaWRcIjogXCJ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GFyfX1cIlxuICAgIH0sXG4gICAgXCJ7e2V4dHJhfX1cIjogW11cbn0i"
113+
}
114+
},
115+
"webpush": {
116+
"enabled": false,
117+
"options": {}
118+
},
119+
"gotify": {
120+
"enabled": false,
121+
"types": 0,
122+
"options": {
123+
"url": "",
124+
"token": ""
125+
}
126+
}
127+
}
128+
},
129+
"jobs": {
130+
"plex-recently-added-scan": {
131+
"schedule": "0 */5 * * * *"
132+
},
133+
"plex-full-scan": {
134+
"schedule": "0 0 3 * * *"
135+
},
136+
"radarr-scan": {
137+
"schedule": "0 0 4 * * *"
138+
},
139+
"sonarr-scan": {
140+
"schedule": "0 30 4 * * *"
141+
},
142+
"download-sync": {
143+
"schedule": "0 * * * * *"
144+
},
145+
"download-sync-reset": {
146+
"schedule": "0 0 1 * * *"
147+
}
148+
}
149+
}

cypress/e2e/discover.cy.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const clickFirstTitleCardInSlider = (sliderTitle: string): void => {
2+
cy.contains('.slider-header', sliderTitle)
3+
.next('[data-testid=media-slider]')
4+
.find('[data-testid=title-card]')
5+
.first()
6+
.trigger('mouseover')
7+
.find('[data-testid=title-card-title]')
8+
.invoke('text')
9+
.then((text) => {
10+
cy.contains('.slider-header', sliderTitle)
11+
.next('[data-testid=media-slider]')
12+
.find('[data-testid=title-card]')
13+
.first()
14+
.click();
15+
cy.get('[data-testid=media-title]').should('contain', text);
16+
});
17+
};
18+
19+
describe('Discover', () => {
20+
beforeEach(() => {
21+
cy.login(Cypress.env('ADMIN_EMAIL'), Cypress.env('ADMIN_PASSWORD'));
22+
cy.visit('/');
23+
});
24+
25+
it('loads a trending item', () => {
26+
clickFirstTitleCardInSlider('Trending');
27+
});
28+
29+
it('loads popular movies', () => {
30+
clickFirstTitleCardInSlider('Popular Movies');
31+
});
32+
33+
it('loads upcoming movies', () => {
34+
clickFirstTitleCardInSlider('Upcoming Movies');
35+
});
36+
37+
it('loads popular series', () => {
38+
clickFirstTitleCardInSlider('Popular Series');
39+
});
40+
41+
it('loads upcoming series', () => {
42+
clickFirstTitleCardInSlider('Upcoming Series');
43+
});
44+
});

cypress/e2e/login.cy.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
describe('Login Page', () => {
2+
it('succesfully logs in as an admin', () => {
3+
cy.login(Cypress.env('ADMIN_EMAIL'), Cypress.env('ADMIN_PASSWORD'));
4+
cy.visit('/');
5+
cy.contains('Recently Added');
6+
});
7+
8+
it('succesfully logs in as a local user', () => {
9+
cy.login(Cypress.env('USER_EMAIL'), Cypress.env('USER_PASSWORD'));
10+
cy.visit('/');
11+
cy.contains('Recently Added');
12+
});
13+
});

cypress/e2e/movie-details.cy.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
describe('Movie Details', () => {
2+
it('loads a movie page', () => {
3+
cy.login(Cypress.env('ADMIN_EMAIL'), Cypress.env('ADMIN_PASSWORD'));
4+
// Try to load minions: rise of gru
5+
cy.visit('/movie/438148');
6+
7+
cy.get('[data-testid=media-title]').should(
8+
'contain',
9+
'Minions: The Rise of Gru (2022)'
10+
);
11+
});
12+
});

cypress/e2e/tv-details.cy.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
describe('TV Details', () => {
2+
it('loads a movie page', () => {
3+
cy.login(Cypress.env('ADMIN_EMAIL'), Cypress.env('ADMIN_PASSWORD'));
4+
// Try to load stranger things
5+
cy.visit('/tv/66732');
6+
7+
cy.get('[data-testid=media-title]').should(
8+
'contain',
9+
'Stranger Things (2016)'
10+
);
11+
});
12+
});

cypress/e2e/user/user-list.cy.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const testUser = {
2+
displayName: 'Test User',
3+
emailAddress: '[email protected]',
4+
password: 'test1234',
5+
};
6+
7+
describe('User List', () => {
8+
beforeEach(() => {
9+
cy.login(Cypress.env('ADMIN_EMAIL'), Cypress.env('ADMIN_PASSWORD'));
10+
});
11+
12+
it('opens the user list from the home page', () => {
13+
cy.visit('/');
14+
15+
cy.get('[data-testid=sidebar-toggle]').click();
16+
cy.get('[data-testid=sidebar-menu-users-mobile]').click();
17+
18+
cy.get('[data-testid=page-header').should('contain', 'User List');
19+
});
20+
21+
it('can find the admin user and friend user in the user list', () => {
22+
cy.visit('/users');
23+
24+
cy.get('[data-testid=user-list-row]').contains(Cypress.env('ADMIN_EMAIL'));
25+
cy.get('[data-testid=user-list-row]').contains(Cypress.env('USER_EMAIL'));
26+
});
27+
28+
it('can create a local user', () => {
29+
cy.visit('/users');
30+
31+
cy.contains('Create Local User').click();
32+
33+
cy.get('[data-testid=modal-title').should('contain', 'Create Local User');
34+
35+
cy.get('#displayName').type(testUser.displayName);
36+
cy.get('#email').type(testUser.emailAddress);
37+
cy.get('#password').type(testUser.password);
38+
39+
cy.intercept('/api/v1/user?take=10&skip=0&sort=displayname').as('user');
40+
41+
cy.get('[data-testid=modal-ok-button').click();
42+
43+
cy.wait('@user');
44+
45+
cy.get('[data-testid=user-list-row]').contains(testUser.emailAddress);
46+
});
47+
48+
it('can delete the created local test user', () => {
49+
cy.visit('/users');
50+
51+
cy.contains('[data-testid=user-list-row]', testUser.emailAddress)
52+
.contains('Delete')
53+
.click();
54+
55+
cy.get('[data-testid=modal-title]').should('contain', 'Delete User');
56+
57+
cy.intercept('/api/v1/user?take=10&skip=0&sort=displayname').as('user');
58+
59+
cy.get('[data-testid=modal-ok-button').should('contain', 'Delete').click();
60+
61+
cy.wait('@user');
62+
63+
cy.get('[data-testid=user-list-row]')
64+
.contains(testUser.emailAddress)
65+
.should('not.exist');
66+
});
67+
});

0 commit comments

Comments
 (0)