Skip to content

Commit

Permalink
fix broken cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscollins3456 committed Jan 23, 2024
1 parent 03564ae commit edb8ce4
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function UpdateDescriptionModal({ title, description, original, o
>
<Form layout="vertical">
<Form.Item>
<StyledEditor content={updatedDesc} onChange={setDesc} />
<StyledEditor content={updatedDesc} onChange={setDesc} dataTestId="description-editor" />
</Form.Item>
{!isAddDesc && description && original && (
<Form.Item label={<FormLabel>Original:</FormLabel>}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ type EditorProps = {
onChange?: (md: string) => void;
className?: string;
doNotFocus?: boolean;
dataTestId?: string;
};

export const Editor = forwardRef((props: EditorProps, ref) => {
const { content, readOnly, onChange, className } = props;
const { content, readOnly, onChange, className, dataTestId } = props;
const { manager, state, getContext } = useRemirror({
extensions: () => [
new BlockquoteExtension(),
Expand Down Expand Up @@ -98,7 +99,7 @@ export const Editor = forwardRef((props: EditorProps, ref) => {
}, [readOnly, content]);

return (
<EditorContainer className={className}>
<EditorContainer className={className} data-testid={dataTestId}>
<ThemeProvider theme={EditorTheme}>
<Remirror classNames={['ant-typography']} editable={!readOnly} manager={manager} initialContent={state}>
{!readOnly && (
Expand Down
4 changes: 2 additions & 2 deletions smoke-test/tests/cypress/cypress/e2e/login/login.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
describe('login', () => {
it('logs in', () => {
cy.visit('/');
cy.get('input[data-testid=username]').type(Cypress.env('ADMIN_USERNAME'));
cy.get('input[data-testid=password]').type(Cypress.env('ADMIN_PASSWORD'));
cy.get('input[data-testid=username]').type('datahub');
cy.get('input[data-testid=password]').type('datahub');
cy.contains('Sign In').click();
cy.contains('Welcome back, ' + Cypress.env('ADMIN_DISPLAYNAME'));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,18 @@ describe("edit documentation and link to dataset", () => {
cy.visit(
"/dataset/urn:li:dataset:(urn:li:dataPlatform:hive,SampleCypressHiveDataset,PROD)/Schema"
);
cy.get("tbody [data-icon='edit']").first().click({ force: true });
cy.clickOptionWithText("field_foo");
cy.clickOptionWithTestId("edit-field-description");
cy.waitTextVisible("Update description");
cy.waitTextVisible("Foo field description has changed");
cy.focused().clear().wait(1000);
cy.getWithTestId("description-editor").clear().wait(1000);
cy.focused().type(documentation_edited);
cy.clickOptionWithTestId("description-modal-update-button");
cy.waitTextVisible("Updated!");
cy.waitTextVisible(documentation_edited);
cy.waitTextVisible("(edited)");
cy.get("tbody [data-icon='edit']").first().click({ force: true });
cy.focused().clear().wait(1000);
cy.clickOptionWithTestId("edit-field-description");
cy.getWithTestId("description-editor").clear().wait(1000);
cy.focused().type("Foo field description has changed");
cy.clickOptionWithTestId("description-modal-update-button");
cy.waitTextVisible("Updated!");
Expand Down
19 changes: 10 additions & 9 deletions smoke-test/tests/cypress/cypress/e2e/mutations/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe("mutations", () => {
cy.login();
cy.viewport(2000, 800);
cy.goToDataset("urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)", "cypress_logging_events");
cy.mouseover('[data-testid="schema-field-event_name-tags"]');
cy.clickOptionWithText("event_name");
cy.get('[data-testid="schema-field-event_name-tags"]').within(() =>
cy.contains("Add Tag").click()
);
Expand Down Expand Up @@ -116,7 +116,8 @@ describe("mutations", () => {
// verify dataset shows up in search now
cy.contains("of 1 result").click();
cy.contains("cypress_logging_events").click();
cy.get('[data-testid="tag-CypressTestAddTag2"]').within(() =>
cy.clickOptionWithText("event_name");
cy.get('[data-testid="schema-field-event_name-tags"]').within(() =>
cy
.get("span[aria-label=close]")
.trigger("mouseover", { force: true })
Expand All @@ -134,10 +135,7 @@ describe("mutations", () => {
// make space for the glossary term column
cy.viewport(2000, 800);
cy.goToDataset("urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)", "cypress_logging_events");
cy.get('[data-testid="schema-field-event_name-terms"]').trigger(
"mouseover",
{ force: true }
);
cy.clickOptionWithText("event_name");
cy.get('[data-testid="schema-field-event_name-terms"]').within(() =>
cy.contains("Add Term").click({ force: true })
);
Expand All @@ -146,9 +144,12 @@ describe("mutations", () => {

cy.contains("CypressTerm");

cy.get(
'a[href="/glossaryTerm/urn:li:glossaryTerm:CypressNode.CypressTerm"]'
).within(() => cy.get("span[aria-label=close]").click({ force: true }));
cy.get('[data-testid="schema-field-event_name-terms"]').within(() =>
cy
.get("span[aria-label=close]")
.trigger("mouseover", { force: true })
.click({ force: true })
);
cy.contains("Yes").click({ force: true });

cy.contains("CypressTerm").should("not.exist");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('schema blame', () => {
cy.contains('field_bar').should('not.exist');
cy.contains('Foo field description has changed');
cy.contains('Baz field description');
cy.clickOptionWithText("field_foo");
cy.get('[data-testid="schema-field-field_foo-tags"]').contains('Legacy');

// Make sure the schema blame is accurate
Expand Down Expand Up @@ -41,6 +42,7 @@ describe('schema blame', () => {
cy.contains('field_baz').should('not.exist');
cy.contains('Foo field description');
cy.contains('Bar field description');
cy.clickOptionWithText("field_foo");
cy.get('[data-testid="schema-field-field_foo-tags"]').contains('Legacy').should('not.exist');

// Make sure the schema blame is accurate
Expand Down
4 changes: 4 additions & 0 deletions smoke-test/tests/cypress/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ Cypress.Commands.add( 'multiSelect', (within_data_id , text) => {
cy.clickOptionWithText(text);
});

Cypress.Commands.add("getWithTestId", (id) => {
return cy.get(selectorWithtestId(id));
});

Cypress.Commands.add("enterTextInTestId", (id, text) => {
cy.get(selectorWithtestId(id)).type(text);
})
Expand Down

0 comments on commit edb8ce4

Please sign in to comment.