Skip to content

Commit

Permalink
e2e test. check deleted link (#9010)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScharfViktor authored May 12, 2023
1 parent b8349ea commit 6707bbe
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
9 changes: 5 additions & 4 deletions tests/e2e/cucumber/steps/ui/public.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { DataTable, Then, When } from '@cucumber/cucumber'
import { expect } from '@playwright/test'
import { kebabCase } from 'lodash'
import { DateTime } from 'luxon'
import { World } from '../../environment'
import { objects } from '../../../support'
import { processDelete, processDownload } from './resources'
import { createdLinkStore } from '../../../support/store'

When(
'{string} opens the public link {string}',
Expand Down Expand Up @@ -132,8 +130,11 @@ When(

Then(
'{string} should not be able to open the old link {string}',
function (this: World, stepUser: string, name: string): void {
expect(createdLinkStore.has(name)).toBe(false)
async function (this: World, stepUser: string, name: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const pageObject = new objects.applicationFiles.page.Public({ page })
const { url } = this.linksEnvironment.getLink({ name })
await pageObject.expectThatLinkIsDeleted({ url })
}
)

Expand Down
1 change: 0 additions & 1 deletion tests/e2e/cucumber/steps/ui/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ When(
Then(
'the following resource(s) should contain the following tag(s) in the files list for user {string}',
async function (this: World, stepUser: string, stepTable: DataTable): Promise<void> {
console.log('stepUser', stepUser)
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
for (const { resource, tags } of stepTable.hashes()) {
Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/support/objects/app-files/link/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ export class Link {
async delete(args: Omit<deleteLinkArgs, 'page'>): Promise<void> {
const startUrl = this.#page.url()
await deleteLink({ ...args, page: this.#page })
this.#linksEnvironment.deleteLink({
key: args.name
})
await this.#page.goto(startUrl)
}

Expand Down
7 changes: 6 additions & 1 deletion tests/e2e/support/objects/app-files/page/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
renameResource,
renameResourceArgs,
uploadResource,
uploadResourceArgs
uploadResourceArgs,
expectThatPublicLinkIsDeleted
} from '../resource/actions'

const passwordInput = 'input[type="password"]'
Expand Down Expand Up @@ -85,4 +86,8 @@ export class Public {
await deleteResource({ ...args, page: this.#page })
await this.#page.goto(startUrl)
}

async expectThatLinkIsDeleted({ url }: { url: string }): Promise<void> {
await expectThatPublicLinkIsDeleted({ page: this.#page, url })
}
}
12 changes: 12 additions & 0 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const tagFormInput = '#tags-form input'
const compareDialogConfirmBtn = '.compare-save-dialog-confirm-btn'
const resourcesAsTiles = '#files-view .oc-tiles'
const fileVersionSidebar = '#oc-file-versions-sidebar'
const noLinkMessage = '#web .oc-link-resolve-error-message'

export const clickResource = async ({
page,
Expand Down Expand Up @@ -1037,3 +1038,14 @@ export const checkThatFileVersionIsNotAvailable = async (
await sidebar.openPanel({ page, name: 'versions' })
await expect(page.locator(fileVersionSidebar)).toHaveText('No Versions available for this file')
}

export const expectThatPublicLinkIsDeleted = async (args): Promise<void> => {
const { page, url } = args
await Promise.all([
page.waitForResponse((resp) => resp.status() === 404 && resp.request().method() === 'PROPFIND'),
page.goto(url)
])
await expect(page.locator(noLinkMessage)).toHaveText(
'Error: The resource could not be located, it may not exist anymore.'
)
}

0 comments on commit 6707bbe

Please sign in to comment.