mockaton 8.1.2 → 8.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,14 +2,19 @@
2
2
  "name": "mockaton",
3
3
  "description": "A deterministic server-side for developing and testing frontend clients",
4
4
  "type": "module",
5
- "version": "8.1.2",
5
+ "version": "8.1.3",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",
9
9
  "repository": "https://github.com/ericfortis/mockaton",
10
10
  "scripts": {
11
- "test": "node --test",
11
+ "test": "node --test src/**.test.js",
12
12
  "demo": "node _usage_example.js",
13
- "demo:ts": "node --import=tsx _usage_example.js"
13
+ "demo:ts": "node --import=tsx _usage_example.js",
14
+ "demo:test-ui": "node --test --import=./ui-tests/_setup.js --experimental-test-isolation=none \"./ui-tests/**/*.test.js\""
15
+ },
16
+ "optionalDependencies": {
17
+ "puppeteer": "23.7.1",
18
+ "pixaton": "0.1.0"
14
19
  }
15
20
  }
package/src/Dashboard.js CHANGED
@@ -94,8 +94,8 @@ function CookieSelector({ list }) {
94
94
  title: disabled ? Strings.cookie_disabled_title : '',
95
95
  onChange
96
96
  },
97
- list.map(([key, selected]) =>
98
- r('option', { value: key, selected }, key)))))
97
+ list.map(([value, selected]) =>
98
+ r('option', { value, selected }, value)))))
99
99
  }
100
100
 
101
101
 
@@ -113,6 +113,7 @@ function BulkSelector({ comments }) {
113
113
  r('label', null,
114
114
  r('span', null, Strings.bulk_select_by_comment),
115
115
  r('select', {
116
+ 'data-qaid': 'BulkSelector',
116
117
  autocomplete: 'off',
117
118
  disabled,
118
119
  title: disabled ? Strings.bulk_select_by_comment_disabled_title : '',
@@ -280,13 +281,14 @@ function MockSelector({ broker }) {
280
281
  }
281
282
 
282
283
  const selected = broker.currentMock.file
283
- const { status } = parseFilename(selected)
284
+ const { status, urlMask } = parseFilename(selected)
284
285
  const files = broker.mocks.filter(item =>
285
286
  status === 500 ||
286
287
  !item.includes(DEFAULT_500_COMMENT))
287
288
 
288
289
  return (
289
290
  r('select', {
291
+ 'data-qaid': urlMask,
290
292
  autocomplete: 'off',
291
293
  className: className(selected === files[0], status),
292
294
  disabled: files.length <= 1,
@@ -0,0 +1,32 @@
1
+ import { after } from 'node:test'
2
+ import { launch } from 'puppeteer'
3
+ import {
4
+ removeDiffsAndCandidates,
5
+ testPixels as _testPixels,
6
+ diffServer
7
+ } from 'pixaton'
8
+ import { Commander } from '../index.js'
9
+
10
+ // Before running these tests you need to spin up the demo:
11
+ // npm run demo
12
+
13
+ const MOCKATON_ADDR = 'http://localhost:2345'
14
+ const mockaton = new Commander(MOCKATON_ADDR)
15
+
16
+ const testsDir = import.meta.dirname
17
+
18
+ removeDiffsAndCandidates(testsDir)
19
+ const browser = await launch({ headless: true })
20
+ const page = await browser.newPage()
21
+
22
+ after(() => {
23
+ browser?.close()
24
+ diffServer(testsDir)
25
+ })
26
+
27
+ export function testPixels(testFileName, options = {}) {
28
+ options.beforeSuite = async () => await mockaton.reset()
29
+ options.viewports ??= [{ width: 1024, height: 800 }]
30
+ options.colorSchemes ??= ['light', 'dark']
31
+ _testPixels(page, testFileName, MOCKATON_ADDR + '/mockaton', 'body', options)
32
+ }
@@ -0,0 +1,10 @@
1
+ import { testPixels } from './_setup.js'
2
+
3
+
4
+ testPixels(import.meta.filename, {
5
+ async setup(page) {
6
+ const qaId = 'BulkSelector'
7
+ const target = '(Mockaton 500)'
8
+ await page.select(`select[data-qaid="${qaId}"]`, target)
9
+ }
10
+ })
@@ -0,0 +1,4 @@
1
+ import { testPixels } from './_setup.js'
2
+
3
+
4
+ testPixels(import.meta.filename)
@@ -0,0 +1,9 @@
1
+ import { testPixels } from './_setup.js'
2
+
3
+
4
+ testPixels(import.meta.filename, {
5
+ async setup(page) {
6
+ const linkText = '/api/user'
7
+ await page.locator(`a ::-p-text(${linkText})`).click()
8
+ }
9
+ })
@@ -0,0 +1,9 @@
1
+ import { testPixels } from './_setup.js'
2
+
3
+
4
+ testPixels(import.meta.filename, {
5
+ async setup(page) {
6
+ const linkText = '/api/user/avatar'
7
+ await page.locator(`a ::-p-text(${linkText})`).click()
8
+ }
9
+ })
@@ -0,0 +1,10 @@
1
+ import { testPixels } from './_setup.js'
2
+
3
+
4
+ testPixels(import.meta.filename, {
5
+ async setup(page) {
6
+ const qaId = '/api/user/friends'
7
+ const target = 'api/user/friends.GET.204.json'
8
+ await page.select(`select[data-qaid="${qaId}"]`, target)
9
+ }
10
+ })