pull/37/head
Varun Patil 2022-09-14 11:19:55 -07:00
commit f0f8ecf348
7 changed files with 321 additions and 65 deletions

3
.gitignore vendored
View File

@ -19,3 +19,6 @@ coverage/
.php_cs.cache .php_cs.cache
vendor vendor
memories.tar.gz memories.tar.gz
/test-results/
/playwright-report/
/playwright/.cache/

View File

@ -0,0 +1,16 @@
import { test, expect } from '@playwright/test';
import { login } from './login';
test.beforeEach(login('/folders'));
test.describe('Open', () => {
test('Look for Folders', async ({ page }) => {
expect(await page.locator('.big-icon > .icon-folder').count(), 'Number of folders').toBeGreaterThan(3);
});
test('Open folder', async ({ page }) => {
await page.locator('text=Local').click();
await expect(page).toHaveURL(/http:\/\/localhost:8080\/apps\/memories\/folders\/\.*/);
await page.waitForSelector('img[src^="/core/preview"]');
});
});

16
e2e/login.ts 100644
View File

@ -0,0 +1,16 @@
import { expect, PlaywrightTestArgs } from '@playwright/test';
export function login(route: string) {
return async ({ page }: PlaywrightTestArgs) => {
await page.setViewportSize({ width: 800, height: 600 })
await page.goto('http://localhost:8080/apps/memories' + route)
await page.locator('[placeholder="Username or email"]').click();
await page.locator('[placeholder="Username or email"]').fill('admin');
await page.locator('[placeholder="Username or email"]').press('Tab');
await page.locator('[placeholder="Password"]').fill('admin');
await page.locator('input:has-text("Log in")').click();
await expect(page).toHaveURL('http://localhost:8080/apps/memories' + route);
await page.waitForSelector('img[src^="/core/preview"]');
}
}

View File

@ -0,0 +1,43 @@
import { test, expect } from '@playwright/test';
import { login } from './login';
test.beforeEach(login('/'));
test.describe('Open', () => {
test('Look for Images', async ({ page }) => {
expect(await page.locator('img[src^="/core/preview"]').count(), 'Number of previews').toBeGreaterThan(4);
await page.waitForTimeout(1000);
});
test('Open one image', async ({ page }) => {
await page.locator('div:nth-child(2) > .p-outer > .img-outer > img').first().click();
await page.waitForTimeout(1000);
await page.locator('button:has-text("Close")').first().click();
});
test('Select two images and delete', async ({ page }) => {
const i1 = "div:nth-child(3) > .photo-row > div:nth-child(2) > .p-outer";
const i2 = "div:nth-child(3) > .photo-row > div:nth-child(3) > .p-outer";
const src1 = await page.locator(`${i1} > .img-outer > img`).first().getAttribute('src');
const src2 = await page.locator(`${i2} > .img-outer > img`).first().getAttribute('src');
expect(await page.locator(`img[src="${src1}"]`).count()).toBe(1);
expect(await page.locator(`img[src="${src2}"]`).count()).toBe(1);
await page.locator(`${i1} > .icon-checkmark`).click();
await page.locator(`${i2}`).click();
await page.waitForTimeout(1000);
await page.locator('[aria-label="Delete selection"]').click();
await page.waitForTimeout(4000);
expect(await page.locator(`img[src="${src1}"]`).count()).toBe(0);
expect(await page.locator(`img[src="${src2}"]`).count()).toBe(0);
// refresh page
await page.reload();
await page.waitForSelector('img[src^="/core/preview"]');
expect(await page.locator(`img[src="${src1}"]`).count()).toBe(0);
expect(await page.locator(`img[src="${src2}"]`).count()).toBe(0);
});
});

77
package-lock.json generated
View File

