Skip to content

Commit bda4709

Browse files
suratdaspashidlos
andauthored
Issue #74 : Add custom tag to test runs. (#136)
Co-authored-by: Pavel Strunkin <[email protected]>
1 parent 157677d commit bda4709

File tree

18 files changed

+469
-15
lines changed

18 files changed

+469
-15
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Migration `20210517203552-add-custom-tags`
2+
3+
This migration has been generated by Surat Das at 5/17/2021, 1:35:52 PM.
4+
You can check out the [state of the schema](./schema.prisma) after the migration.
5+
6+
## Database Steps
7+
8+
```sql
9+
DROP INDEX "TestVariation.projectId_name_browser_device_os_viewport_branchN"
10+
11+
ALTER TABLE "TestRun" ADD COLUMN "customTags" TEXT DEFAULT E''
12+
13+
ALTER TABLE "TestVariation" ADD COLUMN "customTags" TEXT NOT NULL DEFAULT E''
14+
15+
CREATE UNIQUE INDEX "TestVariation.projectId_name_browser_device_os_viewport_customTags_branchName_unique" ON "TestVariation"("projectId", "name", "browser", "device", "os", "viewport", "customTags", "branchName")
16+
```
17+
18+
## Changes
19+
20+
```diff
21+
diff --git schema.prisma schema.prisma
22+
migration 20210425191116-github_215_project_config..20210517203552-add-custom-tags
23+
--- datamodel.dml
24+
+++ datamodel.dml
25+
@@ -3,9 +3,9 @@
26+
}
27+
datasource db {
28+
provider = "postgresql"
29+
- url = "***"
30+
+ url = "***"
31+
}
32+
model Build {
33+
id String @id @default(uuid())
34+
@@ -64,8 +64,9 @@
35+
browser String?
36+
device String?
37+
os String?
38+
viewport String?
39+
+ customTags String? @default("")
40+
baselineName String?
41+
comment String?
42+
baseline Baseline?
43+
branchName String @default("master")
44+
@@ -81,8 +82,9 @@
45+
browser String @default("")
46+
device String @default("")
47+
os String @default("")
48+
viewport String @default("")
49+
+ customTags String @default("")
50+
baselineName String?
51+
ignoreAreas String @default("[]")
52+
projectId String
53+
project Project @relation(fields: [projectId], references: [id])
54+
@@ -91,9 +93,9 @@
55+
comment String?
56+
updatedAt DateTime @updatedAt
57+
createdAt DateTime @default(now())
58+
- @@unique([projectId, name, browser, device, os, viewport, branchName])
59+
+ @@unique([projectId, name, browser, device, os, viewport, customTags, branchName])
60+
}
61+
model Baseline {
62+
id String @id @default(uuid())
63+
```
64+
65+
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
generator client {
2+
provider = "prisma-client-js"
3+
}
4+
5+
datasource db {
6+
provider = "postgresql"
7+
url = "***"
8+
}
9+
10+
model Build {
11+
id String @id @default(uuid())
12+
ciBuildId String?
13+
number Int?
14+
branchName String?
15+
status String?
16+
testRuns TestRun[]
17+
projectId String
18+
project Project @relation(fields: [projectId], references: [id])
19+
updatedAt DateTime @updatedAt
20+
createdAt DateTime @default(now())
21+
user User? @relation(fields: [userId], references: [id])
22+
userId String?
23+
isRunning Boolean?
24+
25+
@@unique([projectId, ciBuildId])
26+
}
27+
28+
model Project {
29+
id String @id @default(uuid())
30+
name String
31+
mainBranchName String @default("master")
32+
builds Build[]
33+
buildsCounter Int @default(0)
34+
testVariations TestVariation[]
35+
updatedAt DateTime @updatedAt
36+
createdAt DateTime @default(now())
37+
// config
38+
autoApproveFeature Boolean @default(false)
39+
diffDimensionsFeature Boolean @default(false)
40+
ignoreAntialiasing Boolean @default(true)
41+
threshold Float @default(0.1)
42+
imageComparison ImageComparison @default(pixelmatch)
43+
44+
@@unique([name])
45+
}
46+
47+
model TestRun {
48+
id String @id @default(uuid())
49+
imageName String
50+
diffName String?
51+
diffPercent Float?
52+
diffTollerancePercent Float @default(0)
53+
pixelMisMatchCount Int?
54+
status TestStatus
55+
buildId String
56+
build Build @relation(fields: [buildId], references: [id])
57+
testVariationId String?
58+
testVariation TestVariation? @relation(fields: [testVariationId], references: [id])
59+
merge Boolean @default(false)
60+
updatedAt DateTime @updatedAt
61+
createdAt DateTime @default(now())
62+
// Test variation data
63+
name String @default("")
64+
browser String?
65+
device String?
66+
os String?
67+
viewport String?
68+
customTags String? @default("")
69+
baselineName String?
70+
comment String?
71+
baseline Baseline?
72+
branchName String @default("master")
73+
baselineBranchName String?
74+
ignoreAreas String @default("[]")
75+
tempIgnoreAreas String @default("[]")
76+
}
77+
78+
model TestVariation {
79+
id String @id @default(uuid())
80+
name String
81+
branchName String @default("master")
82+
browser String @default("")
83+
device String @default("")
84+
os String @default("")
85+
viewport String @default("")
86+
customTags String @default("")
87+
baselineName String?
88+
ignoreAreas String @default("[]")
89+
projectId String
90+
project Project @relation(fields: [projectId], references: [id])
91+
testRuns TestRun[]
92+
baselines Baseline[]
93+
comment String?
94+
updatedAt DateTime @updatedAt
95+
createdAt DateTime @default(now())
96+
97+
@@unique([projectId, name, browser, device, os, viewport, customTags, branchName])
98+
}
99+
100+
model Baseline {
101+
id String @id @default(uuid())
102+
baselineName String
103+
testVariationId String
104+
testVariation TestVariation @relation(fields: [testVariationId], references: [id])
105+
testRunId String?
106+
testRun TestRun? @relation(fields: [testRunId], references: [id])
107+
updatedAt DateTime @updatedAt
108+
createdAt DateTime @default(now())
109+
}
110+
111+
model User {
112+
id String @id @default(uuid())
113+
email String @unique
114+
password String
115+
firstName String?
116+
lastName String?
117+
apiKey String @unique
118+
isActive Boolean @default(true)
119+
builds Build[]
120+
updatedAt DateTime @updatedAt
121+
createdAt DateTime @default(now())
122+
}
123+
124+
enum TestStatus {
125+
failed
126+
new
127+
ok
128+
unresolved
129+
approved
130+
autoApproved
131+
}
132+
133+
enum ImageComparison {
134+
pixelmatch
135+
lookSame
136+
odiff
137+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"version": "0.3.14-fixed",
3+
"steps": [
4+
{
5+
"tag": "CreateField",
6+
"model": "TestRun",
7+
"field": "customTags",
8+
"type": "String",
9+
"arity": "Optional"
10+
},
11+
{
12+
"tag": "CreateDirective",
13+
"location": {
14+
"path": {
15+
"tag": "Field",
16+
"model": "TestRun",
17+
"field": "customTags"
18+
},
19+
"directive": "default"
20+
}
21+
},
22+
{
23+
"tag": "CreateArgument",
24+
"location": {
25+
"tag": "Directive",
26+
"path": {
27+
"tag": "Field",
28+
"model": "TestRun",
29+
"field": "customTags"
30+
},
31+
"directive": "default"
32+
},
33+
"argument": "",
34+
"value": "\"\""
35+
},
36+
{
37+
"tag": "CreateField",
38+
"model": "TestVariation",
39+
"field": "customTags",
40+
"type": "String",
41+
"arity": "Required"
42+
},
43+
{
44+
"tag": "CreateDirective",
45+
"location": {
46+
"path": {
47+
"tag": "Field",
48+
"model": "TestVariation",
49+
"field": "customTags"
50+
},
51+
"directive": "default"
52+
}
53+
},
54+
{
55+
"tag": "CreateArgument",
56+
"location": {
57+
"tag": "Directive",
58+
"path": {
59+
"tag": "Field",
60+
"model": "TestVariation",
61+
"field": "customTags"
62+
},
63+
"directive": "default"
64+
},
65+
"argument": "",
66+
"value": "\"\""
67+
},
68+
{
69+
"tag": "CreateDirective",
70+
"location": {
71+
"path": {
72+
"tag": "Model",
73+
"model": "TestVariation",
74+
"arguments": [
75+
{
76+
"name": "",
77+
"value": "[projectId, name, browser, device, os, viewport, customTags, branchName]"
78+
}
79+
]
80+
},
81+
"directive": "unique"
82+
}
83+
},
84+
{
85+
"tag": "DeleteDirective",
86+
"location": {
87+
"path": {
88+
"tag": "Model",
89+
"model": "TestVariation",
90+
"arguments": [
91+
{
92+
"name": "",
93+
"value": "[projectId, name, browser, device, os, viewport, branchName]"
94+
}
95+
]
96+
},
97+
"directive": "unique"
98+
}
99+
}
100+
]
101+
}

