diff --git a/.gitignore b/.gitignore index c04f4a24..972d4843 100644 --- a/.gitignore +++ b/.gitignore @@ -106,3 +106,4 @@ sw.* /playwright-report/ /blob-report/ /playwright/.cache/ +.auth/ diff --git a/.pnp.cjs b/.pnp.cjs index 33c9d076..4ed27fa5 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -44,6 +44,7 @@ const RAW_RUNTIME_STATE = ["@vueuse/core", "npm:10.11.1"],\ ["axios", "npm:1.7.4"],\ ["dayjs", "npm:1.11.12"],\ + ["dotenv", "npm:16.4.5"],\ ["eslint", "npm:8.57.0"],\ ["eslint-config-prettier", "virtual:f38e57d791791749fcbabd309fca608b4b94dece2d82ce843f1a41fa3116db596a20c099e6de2af31c105fe4ac076cf46376e7075977c7d2a35411de7ab0cc23#npm:9.1.0"],\ ["eslint-config-standard", "virtual:f38e57d791791749fcbabd309fca608b4b94dece2d82ce843f1a41fa3116db596a20c099e6de2af31c105fe4ac076cf46376e7075977c7d2a35411de7ab0cc23#npm:17.1.0"],\ @@ -6134,6 +6135,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["dotenv", [\ + ["npm:16.4.5", {\ + "packageLocation": "./.yarn/cache/dotenv-npm-16.4.5-bcb20eb95d-55a3134601.zip/node_modules/dotenv/",\ + "packageDependencies": [\ + ["dotenv", "npm:16.4.5"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["eastasianwidth", [\ ["npm:0.2.0", {\ "packageLocation": "./.yarn/cache/eastasianwidth-npm-0.2.0-c37eb16bd1-9b1d3e1bae.zip/node_modules/eastasianwidth/",\ @@ -9661,6 +9671,7 @@ const RAW_RUNTIME_STATE = ["@vueuse/core", "npm:10.11.1"],\ ["axios", "npm:1.7.4"],\ ["dayjs", "npm:1.11.12"],\ + ["dotenv", "npm:16.4.5"],\ ["eslint", "npm:8.57.0"],\ ["eslint-config-prettier", "virtual:f38e57d791791749fcbabd309fca608b4b94dece2d82ce843f1a41fa3116db596a20c099e6de2af31c105fe4ac076cf46376e7075977c7d2a35411de7ab0cc23#npm:9.1.0"],\ ["eslint-config-standard", "virtual:f38e57d791791749fcbabd309fca608b4b94dece2d82ce843f1a41fa3116db596a20c099e6de2af31c105fe4ac076cf46376e7075977c7d2a35411de7ab0cc23#npm:17.1.0"],\ diff --git a/.yarn/cache/dotenv-npm-16.4.5-bcb20eb95d-55a3134601.zip b/.yarn/cache/dotenv-npm-16.4.5-bcb20eb95d-55a3134601.zip new file mode 100644 index 00000000..37a9baf4 Binary files /dev/null and b/.yarn/cache/dotenv-npm-16.4.5-bcb20eb95d-55a3134601.zip differ diff --git a/e2e/example.spec.ts b/e2e/example.spec.ts deleted file mode 100644 index a5f148ea..00000000 --- a/e2e/example.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { test, expect } from '@playwright/test' - -test('has title', async ({ page }) => { - await page.goto('https://playwright.dev/') - - // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/Playwright/) -}) - -test('get started link', async ({ page }) => { - await page.goto('https://playwright.dev/') - - // Click the get started link. - await page.getByRole('link', { name: 'Get started' }).click() - - // Expects page to have a heading with the name of Installation. - await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible() -}) diff --git a/e2e/find.spec.ts b/e2e/find.spec.ts new file mode 100644 index 00000000..c66cba6b --- /dev/null +++ b/e2e/find.spec.ts @@ -0,0 +1,30 @@ +import { test, expect } from '@playwright/test' + +test('test', async ({ page }) => { + await page.goto('https://reims2.app/find') + await page.getByLabel('Category').fill('m') + await page.getByLabel('Category').press('Enter') + + await page.getByLabel('Sphere').first().fill('1.2') + await page.getByLabel('Sphere').first().press('Enter') + await expect(page.getByLabel('Sphere').first()).toHaveValue('1.25') + + await page.getByLabel('Cylinder').first().fill('1.7') + + await page.getByLabel('Axis').first().fill('001') + + await page.getByLabel('Additional').first().fill('1') + await page.getByLabel('Additional').first().press('Enter') + await expect(page.getByLabel('Additional').first()).toHaveValue('1.00') + await expect(page.getByLabel('Additional').nth(1)).toHaveValue('1.00') + + await page.locator('#input-30').fill('2.0') + + await page.locator('#input-32').fill('1.5') + + await page.locator('#input-34').fill('002') + + await page.locator('#input-36').press('Enter') + + await expect(page.getByRole('main')).toContainText('SKU 0926') +}) diff --git a/e2e/login.setup.ts b/e2e/login.setup.ts new file mode 100644 index 00000000..7017bcc8 --- /dev/null +++ b/e2e/login.setup.ts @@ -0,0 +1,17 @@ +import { test, expect } from '@playwright/test' + +const authFile = 'e2e/.auth/user.json' +const PASSWORD = process.env.REIMS_PASSWORD as string + +test('test', async ({ page }) => { + await page.goto('https://reims2.app/') + await page.getByRole('link', { name: 'Open REIMS2' }).click() + await page.getByLabel('Username').fill('reims') + await page.getByLabel('Password').fill(PASSWORD) + await page.getByLabel('Password').press('Enter') + await page.waitForURL('**/find') + await expect(page.getByRole('link', { name: 'REIMS Santa Ana' })).toBeInViewport() + + // await expect(page.locator('div').filter({ hasText: 'Setting up REIMS2' }).nth(2)).toBeVisible() + await page.context().storageState({ path: authFile }) +}) diff --git a/package.json b/package.json index 13b0c528..4460553b 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "@vitest/coverage-v8": "2.0.5", "@vitest/ui": "2.0.5", "@vue/eslint-config-typescript": "13.0.0", + "dotenv": "^16.4.5", "eslint": "8.57.0", "eslint-config-prettier": "9.1.0", "eslint-config-standard": "17.1.0", diff --git a/playwright.config.ts b/playwright.config.ts index d51cebad..a146d943 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,11 +1,7 @@ import { defineConfig, devices } from '@playwright/test' +import dotenv from 'dotenv' -/** - * Read environment variables from file. - * https://github.com/motdotla/dotenv - */ -// import dotenv from 'dotenv'; -// dotenv.config({ path: path.resolve(__dirname, '.env') }); +dotenv.config() /** * See https://playwright.dev/docs/test-configuration. @@ -33,19 +29,35 @@ export default defineConfig({ /* Configure projects for major browsers */ projects: [ + { + name: 'setup', + testMatch: /.*\.setup\.ts/, + }, { name: 'chromium', - use: { ...devices['Desktop Chrome'] }, + use: { + ...devices['Desktop Chrome'], + storageState: 'e2e/.auth/user.json', + }, + dependencies: ['setup'], }, { name: 'firefox', - use: { ...devices['Desktop Firefox'] }, + use: { + ...devices['Desktop Firefox'], + storageState: 'e2e/.auth/user.json', + }, + dependencies: ['setup'], }, { name: 'webkit', - use: { ...devices['Desktop Safari'] }, + use: { + ...devices['Desktop Safari'], + storageState: 'e2e/.auth/user.json', + }, + dependencies: ['setup'], }, /* Test against mobile viewports. */ diff --git a/yarn.lock b/yarn.lock index 0027c252..03793a69 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4208,6 +4208,13 @@ __metadata: languageName: node linkType: hard +"dotenv@npm:^16.4.5": + version: 16.4.5 + resolution: "dotenv@npm:16.4.5" + checksum: 10/55a3134601115194ae0f924e54473459ed0d9fc340ae610b676e248cca45aa7c680d86365318ea964e6da4e2ea80c4514c1adab5adb43d6867fb57ff068f95c8 + languageName: node + linkType: hard + "eastasianwidth@npm:^0.2.0": version: 0.2.0 resolution: "eastasianwidth@npm:0.2.0" @@ -7358,6 +7365,7 @@ __metadata: "@vueuse/core": "npm:10.11.1" axios: "npm:1.7.4" dayjs: "npm:1.11.12" + dotenv: "npm:^16.4.5" eslint: "npm:8.57.0" eslint-config-prettier: "npm:9.1.0" eslint-config-standard: "npm:17.1.0"