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 11, 2022
1 parent 84b773c commit 078862e
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 36 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
10 changes: 5 additions & 5 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 Expand Up @@ -88,7 +88,7 @@ export default {
return this.$gettext('Enter password for public link')
}
},
mounted() {
created() {
this.resolvePublicLink()
},
methods: {
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Feature: Session storage for public link
And user "Alice" has created file "simple-folder/lorem.txt" in the server
And user "Alice" has shared folder "simple-folder" with link with "read" permissions and password "pass123" in the server
When the public uses the webUI to access the last public link created by user "Alice" with password "pass123"
And user "Alice" changes the password of last public link to "newpass" using the Sharing API in the server
Then file "lorem.txt" should be listed on the webUI
And user "Alice" changes the password of last public link to "newpass" using the Sharing API in the server
When the user reloads the current page of the webUI
Then the password input for the public link should appear on the webUI
When the user accesses the public link with password "newpass" using the webUI
Expand All @@ -49,8 +49,8 @@ Feature: Session storage for public link
Given user "Alice" has created file "lorem.txt" in the server
And user "Alice" has shared folder "lorem.txt" with link with "read" permissions and password "pass123" in the server
When the public uses the webUI to access the last public link created by user "Alice" with password "pass123"
And user "Alice" changes the password of last public link to "newpass" using the Sharing API in the server
Then file "lorem.txt" should be listed on the webUI
And user "Alice" changes the password of last public link to "newpass" using the Sharing API in the server
When the user reloads the current page of the webUI
Then the password input for the public link should appear on the webUI
When the user accesses the public link with password "newpass" using the webUI
Expand Down
13 changes: 4 additions & 9 deletions tests/acceptance/pageObjects/publicLinkPasswordPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,14 @@ module.exports = {
selector: '.oc-login-authorize-button'
},
resourceProtectedText: {
selector: '//h2[@class="oc-login-card-title"]/span',
selector: '//*[@class="oc-card-header"]',
locateStrategy: 'xpath'
},
loadingPublicLink: {
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:
'//div[@class="oc-login-card-body"]//h2[@class="oc-login-card-title"]/span[text()="This resource is password-protected."]',
selector: '//*[@class="oc-card-header"]//*[text()="This resource is password-protected"]',
locateStrategy: 'xpath'
}
}
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
2 changes: 1 addition & 1 deletion tests/acceptance/stepDefinitions/publicLinkContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Then('the public should not get access to the publicly shared file', async funct
.submitLinkPasswordForm() // form is submitted as password input is filled in the step before this particular step in 'when' part
.getResourceAccessDeniedMsg()
return assert.strictEqual(
'This resource is password-protected.',
'This resource is password-protected',
message,
'Resource protected message invalid, Found: ',
message
Expand Down

0 comments on commit 078862e

Please sign in to comment.