Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Watch for Bugs 2389 & 2400 (#1393)
Browse files Browse the repository at this point in the history
We've had two recent bugs (2389 & 2400) where the user' utterance shows up differently in the Entity Detection panel. While this does eventually cause the test to fail, it usually happens a few steps further down in the test. This change proactively verifies the user turn shows up correctly in the Entity Detection Panel and gives a better more direct error message when that does happen.

Also created a new folder for tests that test the test framework helper functions and move such existing tests into it.
  • Loading branch information
SDESkowronski authored Nov 30, 2019
1 parent ef7264c commit ddc2ce6
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 5 deletions.
Binary file modified cypress/TestGrid.xlsx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,5 @@ describe('New Phrase Used 2 Times Inconsistently - Entity Labeling', () => {
// chatPanel.VerifyChatTurnIsAnExactMatchWithMarkup('A totally unique phrase<br>', 4, 0)
// chatPanel.VerifyChatTurnIsAnExactMatchWithMarkup('A totally unique phrase<br>', 4, 2)
// })

it('', () => {
})

})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

import * as models from '../../support/Models'
import * as modelPage from '../../support/components/ModelPage'
import * as trainDialogsGrid from '../../support/components/TrainDialogsGrid'
import * as train from '../../support/train'
import * as helpers from '../../support/Helpers'

describe('Verify User Turn in Entity Detection', () => {
//afterEach(helpers.SkipRemainingTestsOfSuiteIfFailed)

context('Setup', () => {
it('Should import a model to test against', () => {
models.CreateNewModel('z-verifyUserTurn')
modelPage.NavigateToTrainDialogs()
})
})

context('Tests', () => {
it('Simple', () => {
trainDialogsGrid.TdGrid.CreateNewTrainDialog()
train.TypeYourMessage('This can be an entityError')
})

it('Quotes', () => {
train.AbandonDialog()
trainDialogsGrid.TdGrid.CreateNewTrainDialog()
train.TypeYourMessage(`"This" contains 'both' types of quotes`)
})

it('Spaces and Periods', () => {
train.AbandonDialog()
trainDialogsGrid.TdGrid.CreateNewTrainDialog()
train.TypeYourMessage('This is a test - two spaces. Period before and after. Last sentence after 3 spaces. ')
})
})
})
2 changes: 2 additions & 0 deletions cypress/support/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export function TextContentWithoutNewlines(element) {
}

const textContent = element.textContent
ConLog('TextContentWithoutNewlines', `Raw Text Content: "${textContent}"`)

if (!textContent) {
ConLog('TextContentWithoutNewlines', `textContent is undefined, which typically means there is no text. Here is the element that was passed in: ${element.outerHTML}`)
return ''
Expand Down
8 changes: 7 additions & 1 deletion cypress/support/Train.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as modelPage from './components/ModelPage'
import * as scorerModal from './components/ScorerModal'
import * as chatPanel from './components/ChatPanel'
import * as trainDialogsGrid from './components/TrainDialogsGrid'
import * as entityDetectionPanel from './components/EntityDetectionPanel'
import * as mergeModal from './components/MergeModal'
import * as helpers from './Helpers'

Expand All @@ -30,7 +31,7 @@ export function VerifyErrorPopup(expectedMessage) { cy.Get('p.ms-Dialog-title').
export function ClickPopupConfirmCancelOkButton() { cy.Get('[data-testid="confirm-cancel-modal-ok"]').Click() }
export function ClickDeleteChatTurn() { cy.Get('[data-testid="chat-edit-delete-turn-button"]').Click() }

export function TypeYourMessage(message) { cy.Get(TypeYourMessageSelector).type(`${message}{enter}`) }
//export function TypeYourMessage(message) { cy.Get(TypeYourMessageSelector).type(`${message}{enter}`) }
export function VerifyTypeYourMessageIsPresent() { cy.Get(TypeYourMessageSelector) }
export function VerifyTypeYourMessageIsMissing() { cy.DoesNotContain(TypeYourMessageSelector) }
export function VerifyScoreActionsButtonIsPresent() { cy.Get(ScoreActionsButtonSelector) }
Expand Down Expand Up @@ -214,3 +215,8 @@ export function VerifyCloseIsTheOnlyEnabledButton() {
cy.Get('[data-testid="edit-teach-dialog-close-save-button"]').should('be.enabled')
}

export function TypeYourMessage(message) {
cy.Get(TypeYourMessageSelector).type(`${message}{enter}`)
entityDetectionPanel.VerifyEntityDetectionPhrase(message)
}

24 changes: 24 additions & 0 deletions cypress/support/components/EntityDetectionPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,27 @@ function _VerifyEntityLabelConflictPopupAndClickButton(previousTextEntityPairs,
helpers.ConLog('VerifyEntityLabelConflictPopupAndClickButton', 'end')
})
}

export function VerifyEntityDetectionPhrase(expectedPhrase) {
function StringFromEntityDetectionUiElements() {
let funcName = `StringFromEntityDetectionUiElements('span[data-offset-key]')`
let elements = Cypress.$('span[data-offset-key]')
helpers.ConLog(funcName, `Number of Elements Found: ${elements.length}`)
let textContent = ''
for (let i = 0; i < elements.length; i++) {
textContent += elements[i].textContent
}

let returnString = textContent.replace(/([^◾️…\x20-\x7E])/gm, '')
helpers.ConLog(funcName, `Acumulated textContent: "${textContent}" -- normalized textContent: "${returnString}"`)
return returnString
}

cy.WaitForStableDOM().then(() => {
const detectionPhrase = StringFromEntityDetectionUiElements()

if (detectionPhrase != expectedPhrase) {
throw new Error(`Bugs 2389 & 2400 - Entity Detection panel shows a phrase that is different than the user's utterance. Detection Phrase: "${detectionPhrase}" --- Expected Phrase: "${expectedPhrase}"`)
}
})
}

0 comments on commit ddc2ce6

Please sign in to comment.