@ -26,7 +26,9 @@
"@nextcloud/eslint-config": "^8.1.2", "@nextcloud/eslint-config": "^8.1.2",
"@nextcloud/stylelint-config": "^2.2.0", "@nextcloud/stylelint-config": "^2.2.0",
"@nextcloud/webpack-vue-config": "^5.3.0", "@nextcloud/webpack-vue-config": "^5.3.0",
"@playwright/test": "^1.25.2",
"@types/url-parse": "^1.4.8", "@types/url-parse": "^1.4.8",
"playwright": "^1.25.2",
"ts-loader": "^9.3.1", "ts-loader": "^9.3.1",
"typescript": "^4.8.3" "typescript": "^4.8.3"
}, },
@ -2372,6 +2374,22 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/@playwright/test": {
"version": "1.25.2",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.25.2.tgz",
"integrity": "sha512-6qPznIR4Fw02OMbqXUPMG6bFFg1hDVNEdihKy0t9K0dmRbus1DyP5Q5XFQhGwEHQkLG5hrSfBuu9CW/foqhQHQ==",
"dev": true,
"dependencies": {
"@types/node": "*",
"playwright-core": "1.25.2"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=14"
}
},
"node_modules/@types/body-parser": { "node_modules/@types/body-parser": {
"version": "1.19.2", "version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
@ -2515,8 +2533,7 @@
"version": "18.7.3", "version": "18.7.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.3.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.3.tgz",
"integrity": "sha512-LJgzOEwWuMTBxHzgBR/fhhBOWrvBjvO+zPteUgbbuQi80rYIZHrk1mNbRUqPZqSLP2H7Rwt1EFLL/tNLD1Xx/w==", "integrity": "sha512-LJgzOEwWuMTBxHzgBR/fhhBOWrvBjvO+zPteUgbbuQi80rYIZHrk1mNbRUqPZqSLP2H7Rwt1EFLL/tNLD1Xx/w==",
"dev": true, "dev": true
"peer": true
}, },
"node_modules/@types/normalize-package-data": { "node_modules/@types/normalize-package-data": {
"version": "2.4.1", "version": "2.4.1",
@ -8507,6 +8524,34 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/playwright": {
"version": "1.25.2",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.25.2.tgz",
"integrity": "sha512-RwMB5SFRV/8wSfK+tK8ycpqdzORvoqUNz9DUeRfSgZFrZej5uuBl9wFjWcc+OkXFEtaPmx1acAVGG7hA4IJ1kg==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
"playwright-core": "1.25.2"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=14"
}
},
"node_modules/playwright-core": {
"version": "1.25.2",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.25.2.tgz",
"integrity": "sha512-0yTbUE9lIddkEpLHL3u8PoCL+pWiZtj5A/j3U7YoNjcmKKDGBnCrgHJMzwd2J5vy6l28q4ki3JIuz7McLHhl1A==",
"dev": true,
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=14"
}
},
"node_modules/postcss": { "node_modules/postcss": {
"version": "8.4.16", "version": "8.4.16",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz",
@ -13669,6 +13714,16 @@
"fastq": "^1.6.0" "fastq": "^1.6.0"
} }
}, },
"@playwright/test": {
"version": "1.25.2",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.25.2.tgz",
"integrity": "sha512-6qPznIR4Fw02OMbqXUPMG6bFFg1hDVNEdihKy0t9K0dmRbus1DyP5Q5XFQhGwEHQkLG5hrSfBuu9CW/foqhQHQ==",
"dev": true,
"requires": {
"@types/node": "*",
"playwright-core": "1.25.2"
}
},
"@types/body-parser": { "@types/body-parser": {
"version": "1.19.2", "version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
@ -13812,8 +13867,7 @@
"version": "18.7.3", "version": "18.7.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.3.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.3.tgz",
"integrity": "sha512-LJgzOEwWuMTBxHzgBR/fhhBOWrvBjvO+zPteUgbbuQi80rYIZHrk1mNbRUqPZqSLP2H7Rwt1EFLL/tNLD1Xx/w==", "integrity": "sha512-LJgzOEwWuMTBxHzgBR/fhhBOWrvBjvO+zPteUgbbuQi80rYIZHrk1mNbRUqPZqSLP2H7Rwt1EFLL/tNLD1Xx/w==",
"dev": true, "dev": true
"peer": true
}, },
"@types/normalize-package-data": { "@types/normalize-package-data": {
"version": "2.4.1", "version": "2.4.1",
@ -18490,6 +18544,21 @@
} }
} }
}, },
"playwright": {
"version": "1.25.2",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.25.2.tgz",
"integrity": "sha512-RwMB5SFRV/8wSfK+tK8ycpqdzORvoqUNz9DUeRfSgZFrZej5uuBl9wFjWcc+OkXFEtaPmx1acAVGG7hA4IJ1kg==",
"dev": true,
"requires": {
"playwright-core": "1.25.2"
}
},
"playwright-core": {
"version": "1.25.2",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.25.2.tgz",
"integrity": "sha512-0yTbUE9lIddkEpLHL3u8PoCL+pWiZtj5A/j3U7YoNjcmKKDGBnCrgHJMzwd2J5vy6l28q4ki3JIuz7McLHhl1A==",
"dev": true
},
"postcss": { "postcss": {
"version": "8.4.16", "version": "8.4.16",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz",

View File

@ -1,63 +1,65 @@
{ {
"name": "memories", "name": "memories",
"description": "A better photos app", "description": "A better photos app",
"version": "1.0.1", "version": "1.0.1",
"author": "Varun Patil <radialapps@gmail.com>", "author": "Varun Patil <radialapps@gmail.com>",
"contributors": [ "contributors": [
"Varun Patil <radialapps@gmail.com>" "Varun Patil <radialapps@gmail.com>"
], ],
"keywords": [ "keywords": [
"nextcloud", "nextcloud",
"app", "app",
"dev", "dev",
"vuejs" "vuejs"
], ],
"bugs": { "bugs": {
"url": "https://github.com/pulsejet/memories/issues" "url": "https://github.com/pulsejet/memories/issues"
}, },
"repository": { "repository": {
"url": "https://github.com/pulsejet/memories.git", "url": "https://github.com/pulsejet/memories.git",
"type": "git" "type": "git"
}, },
"homepage": "https://github.com/pulsejet/memories", "homepage": "https://github.com/pulsejet/memories",
"license": "agpl", "license": "agpl",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "NODE_ENV=production webpack --progress --config webpack.js", "build": "NODE_ENV=production webpack --progress --config webpack.js",
"dev": "NODE_ENV=development webpack --progress --config webpack.js", "dev": "NODE_ENV=development webpack --progress --config webpack.js",
"watch": "NODE_ENV=development webpack --progress --watch --config webpack.js", "watch": "NODE_ENV=development webpack --progress --watch --config webpack.js",
"lint": "eslint --ext .js,.vue src", "lint": "eslint --ext .js,.vue src",
"lint:fix": "eslint --ext .js,.vue src --fix", "lint:fix": "eslint --ext .js,.vue src --fix",
"stylelint": "stylelint src", "stylelint": "stylelint src",
"stylelint:fix": "stylelint src --fix" "stylelint:fix": "stylelint src --fix"
}, },
"dependencies": { "dependencies": {
"@nextcloud/l10n": "^1.6.0", "@nextcloud/l10n": "^1.6.0",
"@nextcloud/vue": "^6.0.0-beta.6", "@nextcloud/vue": "^6.0.0-beta.6",
"path-posix": "^1.0.0", "path-posix": "^1.0.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"vue": "^2.7.10", "vue": "^2.7.10",
"vue-class-component": "^7.2.6", "vue-class-component": "^7.2.6",
"vue-property-decorator": "^9.1.2", "vue-property-decorator": "^9.1.2",
"vue-router": "^3.5.4", "vue-router": "^3.5.4",
"vue-virtual-scroller": "^1.0.10", "vue-virtual-scroller": "^1.0.10",
"webdav": "^4.11.0" "webdav": "^4.11.0"
}, },
"browserslist": [ "browserslist": [
"extends @nextcloud/browserslist-config" "extends @nextcloud/browserslist-config"
], ],
"engines": { "engines": {
"node": ">=14.0.0", "node": ">=14.0.0",
"npm": ">=7.0.0" "npm": ">=7.0.0"
}, },
"devDependencies": { "devDependencies": {
"@nextcloud/babel-config": "^1.0.0", "@nextcloud/babel-config": "^1.0.0",
"@nextcloud/browserslist-config": "^2.3.0", "@nextcloud/browserslist-config": "^2.3.0",
"@nextcloud/eslint-config": "^8.1.2", "@nextcloud/eslint-config": "^8.1.2",
"@nextcloud/stylelint-config": "^2.2.0", "@nextcloud/stylelint-config": "^2.2.0",
"@nextcloud/webpack-vue-config": "^5.3.0", "@nextcloud/webpack-vue-config": "^5.3.0",
"@types/url-parse": "^1.4.8", "@playwright/test": "^1.25.2",
"ts-loader": "^9.3.1", "@types/url-parse": "^1.4.8",
"typescript": "^4.8.3" "playwright": "^1.25.2",
} "ts-loader": "^9.3.1",
"typescript": "^4.8.3"
}
} }

View File

@ -0,0 +1,107 @@
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
testDir: './e2e',
/* Maximum time one test can run for. */
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000
},
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://localhost:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
},
},
// {
// name: 'firefox',
// use: {
// ...devices['Desktop Firefox'],
// },
// },
// {
// name: 'webkit',
// use: {
// ...devices['Desktop Safari'],
// },
// },
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: {
// ...devices['Pixel 5'],
// },
// },
// {
// name: 'Mobile Safari',
// use: {
// ...devices['iPhone 12'],
// },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: {
// channel: 'msedge',
// },
// },
// {
// name: 'Google Chrome',
// use: {
// channel: 'chrome',
// },
// },
],
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',
/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// port: 3000,
// },
};
export default config;