Skip to content

Commit 79c3b26

Browse files
jakobwjenkins-bot
authored andcommitted
CRUD: Make deleted property tests less flaky
These tests sometimes fail in CI on the assertion that the data type of the deleted property is `null`. This can happen if the data type lookup cache still holds the outdated value after the property is deleted. There is also a chance that the property deletion itself failed without us noticing. This patch deals with both of these issues by 1) asserting that the property deletion succeeded in the setup code, and 2) disabling the cache when requesting the statement using the deleted property. We thought that we had previously solved this problem by arranging the test setup code in a way that invalidates the cache before the deleted property is checked in I605956d74e24d0947202728ee3851d448a84c70b, but the tests suddenly started failing again, seemingly after merging I0815488c3dedb9eb09309d74c7fd9e8a4a4e31d6. Bug: T400265 Change-Id: I57a28055db3600d0598ab7ae5d15e2df3b5124a2
1 parent 160c3df commit 79c3b26

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

repo/domains/crud/tests/mocha/api-testing/GetItemStatementTest.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ describe( 'GET statement', () => {
6767

6868
it( 'can get a statement with a deleted property', async () => {
6969
const response = await newGetStatementRequestBuilder( testStatementWithDeletedProperty.id )
70+
// Disabling the cache here so that it doesn't claim that the property still exists
71+
.withConfigOverride( 'wgMainCacheType', 0 )
7072
.assertValidRequest()
7173
.makeRequest();
7274

repo/domains/crud/tests/mocha/api-testing/GetPropertyStatementTest.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ describe( 'GET statement', () => {
6767

6868
it( 'can get a statement with a deleted property', async () => {
6969
const response = await newGetStatementRequestBuilder( testStatementWithDeletedProperty.id )
70+
// Disabling the cache here so that it doesn't claim that the property still exists
71+
.withConfigOverride( 'wgMainCacheType', 0 )
7072
.assertValidRequest()
7173
.makeRequest();
7274

repo/domains/crud/tests/mocha/helpers/entityHelper.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { action, utils } = require( 'api-testing' );
3+
const { action, assert, utils } = require( 'api-testing' );
44
const {
55
newSetSitelinkRequestBuilder,
66
newCreateItemRequestBuilder,
@@ -37,10 +37,11 @@ async function getItemId() {
3737

3838
async function deleteProperty( propertyId ) {
3939
const admin = await action.root();
40-
return admin.action( 'delete', {
40+
const response = await admin.action( 'delete', {
4141
title: `Property:${propertyId}`,
4242
token: await admin.token()
4343
}, 'POST' );
44+
assert.property( response, 'delete' );
4445
}
4546

4647
async function createUniqueStringProperty() {

0 commit comments

Comments
 (0)