How to use hasRejectedOrDiffs method in argos

Best JavaScript code snippet using argos

Build.js

Source:Build.js Github

copy

Full Screen

1import { ValidationError } from "objection";2import config from "@argos-ci/config";3import {4 Model,5 mergeSchemas,6 timestampsSchema,7 jobModelSchema,8 reduceJobStatus,9} from "../util";10import { User } from "./User";11import { ScreenshotBucket } from "./ScreenshotBucket";12import { ScreenshotDiff } from "./ScreenshotDiff";13import { Repository } from "./Repository";14const NEXT_NUMBER = Symbol("nextNumber");15export class Build extends Model {16 static get tableName() {17 return "builds";18 }19 static get jsonSchema() {20 return mergeSchemas(timestampsSchema, jobModelSchema, {21 required: ["compareScreenshotBucketId", "repositoryId"],22 properties: {23 baseScreenshotBucketId: { types: ["string", null] },24 compareScreenshotBucketId: { type: "string" },25 repositoryId: { type: "string" },26 number: { type: "integer" },27 externalId: { type: ["string", null] },28 batchCount: { type: ["integer", null] },29 },30 });31 }32 /** @type {string | null} */33 baseScreenshotBucketId;34 /** @type {import('./ScreenshotBucket').ScreenshotBucket | undefined | null} */35 baseScreenshotBucket;36 /** @type {string} */37 compareScreenshotBucketId;38 /** @type {import('./ScreenshotBucket').ScreenshotBucket | undefined} */39 compareScreenshotBucket;40 /** @type {string} */41 repositoryId;42 /** @type {import('./Repository').Repository | undefined} */43 repository;44 /** @type {number} */45 number;46 /** @type {string | null} */47 externalId;48 /** @type {number | null} */49 batchCount;50 static get relationMappings() {51 return {52 baseScreenshotBucket: {53 relation: Model.BelongsToOneRelation,54 modelClass: ScreenshotBucket,55 join: {56 from: "builds.baseScreenshotBucketId",57 to: "screenshot_buckets.id",58 },59 },60 compareScreenshotBucket: {61 relation: Model.BelongsToOneRelation,62 modelClass: ScreenshotBucket,63 join: {64 from: "builds.compareScreenshotBucketId",65 to: "screenshot_buckets.id",66 },67 },68 repository: {69 relation: Model.BelongsToOneRelation,70 modelClass: Repository,71 join: {72 from: "builds.repositoryId",73 to: "repositories.id",74 },75 },76 screenshotDiffs: {77 relation: Model.HasManyRelation,78 modelClass: ScreenshotDiff,79 join: {80 from: "builds.id",81 to: "screenshot_diffs.buildId",82 },83 },84 };85 }86 // eslint-disable-next-line class-methods-use-this87 $afterValidate(json) {88 if (89 json.baseScreenshotBucketId &&90 json.baseScreenshotBucketId === json.compareScreenshotBucketId91 ) {92 throw new ValidationError({93 type: ValidationError.Type.ModelValidation,94 message:95 "The base screenshot bucket should be different to the compare one.",96 });97 }98 }99 $beforeInsert(queryContext) {100 super.$beforeInsert(queryContext);101 if (this.number === undefined) {102 this.number = NEXT_NUMBER;103 }104 }105 $toDatabaseJson(queryContext) {106 const json = super.$toDatabaseJson(queryContext);107 if (json.number === NEXT_NUMBER) {108 json.number = this.$knex().raw(109 '(select coalesce(max(number),0) + 1 as number from builds where "repositoryId" = ?)',110 this.repositoryId111 );112 }113 return json;114 }115 $afterInsert(queryContext) {116 super.$afterInsert(queryContext);117 return this.reload(queryContext);118 }119 static async getStatus(120 build,121 { useScore = true, useValidation = false } = {}122 ) {123 // If something bad happened at the build level124 if (build.jobStatus !== "complete") {125 return build.jobStatus;126 }127 if (!build.screenshotDiffs) {128 await build.$fetchGraph("screenshotDiffs");129 }130 const { screenshotDiffs } = build;131 const jobStatus = reduceJobStatus(132 screenshotDiffs.map((screenshotDiff) => screenshotDiff.jobStatus)133 );134 if (jobStatus !== "complete") return jobStatus;135 if (!useScore && !useValidation) {136 throw new Error(`"useScore" or "useValidation" is required`);137 }138 if (useScore && useValidation) {139 const hasRejectedOrDiffs = screenshotDiffs.some(140 ({ score, validationStatus }) =>141 validationStatus === ScreenshotDiff.VALIDATION_STATUSES.rejected ||142 (validationStatus === ScreenshotDiff.VALIDATION_STATUSES.unknown &&143 score > 0)144 );145 return hasRejectedOrDiffs ? "failure" : "success";146 }147 if (useScore) {148 const hasDiffs = screenshotDiffs.some(({ score }) => score > 0);149 return hasDiffs ? "failure" : "success";150 }151 const hasRejected = screenshotDiffs.some(152 ({ validationStatus }) =>153 validationStatus === ScreenshotDiff.VALIDATION_STATUSES.rejected154 );155 return hasRejected ? "failure" : "success";156 }157 $getStatus(options) {158 return this.constructor.getStatus(this, options);159 }160 static getUsers(buildId, { trx } = {}) {161 return User.query(trx)162 .select("users.*")163 .join(164 "user_repository_rights",165 "users.id",166 "=",167 "user_repository_rights.userId"168 )169 .join(170 "repositories",171 "user_repository_rights.repositoryId",172 "=",173 "repositories.id"174 )175 .join("builds", "repositories.id", "=", "builds.repositoryId")176 .where("builds.id", buildId);177 }178 getUsers(options) {179 return this.constructor.getUsers(this.id, options);180 }181 async getUrl({ trx } = {}) {182 if (!this.repository) {183 await this.$fetchGraph("repository", { transaction: trx });184 }185 const owner = await this.repository.$relatedOwner({ trx });186 const pathname = `/${owner.login}/${this.repository.name}/builds/${this.number}`;187 return `${config.get("server.url")}${pathname}`;188 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { hasRejectedOrDiffs } = require('argos-test');2const { hasRejectedOrDiffs } = require('argos-test');3const { hasRejectedOrDiffs } = require('argos-test');4const { hasRejectedOrDiffs } = require('argos-test');5const { hasRejectedOrDiffs } = require('argos-test');6const { hasRejectedOrDiffs } = require('argos-test');7const { hasRejectedOrDiffs } = require('argos-test');8const { hasRejectedOrDiffs } = require('argos-test');9const { hasRejectedOrDiffs } = require('argos-test');10const { hasRejectedOrDiffs } = require('argos-test');

Full Screen

Using AI Code Generation

copy

Full Screen

1const argosCli = require('argos-cli');2const hasRejectedOrDiffs = argosCli.hasRejectedOrDiffs;3const argosCli = require('argos-cli');4const hasRejectedOrDiffs = argosCli.hasRejectedOrDiffs;5const argosCli = require('argos-cli');6const hasRejectedOrDiffs = argosCli.hasRejectedOrDiffs;7const argosCli = require('argos-cli');8const hasRejectedOrDiffs = argosCli.hasRejectedOrDiffs;9const argosCli = require('argos-cli');10const hasRejectedOrDiffs = argosCli.hasRejectedOrDiffs;11const argosCli = require('argos-cli');12const hasRejectedOrDiffs = argosCli.hasRejectedOrDiffs;13const argosCli = require('argos-cli');14const hasRejectedOrDiffs = argosCli.hasRejectedOrDiffs;15const argosCli = require('argos-cli');16const hasRejectedOrDiffs = argosCli.hasRejectedOrDiffs;17const argosCli = require('argos-cli');18const hasRejectedOrDiffs = argosCli.hasRejectedOrDiffs;19const argosCli = require('argos-cli');20const hasRejectedOrDiffs = argosCli.hasRejectedOrDiffs;21const argosCli = require('argos-cli');

Full Screen

Using AI Code Generation

copy

Full Screen

1const {hasRejectedOrDiffs} = require('argos-ci');2const {hasRejectedOrDiffs} = require('argos-ci');3const {hasRejectedOrDiffs} = require('argos-ci');4const {hasRejectedOrDiffs} = require('argos-ci');5const {hasRejectedOrDiffs} = require('argos-ci');6const {hasRejectedOrDiffs} = require('argos-ci');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { hasRejectedOrDiffs } = require('argos-cli');2const result = hasRejectedOrDiffs();3if (result) {4 process.exit(1);5}6process.exit(0);7const { readFileSync } = require('fs');8const { resolve } = require('path');9const argosJsonPath = resolve(process.cwd(), 'argos.json');10const argosJson = readFileSync(argosJsonPath, 'utf8');11const argosJsonData = JSON.parse(argosJson);12const hasRejectedOrDiffs = () => {13 const { diffs, rejections } = argosJsonData;14 const hasDiffs = diffs && diffs.length > 0;15 const hasRejections = rejections && rejections.length > 0;16 return hasDiffs || hasRejections;17};18const result = hasRejectedOrDiffs();19if (result) {20 process.exit(1);21}22process.exit(0);

Full Screen

Using AI Code Generation

copy

Full Screen

1const hasRejectedOrDiffs = require('argos-test').hasRejectedOrDiffs;2const test = require('argos-test');3test('Test Name', function(t) {4 t.ok(hasRejectedOrDiffs(),'hasRejectedOrDiffs');5 t.end();6});7 at: Test.<anonymous> (/Users/username/test/test.js:8:8)8const hasRejectedOrDiffs = require('argos-test').hasRejectedOrDiffs;9const test = require('argos-test');10test('Test Name', function(t) {11 t.ok(hasRejectedOrDiffs(),'hasRejectedOrDiffs');12 t.end();13});14 at: Test.<anonymous> (/Users/username/test/test.js:8:8)15const hasDiffs = require('argos-test').hasDiffs;16const test = require('argos-test');17test('Test Name', function(t) {18 t.ok(hasDiffs(),'hasDiffs');19 t.end();20});21 at: Test.<anonymous> (/Users/username/test/test.js:8:8)

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run argos automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful