diff --git a/.github/workflows-disabled/end-to-end-tests.yml b/.github/workflows-disabled/end-to-end-tests.yml deleted file mode 100644 index 8d1ac02c10..0000000000 --- a/.github/workflows-disabled/end-to-end-tests.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: End-to-end tests -on: - push: - branches: - - master - pull_request: - branches: - - master -jobs: - cypress-run: - runs-on: ubuntu-16.04 - steps: - - name: Checkout - uses: actions/checkout@v1 - # Install NPM dependencies, cache them correctly - # and run all Cypress tests - - name: Cypress run - uses: cypress-io/github-action@v2 - with: - config: baseUrl=https://ccsearch-dev.creativecommons.org diff --git a/src/components/ImageGrid/ImageCell.vue b/src/components/ImageGrid/ImageCell.vue index 1627858404..d717a25849 100644 --- a/src/components/ImageGrid/ImageCell.vue +++ b/src/components/ImageGrid/ImageCell.vue @@ -8,7 +8,7 @@
{ // Go to http://localhost:8444/ await page.goto('/') @@ -16,7 +16,6 @@ test('can change type and search for audio/modification from homepage', async ({ await page.fill('[placeholder="Search all content"]', 'cat') // Click button:has-text("Search") await page.click('button:has-text("Search")') - const BASE_URL = context._options.baseURL - const expectedUrl = BASE_URL + '/search/audio?q=cat&license_type=modification' + const expectedUrl = baseURL + '/search/audio?q=cat&license_type=modification' await expect(page).toHaveURL(expectedUrl) }) diff --git a/test/e2e/image-detail.spec.js b/test/e2e/image-detail.spec.js new file mode 100644 index 0000000000..b90a62c8da --- /dev/null +++ b/test/e2e/image-detail.spec.js @@ -0,0 +1,28 @@ +const { test, expect } = require('@playwright/test') + +test.beforeEach(async ({ context, page }) => { + // Block any image request for each test in this file. + await context.route(/\.(png|jpeg|jpg|svg)$/, (route) => route.abort()) + + // Test in a custom image detail page, it should apply the same for any image. + // TODO: Make these tests independent of the live API. + await page.goto('image/e9d97a98-621b-4ec2-bf70-f47a74380452') +}) + +test('shows the author and title of the image', async ({ page }) => { + const author = page.locator('a[aria-label^="author"]') + await expect(author).toBeVisible() + const imgTitle = page.locator('h1') + await expect(imgTitle).toBeVisible() +}) + +test('shows the main image with its title as alt text', async ({ page }) => { + const imgTitle = await page.locator('h1').innerText() + const img = page.locator('img[class="photo_image"]') + await expect(img).toBeVisible() + await expect(img).toHaveAttribute('alt', imgTitle) +}) + +test('does not show back to search results breadcrumb', async ({ page }) => { + await expect(page.locator('text="Back to search results"')).not.toBeVisible() +}) diff --git a/test/e2e/search.spec.js b/test/e2e/search.spec.js index aec767e8ad..3560b9fe55 100644 --- a/test/e2e/search.spec.js +++ b/test/e2e/search.spec.js @@ -55,3 +55,13 @@ test('shows search result metadata', async ({ page }) => { // All search results have been shown, cannot load more await expect(loadMoreButton).toHaveCount(0) }) + +test('navigates to the image detail page correctly', async ({ page }) => { + await page.goto('/search/image?q=honey') + const figure = page.locator('figure').first() + const imgTitle = await figure.locator('img').getAttribute('alt') + await figure.click() + await expect(page.locator('h1')).toHaveText(imgTitle) + // Renders the breadcrumb link + await expect(page.locator('text="Back to search results"')).toBeVisible() +}) diff --git a/test/unit/specs/components/ImageDetails/photo-details.spec.js b/test/unit/specs/components/ImageDetails/photo-details.spec.js index 1f4fc5ebc6..b99971fe02 100644 --- a/test/unit/specs/components/ImageDetails/photo-details.spec.js +++ b/test/unit/specs/components/ImageDetails/photo-details.spec.js @@ -110,11 +110,6 @@ describe('PhotoDetails', () => { expect(wrapper.html()).toContain(props.image.title) }) - // it('renders creator name', () => { - // const wrapper = render(PhotoDetails, options) - // expect(wrapper.html()).toContain(props.image.creator) - // }) - it('redirects back when clicking on the back to results link', async () => { const routerMock = { push: jest.fn(), diff --git a/test/unit/specs/components/search-grid-cell.spec.js b/test/unit/specs/components/search-grid-cell.spec.js index 30595a816c..cd5fe3cf6b 100644 --- a/test/unit/specs/components/search-grid-cell.spec.js +++ b/test/unit/specs/components/search-grid-cell.spec.js @@ -5,6 +5,7 @@ describe('SearchGridCell', () => { const props = { image: { id: 0, + license: 'by', title: 'foo', provider: 'flickr', url: 'foo.bar',