Skip to content

Commit eabb193

Browse files
committed
chore: extend E2E tests
-e Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
1 parent ec9eeb2 commit eabb193

1 file changed

Lines changed: 56 additions & 5 deletions

File tree

cypress/e2e/core/setup.ts

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@ describe('Can install Nextcloud', { testIsolation: true, retries: 0 }, () => {
3232
sharedSetup()
3333
})
3434

35+
it('Sqlite - Install recommended apps (success)', () => {
36+
cy.visit('/')
37+
cy.get('[data-cy-setup-form]').should('be.visible')
38+
cy.get('[data-cy-setup-form-field="dbtype-sqlite"] input').check({ force: true })
39+
40+
sharedSetup('install-success')
41+
})
42+
43+
it('Sqlite - Install recommended apps (failure)', () => {
44+
cy.visit('/')
45+
cy.get('[data-cy-setup-form]').should('be.visible')
46+
cy.get('[data-cy-setup-form-field="dbtype-sqlite"] input').check({ force: true })
47+
48+
sharedSetup('install-failure')
49+
})
50+
3551
it('MySQL', () => {
3652
cy.visit('/')
3753
cy.get('[data-cy-setup-form]').should('be.visible')
@@ -113,6 +129,10 @@ describe('Can install Nextcloud', { testIsolation: true, retries: 0 }, () => {
113129

114130
/**
115131
* Shared admin setup function for the Nextcloud setup
132+
*
133+
* @param mode How to handle the recommended apps screen at the end of the
134+
* install assistant: skip it, exercise the install button with a
135+
* stubbed success response, or stub a failure response.
116136
*/
117137
function sharedSetup(mode: RecommendedAppsMode = 'skip') {
118138
const randAdmin = 'admin-' + Math.random().toString(36).substring(2, 15)
@@ -143,10 +163,41 @@ function sharedSetup(mode: RecommendedAppsMode = 'skip') {
143163
.should('be.visible')
144164
})
145165

146-
// Skip the setup apps
147-
cy.get('[data-cy-setup-recommended-apps-skip]').click()
166+
if (mode === 'skip') {
167+
// Skip the setup apps
168+
cy.get('[data-cy-setup-recommended-apps-skip]').click()
148169

149-
// Go to files
150-
cy.visit('/apps/files/')
151-
cy.get('[data-cy-files-content]').should('be.visible')
170+
// Go to files
171+
cy.visit('/apps/files/')
172+
cy.get('[data-cy-files-content]').should('be.visible')
173+
return
174+
}
175+
176+
// Stub the bulk enable endpoint so we exercise the frontend flow without
177+
// hitting the real app store.
178+
cy.intercept('POST', '**/settings/apps/enable', mode === 'install-success'
179+
? { statusCode: 200, body: { data: { update_required: false } } }
180+
: { statusCode: 500, body: { data: { message: 'Forced failure' } } }).as('enableApps')
181+
182+
cy.get('[data-cy-setup-recommended-apps-install]').click()
183+
184+
// The strict password-confirmation dialog must appear and must result in a
185+
// Basic auth header on the enable request.
186+
cy.findByRole('dialog', { name: 'Authentication required' })
187+
.should('be.visible')
188+
handlePasswordConfirmation(randAdmin)
189+
cy.wait('@enableApps')
190+
.its('request.headers.authorization')
191+
.should('match', /^Basic /)
192+
193+
if (mode === 'install-success') {
194+
// Frontend redirects via window.location to the default page.
195+
cy.location('pathname', { timeout: 10000 })
196+
.should('not.include', '/core/apps/recommended')
197+
} else {
198+
// Stay on the recommended-apps page and surface the per-app error state.
199+
cy.location('pathname').should('include', '/core/apps/recommended')
200+
cy.get('[data-cy-setup-recommended-apps]')
201+
.should('contain.text', 'App download or installation failed')
202+
}
152203
}

0 commit comments

Comments
 (0)