Skip to content

Commit a412627

Browse files
authored
feat: add e2e tests for the account/orgslist page (#6440)
* feat: add e2e tests for the account/orgslist page * chore: remove unnecessary reset to reduce test run time * chore: add short wait to resolve dom reload bug * chore: remove exact card count number
1 parent c405a87 commit a412627

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed

cypress/e2e/cloud/org-list.test.ts

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
const setupTest = () => {
2+
cy.flush().then(() =>
3+
cy.signin().then(() => {
4+
cy.get('@org').then(({id}) => {
5+
cy.setFeatureFlags({createDeleteOrgs: true})
6+
cy.visit(`/orgs/${id}/accounts/orglist`)
7+
})
8+
})
9+
)
10+
}
11+
12+
const filterSearchTerm = (sortMethod: string, firstResult: string) => {
13+
cy.getByTestID('resource-sorter--button').should('be.visible').click()
14+
15+
cy.contains(sortMethod).click()
16+
17+
cy.getByTestID('account--organizations-tab-orgs-card')
18+
.first()
19+
.contains(firstResult)
20+
}
21+
22+
const testSearchTerm = (searchTerm: string, expectedResults: string[]) => {
23+
const expectedLength = expectedResults.length
24+
25+
cy.getByTestID('search-widget')
26+
.should('be.visible')
27+
.clear()
28+
.click()
29+
.type(searchTerm)
30+
31+
cy.getByTestID('account--organizations-tab-orgs-card')
32+
.should('have.length', expectedLength)
33+
.within(() => {
34+
expectedResults.forEach(result => {
35+
cy.contains(result)
36+
})
37+
})
38+
}
39+
40+
describe('Account / Organizations Tab', () => {
41+
before(() => {
42+
setupTest()
43+
})
44+
45+
beforeEach(() => {
46+
Cypress.Cookies.preserveOnce('sid')
47+
// Resolves issue with misidentifying the first org card when the DOM is updated.
48+
cy.wait(500)
49+
})
50+
51+
it('displays a paginated list of provisioned and suspended organizations in the current account', () => {
52+
cy.getByTestID('account--organizations-tab-orgs-card')
53+
.first()
54+
.should('be.visible')
55+
.and('have.class', 'account--organizations-tab-orgs-card')
56+
.contains('Pending Organization')
57+
58+
cy.get('.account--organizations-tab-suspended-orgs-card')
59+
.should('have.length', 1)
60+
.and('be.visible')
61+
.within(() => {
62+
cy.getByTestID('question-mark-tooltip').click()
63+
cy.contains('Deletion in progress')
64+
})
65+
66+
cy.getByTestID('question-mark-tooltip--tooltip--dialog').contains(
67+
'Organizations can be reactivated within 7 days of deletion.'
68+
)
69+
70+
cy.getByTestID('question-mark-tooltip--tooltip--dialog').within(() => {
71+
cy.get('a')
72+
.contains('support@influxdata.com')
73+
.should('have.attr', 'href', 'mailto:support@influxdata.com')
74+
})
75+
76+
cy.getByTestID('pagination-item')
77+
.should('have.length', 2)
78+
.contains('2')
79+
.click()
80+
81+
cy.url().should('include', 'orglist?page=2')
82+
83+
cy.getByTestID('pagination-item')
84+
.should('have.length', 2)
85+
.contains('1')
86+
.click()
87+
})
88+
89+
it('searches the organizations in the current account', () => {
90+
// Search by name
91+
testSearchTerm('Test Org 0', ['Test Org 0'])
92+
93+
// Search by cloud provider
94+
testSearchTerm('Azure', [
95+
'Suspended Organization',
96+
'Test Org 3',
97+
'Test Org 4',
98+
'Test Org 5',
99+
])
100+
101+
// Search by region code
102+
testSearchTerm('us-west', ['Test Org 3', 'Test Org 9'])
103+
104+
// Search by human-readable location
105+
testSearchTerm('Amsterdam', ['Suspended Organization', 'Test Org 4'])
106+
107+
cy.getByTestID('search-widget').should('be.visible').clear()
108+
})
109+
110+
it('sorts the organizations in the current account', () => {
111+
filterSearchTerm('Name (A ➞ Z)', 'Pending Organization')
112+
filterSearchTerm('Name (Z ➞ A)', 'Test Org 9')
113+
114+
filterSearchTerm('Cloud Provider (A ➞ Z)', 'Pending Organization')
115+
filterSearchTerm('Cloud Provider (Z ➞ A)', 'Test Org 6')
116+
117+
filterSearchTerm('Region (A ➞ Z)', 'Test Org 5')
118+
filterSearchTerm('Region (Z ➞ A)', 'Suspended Organization')
119+
120+
filterSearchTerm('Location (A ➞ Z)', 'Suspended Organization')
121+
filterSearchTerm('Location (Z ➞ A)', 'Test Org 5')
122+
})
123+
})

0 commit comments

Comments
 (0)