Skip to content

Commit

Permalink
Fix link resolving in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Feb 10, 2022
1 parent 84b773c commit 21f482c
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 25 deletions.
8 changes: 4 additions & 4 deletions packages/web-app-files/src/views/PrivateLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="oc-card oc-border oc-rounded oc-position-center oc-text-center oc-width-large">
<template v-if="loading">
<div class="oc-card-header">
<h2>
<h2 key="private-link-loading">
<translate>Resolving private link…</translate>
</h2>
</div>
Expand All @@ -13,12 +13,12 @@
</div>
</template>
<template v-else-if="errorMessage">
<div class="oc-card-header">
<h2>
<div class="oc-card-header oc-link-resolve-error-title">
<h2 key="private-link-error">
<translate>An error occurred while resolving the private link</translate>
</h2>
</div>
<div class="oc-card-body oc-link-resolve-error">
<div class="oc-card-body oc-link-resolve-error-message">
<p class="oc-text-lead">{{ errorMessage }}</p>
</div>
</template>
Expand Down
8 changes: 4 additions & 4 deletions packages/web-app-files/src/views/PublicLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="oc-card oc-border oc-rounded oc-position-center oc-text-center oc-width-large">
<template v-if="loading">
<div class="oc-card-header">
<h2>
<h2 key="public-link-loading">
<translate>Loading public link…</translate>
</h2>
</div>
Expand All @@ -13,12 +13,12 @@
</div>
</template>
<template v-else-if="errorMessage">
<div class="oc-card-header">
<h2>
<div class="oc-card-header oc-link-resolve-error-title">
<h2 key="public-link-error">
<translate>An error occurred while loading the public link</translate>
</h2>
</div>
<div class="oc-card-body oc-link-resolve-error">
<div class="oc-card-body oc-link-resolve-error-message">
<p class="oc-text-lead">{{ errorMessage }}</p>
</div>
</template>
Expand Down
4 changes: 2 additions & 2 deletions packages/web-app-files/tests/unit/views/PrivateLink.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const $route = {
const selectors = {
pageTitle: 'h1.oc-invisible-sr',
loader: '.oc-card-body',
errorMessage: '.oc-link-resolve-error'
errorTitle: '.oc-link-resolve-error-title'
}

describe('PrivateLink view', () => {
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('PrivateLink view', () => {

await new Promise((resolve) => {
setTimeout(() => {
expect(wrapper.find(selectors.errorMessage)).toMatchSnapshot()
expect(wrapper.find(selectors.errorTitle)).toMatchSnapshot()
resolve()
}, 1)
})
Expand Down
8 changes: 4 additions & 4 deletions packages/web-app-files/tests/unit/views/PublicLink.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const selectors = {
cardFooter: '.oc-card-footer',
cardBody: '.oc-card-body',
submitButton: '.oc-login-authorize-button',
errorMessage: '.oc-link-resolve-error',
errorTitle: '.oc-link-resolve-error-title',
publicLinkPasswordRequired: 'form > .oc-card-title'
}

Expand Down Expand Up @@ -49,7 +49,7 @@ describe('PublicLink', () => {
expect(loading).toMatchSnapshot()
})
it('should not display the error message', () => {
expect(wrapper.find(selectors.errorMessage).exists()).toBeFalsy()
expect(wrapper.find(selectors.errorTitle).exists()).toBeFalsy()
})
it('should not display the password required form', () => {
expect(wrapper.find(selectors.publicLinkPasswordRequired).exists()).toBeFalsy()
Expand All @@ -67,8 +67,8 @@ describe('PublicLink', () => {
const wrapper = getWrapper({ loading: false })
await wrapper.setData({ errorMessage: 'some-error-message' })

expect(wrapper.find(selectors.errorMessage).exists()).toBeTruthy()
expect(wrapper.find(selectors.errorMessage)).toMatchSnapshot()
expect(wrapper.find(selectors.errorTitle).exists()).toBeTruthy()
expect(wrapper.find(selectors.errorTitle)).toMatchSnapshot()
})

describe('and when "passwordRequired" is set as true', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ exports[`PrivateLink view when the view is still loading should display the load
`;

exports[`PrivateLink view when there was an error should display the error message 1`] = `
<div class="oc-card-body oc-link-resolve-error">
<p class="oc-text-lead">Error: some error</p>
<div class="oc-card-header oc-link-resolve-error-title">
<h2>
<translate-stub tag="span">An error occurred while resolving the private link</translate-stub>
</h2>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ exports[`PublicLink when the view is not loading anymore and when "passwordRequi
`;

exports[`PublicLink when the view is not loading anymore should display the error message if "errorMessage" is not empty 1`] = `
<div class="oc-card-body oc-link-resolve-error">
<p class="oc-text-lead">some-error-message</p>
<div class="oc-card-header oc-link-resolve-error-title">
<h2>
<translate-stub tag="span">An error occurred while loading the public link</translate-stub>
</h2>
</div>
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ Feature: Access private link
Given user "Brian" has been created with default attributes and without skeleton files in the server
And user "Brian" has logged in using the webUI
When the user navigates to the private link created by user "Alice" for file "lorem.txt"
Then the user should see the following error message on the login card dialog
Then the user should see the following error message on the link resolve page
"""
An error occurred while resolving the private link
Error: Unknown error
"""


Scenario: Access the private link anonymously
When an anonymous user tries to navigate to the private link created by user "Alice" for file "lorem.txt"
Then the user should be redirected to the IdP login page
4 changes: 2 additions & 2 deletions tests/acceptance/pageObjects/publicLinkPasswordPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ module.exports = {
selector: "//div[@class='oc-login-card oc-position-center']//span[.='Loading public link…']",
locateStrategy: 'xpath'
},
loginCardDialogBox: {
selector: '.oc-login-card-body'
linkResolveErrorTitle: {
selector: '.oc-link-resolve-error-title'
},
publicLinkPasswordSection: {
selector:
Expand Down
6 changes: 3 additions & 3 deletions tests/acceptance/stepDefinitions/generalContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ Then(
)

Then(
'the user should see the following error message on the login card dialog',
'the user should see the following error message on the link resolve page',
function (message) {
return client.page
.publicLinkPasswordPage()
.waitForElementVisible('@loginCardDialogBox')
.expect.element('@loginCardDialogBox')
.waitForElementVisible('@linkResolveErrorTitle')
.expect.element('@linkResolveErrorTitle')
.text.to.equal(message)
}
)
Expand Down

0 comments on commit 21f482c

Please sign in to comment.