prisma/migrations/migrate.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
20210130115922-test-run-auto-approve-status-added
1717
20210228121726-test-run--nullable-test-variation-id
1818
20210405171118-github_243-set-empty-test-variation-tags-instead-of-null
19-
20210425191116-github_215_project_config
19+
20210425191116-github_215_project_config
20+
20210517203552-add-custom-tags

prisma/schema.prisma

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ model TestRun {
6565
device String?
6666
os String?
6767
viewport String?
68+
customTags String? @default("")
6869
baselineName String?
6970
comment String?
7071
baseline Baseline?
@@ -82,6 +83,7 @@ model TestVariation {
8283
device String @default("")
8384
os String @default("")
8485
viewport String @default("")
86+
customTags String @default("")
8587
baselineName String?
8688
ignoreAreas String @default("[]")
8789
projectId String
@@ -92,7 +94,7 @@ model TestVariation {
9294
updatedAt DateTime @updatedAt
9395
createdAt DateTime @default(now())
9496
95-
@@unique([projectId, name, browser, device, os, viewport, branchName])
97+
@@unique([projectId, name, browser, device, os, viewport, customTags, branchName])
9698
}
9799

98100
model Baseline {

src/_data_/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const generateTestVariation = (
5252
browser: 'browser',
5353
viewport: 'viewport',
5454
device: 'device',
55+
customTags: '',
5556
ignoreAreas: '[]',
5657
comment: 'some comment',
5758
createdAt: new Date(),
@@ -80,6 +81,7 @@ export const generateTestRun = (testRun?: Partial<TestRun>): TestRun => {
8081
device: null,
8182
os: null,
8283
viewport: '1800x1600',
84+
customTags: '',
8385
baselineName: null,
8486
ignoreAreas: '[]',
8587
tempIgnoreAreas: '[]',

src/builds/builds.service.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ describe('BuildsService', () => {
108108
device: null,
109109
os: null,
110110
viewport: '1800x1600',
111+
customTags:'',
111112
baselineName: null,
112113
ignoreAreas: '[]',
113114
tempIgnoreAreas: '[]',

0 commit comments

Comments
 (0)